[hibernate-commits] Hibernate SVN: r10781 - in trunk/Hibernate3/src/org/hibernate/proxy/pojo: cglib javassist

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Fri Nov 10 23:07:32 EST 2006


Author: scottmarlownovell
Date: 2006-11-10 23:07:31 -0500 (Fri, 10 Nov 2006)
New Revision: 10781

Modified:
   trunk/Hibernate3/src/org/hibernate/proxy/pojo/cglib/CGLIBLazyInitializer.java
   trunk/Hibernate3/src/org/hibernate/proxy/pojo/javassist/JavassistLazyInitializer.java
Log:
Fix for HHH-2229 "Performance issue with fix for HHH-1293, CGLIBLazyInitializer may be slower for certain Java classes"
Also fixed Javaassist which had the same recursive code.


Modified: trunk/Hibernate3/src/org/hibernate/proxy/pojo/cglib/CGLIBLazyInitializer.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/proxy/pojo/cglib/CGLIBLazyInitializer.java	2006-11-10 16:40:49 UTC (rev 10780)
+++ trunk/Hibernate3/src/org/hibernate/proxy/pojo/cglib/CGLIBLazyInitializer.java	2006-11-11 04:07:31 UTC (rev 10781)
@@ -4,11 +4,7 @@
 import java.io.Serializable;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
 
-
 import net.sf.cglib.proxy.Callback;
 import net.sf.cglib.proxy.CallbackFilter;
 import net.sf.cglib.proxy.Enhancer;
@@ -137,34 +133,6 @@
 		this.interfaces = interfaces;
 	}
 
-	private static boolean isCastable(Class caster, Class castee) {
-		if ( castee.equals( caster ) ) {
-			return true;
-		}
-		List list = addCheckingTypes( caster, new ArrayList() );
-		for ( Iterator iter = list.iterator(); iter.hasNext(); ) {
-			Class cl = ( Class ) iter.next();
-			if ( castee.equals( cl ) ) {
-				return true;
-			}
-		}
-		return false;
-	}
-
-	private static List addCheckingTypes(final Class type, final List list) {
-		Class superclass = type.getSuperclass();
-		if ( superclass != null ) {
-			list.add( superclass );
-			addCheckingTypes( superclass, list );
-		}
-		Class[] interfaces = type.getInterfaces();
-		for ( int i = 0; i < interfaces.length; ++i ) {
-			list.add( interfaces[i] );
-			addCheckingTypes( interfaces[i], list );
-		}
-		return list;
-	}
-
 	public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
 		if ( constructed ) {
 			Object result = invoke( method, args, proxy );
@@ -173,10 +141,8 @@
 				final Object returnValue;
 				try {
 					if ( ReflectHelper.isPublic( persistentClass, method ) ) {
-						if ( !isCastable(
-								target.getClass(), method
-								.getDeclaringClass()
-						) ) {
+						if(! ( method.getDeclaringClass().isInstance(target) ) )
+						{
 							throw new ClassCastException(
 									target.getClass()
 											.getName()

Modified: trunk/Hibernate3/src/org/hibernate/proxy/pojo/javassist/JavassistLazyInitializer.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/proxy/pojo/javassist/JavassistLazyInitializer.java	2006-11-10 16:40:49 UTC (rev 10780)
+++ trunk/Hibernate3/src/org/hibernate/proxy/pojo/javassist/JavassistLazyInitializer.java	2006-11-11 04:07:31 UTC (rev 10781)
@@ -153,34 +153,6 @@
 		}
 	}
 
-	private static boolean isCastable(Class caster, Class castee) {
-		if ( castee.equals( caster ) ) {
-			return true;
-		}
-		List list = addCheckingTypes( caster, new ArrayList() );
-		for ( Iterator iter = list.iterator(); iter.hasNext(); ) {
-			Class cl = ( Class ) iter.next();
-			if ( castee.equals( cl ) ) {
-				return true;
-			}
-		}
-		return false;
-	}
-
-	private static List addCheckingTypes(final Class type, final List list) {
-		Class superclass = type.getSuperclass();
-		if ( superclass != null ) {
-			list.add( superclass );
-			addCheckingTypes( superclass, list );
-		}
-		Class[] interfaces = type.getInterfaces();
-		for ( int i = 0; i < interfaces.length; ++i ) {
-			list.add( interfaces[i] );
-			addCheckingTypes( interfaces[i], list );
-		}
-		return list;
-	}
-
 	public Object invoke(
 			final Object proxy,
 			final Method thisMethod,
@@ -199,7 +171,7 @@
 				final Object returnValue;
 				try {
                     if ( ReflectHelper.isPublic( persistentClass, thisMethod ) ) {
-                    	if ( !isCastable( target.getClass(), thisMethod.getDeclaringClass()) ) {
+						   if(! ( thisMethod.getDeclaringClass().isInstance(target) ) ) {
                     		throw new ClassCastException( target.getClass().getName() );
                     	}
                     	returnValue = thisMethod.invoke( target, args );




More information about the hibernate-commits mailing list