summaryrefslogtreecommitdiff
path: root/libjava/classpath/java/lang/reflect/Proxy.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/java/lang/reflect/Proxy.java')
-rw-r--r--libjava/classpath/java/lang/reflect/Proxy.java133
1 files changed, 11 insertions, 122 deletions
diff --git a/libjava/classpath/java/lang/reflect/Proxy.java b/libjava/classpath/java/lang/reflect/Proxy.java
index dc1ac87e4e1..7a5fd30de16 100644
--- a/libjava/classpath/java/lang/reflect/Proxy.java
+++ b/libjava/classpath/java/lang/reflect/Proxy.java
@@ -38,7 +38,6 @@ exception statement from your version. */
package java.lang.reflect;
-import gnu.classpath.Configuration;
import gnu.java.lang.reflect.TypeSignature;
import java.io.Serializable;
@@ -263,16 +262,16 @@ public class Proxy implements Serializable
Class clazz = (Class) proxyClasses.get(pt);
if (clazz == null)
{
- if (Configuration.HAVE_NATIVE_GET_PROXY_CLASS)
- clazz = getProxyClass0(loader, interfaces);
+ if (VMProxy.HAVE_NATIVE_GET_PROXY_CLASS)
+ clazz = VMProxy.getProxyClass(loader, interfaces);
else
{
- ProxyData data = (Configuration.HAVE_NATIVE_GET_PROXY_DATA
- ? getProxyData0(loader, interfaces)
+ ProxyData data = (VMProxy.HAVE_NATIVE_GET_PROXY_DATA
+ ? VMProxy.getProxyData(loader, interfaces)
: ProxyData.getProxyData(pt));
- clazz = (Configuration.HAVE_NATIVE_GENERATE_PROXY_CLASS
- ? generateProxyClass0(loader, data)
+ clazz = (VMProxy.HAVE_NATIVE_GENERATE_PROXY_CLASS
+ ? VMProxy.generateProxyClass(loader, data)
: new ClassFactory(data).generate(loader));
}
@@ -388,74 +387,6 @@ public class Proxy implements Serializable
}
/**
- * Optional native method to replace (and speed up) the pure Java
- * implementation of getProxyClass. Only needed if
- * Configuration.HAVE_NATIVE_GET_PROXY_CLASS is true, this does the
- * work of both getProxyData0 and generateProxyClass0 with no
- * intermediate form in Java. The native code may safely assume that
- * this class must be created, and does not already exist.
- *
- * @param loader the class loader to define the proxy class in; null
- * implies the bootstrap class loader
- * @param interfaces the interfaces the class will extend
- * @return the generated proxy class
- * @throws IllegalArgumentException if the constraints for getProxyClass
- * were violated, except for problems with null
- * @throws NullPointerException if `interfaces' is null or contains
- * a null entry, or if handler is null
- * @see Configuration#HAVE_NATIVE_GET_PROXY_CLASS
- * @see #getProxyClass(ClassLoader, Class[])
- * @see #getProxyData0(ClassLoader, Class[])
- * @see #generateProxyClass0(ProxyData)
- */
- private static native Class getProxyClass0(ClassLoader loader,
- Class[] interfaces);
-
- /**
- * Optional native method to replace (and speed up) the pure Java
- * implementation of getProxyData. Only needed if
- * Configuration.HAVE_NATIVE_GET_PROXY_DATA is true. The native code
- * may safely assume that a new ProxyData object must be created which
- * does not duplicate any existing ones.
- *
- * @param loader the class loader to define the proxy class in; null
- * implies the bootstrap class loader
- * @param interfaces the interfaces the class will extend
- * @return all data that is required to make this proxy class
- * @throws IllegalArgumentException if the constraints for getProxyClass
- * were violated, except for problems with null
- * @throws NullPointerException if `interfaces' is null or contains
- * a null entry, or if handler is null
- * @see Configuration.HAVE_NATIVE_GET_PROXY_DATA
- * @see #getProxyClass(ClassLoader, Class[])
- * @see #getProxyClass0(ClassLoader, Class[])
- * @see ProxyType#getProxyData()
- */
- private static native ProxyData getProxyData0(ClassLoader loader,
- Class[] interfaces);
-
- /**
- * Optional native method to replace (and speed up) the pure Java
- * implementation of generateProxyClass. Only needed if
- * Configuration.HAVE_NATIVE_GENERATE_PROXY_CLASS is true. The native
- * code may safely assume that a new Class must be created, and that
- * the ProxyData object does not describe any existing class.
- *
- * @param loader the class loader to define the proxy class in; null
- * implies the bootstrap class loader
- * @param data the struct of information to convert to a Class. This
- * has already been verified for all problems except exceeding
- * VM limitations
- * @return the newly generated class
- * @throws IllegalArgumentException if VM limitations are exceeded
- * @see #getProxyClass(ClassLoader, Class[])
- * @see #getProxyClass0(ClassLoader, Class[])
- * @see ProxyData#generateProxyClass(ClassLoader)
- */
- private static native Class generateProxyClass0(ClassLoader loader,
- ProxyData data);
-
- /**
* Helper class for mapping unique ClassLoader and interface combinations
* to proxy classes.
*
@@ -502,49 +433,6 @@ public class Proxy implements Serializable
return hash;
}
- // A more comprehensive comparison of two arrays,
- // ignore array element order, and
- // ignore redundant elements
- private static boolean sameTypes(Class arr1[], Class arr2[]) {
- if (arr1.length == 1 && arr2.length == 1) {
- return arr1[0] == arr2[0];
- }
-
- // total occurrance of elements of arr1 in arr2
- int total_occ_of_arr1_in_arr2 = 0;
- each_type:
- for (int i = arr1.length; --i >= 0; )
- {
- Class t = arr1[i];
- for (int j = i; --j >= 0; )
- {
- if (t == arr1[j])
- { //found duplicate type
- continue each_type;
- }
- }
-
- // count c(a unique element of arr1)'s
- // occurrences in arr2
- int occ_in_arr2 = 0;
- for (int j = arr2.length; --j >= 0; )
- {
- if (t == arr2[j])
- {
- ++occ_in_arr2;
- }
- }
- if (occ_in_arr2 == 0)
- { // t does not occur in arr2
- return false;
- }
-
- total_occ_of_arr1_in_arr2 += occ_in_arr2;
- }
- // now, each element of arr2 must have been visited
- return total_occ_of_arr1_in_arr2 == arr2.length;
- }
-
/**
* Calculates equality.
*
@@ -556,7 +444,10 @@ public class Proxy implements Serializable
ProxyType pt = (ProxyType) other;
if (loader != pt.loader || interfaces.length != pt.interfaces.length)
return false;
- return sameTypes(interfaces, pt.interfaces);
+ for (int i = 0; i < interfaces.length; i++)
+ if (interfaces[i] != pt.interfaces[i])
+ return false;
+ return true;
}
} // class ProxyType
@@ -720,7 +611,7 @@ public class Proxy implements Serializable
*
* @author Eric Blake (ebb9@email.byu.edu)
*/
- private static final class ProxyData
+ static final class ProxyData
{
/**
* The package this class is in <b>including the trailing dot</b>
@@ -876,7 +767,6 @@ public class Proxy implements Serializable
private static final class ClassFactory
{
/** Constants for assisting the compilation */
- private static final byte POOL = 0;
private static final byte FIELD = 1;
private static final byte METHOD = 2;
private static final byte INTERFACE = 3;
@@ -909,7 +799,6 @@ public class Proxy implements Serializable
private static final char GETFIELD = 180;
private static final char INVOKEVIRTUAL = 182;
private static final char INVOKESPECIAL = 183;
- private static final char INVOKESTATIC = 184;
private static final char INVOKEINTERFACE = 185;
private static final char NEW = 187;
private static final char ANEWARRAY = 189;