This is just a simple addition, though pretty nasty in some ways. Basically it:
* Allows package-private access to the VMx instance of a reflection class, x. This allows equals to be implemented. * Maintains a reference to the x class in the VMx instance. This allows methods such as isAccessible() to be called. As an alternative to the latter, we could instead implement the access checks in Classpath centrally. Does anyone have any thoughts on this? I've gone against it so far, as I guess it will be inefficent and more disruptive of existing implementations than necessary. But I'm open to contradiction... :) ChangeLog: 2008-03-05 Andrew John Hughes <[EMAIL PROTECTED]> * java/lang/reflect/Constructor.java: (cons): Make package-private. (Constructor(VMConstructor)): Set cons in VM interface. * java/lang/reflect/Field.java: (f): Make package-private. (Field(VMField)): Set f in VM interface. * java/lang/reflect/Method.java: (m): Make package-private. (Method(VMMethod)): Set m in VM interface. * vm/reference/java/lang/reflect/VMConstructor.java: (cons): Added reference to Constructor instance. * vm/reference/java/lang/reflect/VMField.java: (f): Added reference to Field instance. * vm/reference/java/lang/reflect/VMMethod.java, (m): Added reference to Method instance. -- Andrew :) Support Free Java! Contribute to GNU Classpath and the OpenJDK http://www.gnu.org/software/classpath http://openjdk.java.net PGP Key: 94EFD9D8 (http://subkeys.pgp.net) Fingerprint = F8EF F1EA 401E 2E60 15FA 7927 142C 2591 94EF D9D8
Index: java/lang/reflect/Constructor.java =================================================================== RCS file: /sources/classpath/classpath/java/lang/reflect/Constructor.java,v retrieving revision 1.8 diff -u -3 -p -u -r1.8 Constructor.java --- java/lang/reflect/Constructor.java 5 Mar 2008 21:16:37 -0000 1.8 +++ java/lang/reflect/Constructor.java 6 Mar 2008 19:30:59 -0000 @@ -87,7 +87,7 @@ public final class Constructor<T> private MethodSignatureParser p; - private VMConstructor cons; + VMConstructor cons; /** * This class is uninstantiable outside this package. @@ -95,6 +95,7 @@ public final class Constructor<T> Constructor(VMConstructor cons) { this.cons = cons; + cons.cons = this; } private Constructor() Index: java/lang/reflect/Field.java =================================================================== RCS file: /sources/classpath/classpath/java/lang/reflect/Field.java,v retrieving revision 1.8 diff -u -3 -p -u -r1.8 Field.java --- java/lang/reflect/Field.java 5 Mar 2008 21:16:37 -0000 1.8 +++ java/lang/reflect/Field.java 6 Mar 2008 19:30:59 -0000 @@ -88,7 +88,7 @@ extends AccessibleObject implements Memb private FieldSignatureParser p; - private VMField f; + VMField f; /** * This class is uninstantiable outside the package. @@ -96,6 +96,7 @@ extends AccessibleObject implements Memb Field(VMField f) { this.f = f; + f.f = this; } /** Index: java/lang/reflect/Method.java =================================================================== RCS file: /sources/classpath/classpath/java/lang/reflect/Method.java,v retrieving revision 1.7 diff -u -3 -p -u -r1.7 Method.java --- java/lang/reflect/Method.java 5 Mar 2008 21:16:37 -0000 1.7 +++ java/lang/reflect/Method.java 6 Mar 2008 19:30:59 -0000 @@ -88,7 +88,7 @@ extends AccessibleObject implements Memb private MethodSignatureParser p; - private VMMethod m; + VMMethod m; /** * This class is uninstantiable outside this package. @@ -96,6 +96,7 @@ extends AccessibleObject implements Memb Method(VMMethod m) { this.m = m; + m.m = this; } /** Index: vm/reference/java/lang/reflect/VMConstructor.java =================================================================== RCS file: /sources/classpath/classpath/vm/reference/java/lang/reflect/VMConstructor.java,v retrieving revision 1.3 diff -u -3 -p -u -r1.3 VMConstructor.java --- vm/reference/java/lang/reflect/VMConstructor.java 5 Mar 2008 21:16:38 -0000 1.3 +++ vm/reference/java/lang/reflect/VMConstructor.java 6 Mar 2008 19:31:09 -0000 @@ -47,6 +47,12 @@ final class VMConstructor Class clazz; int slot; + /** + * This field allows us to refer back to the main constructor instance. + * It is set by the constructor of Constructor. + */ + Constructor cons; + VMConstructor(Class clazz, int slot) { this.clazz = clazz; Index: vm/reference/java/lang/reflect/VMField.java =================================================================== RCS file: /sources/classpath/classpath/vm/reference/java/lang/reflect/VMField.java,v retrieving revision 1.3 diff -u -3 -p -u -r1.3 VMField.java --- vm/reference/java/lang/reflect/VMField.java 5 Mar 2008 21:16:38 -0000 1.3 +++ vm/reference/java/lang/reflect/VMField.java 6 Mar 2008 19:31:09 -0000 @@ -45,6 +45,12 @@ final class VMField Class declaringClass; String name; int slot; + + /** + * This field allows us to refer back to the main constructor instance. + * It is set by the constructor of Field. + */ + Field f; VMField(Class declaringClass, String name, int slot) { Index: vm/reference/java/lang/reflect/VMMethod.java =================================================================== RCS file: /sources/classpath/classpath/vm/reference/java/lang/reflect/VMMethod.java,v retrieving revision 1.3 diff -u -3 -p -u -r1.3 VMMethod.java --- vm/reference/java/lang/reflect/VMMethod.java 5 Mar 2008 21:16:38 -0000 1.3 +++ vm/reference/java/lang/reflect/VMMethod.java 6 Mar 2008 19:31:09 -0000 @@ -48,6 +48,12 @@ final class VMMethod String name; int slot; + /** + * This field allows us to refer back to the main constructor instance. + * It is set by the constructor of Field. + */ + Method m; + public Class getDeclaringClass() { return declaringClass;
signature.asc
Description: Digital signature