RFC: Changing Class.newInstance() to add VM specific feature

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I've added a new access modifier to IKVM. By applying the
@ikvm.lang.Internal annotation to a type or member, you can mark it as
internal to the library it resides in. Hopefully Java will provide
something similar with JSR 277, but I've decided not to wait on that.

To support this access level with reflection, I've modified
Method/Constructor/Field (of which I include my own versions with IKVM,
so that was easy), but I also need to modify Class.newInstance().

Would anybody object to adding a hook for this? It would look something
like this:

Index: java/lang/Class.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/Class.java,v
retrieving revision 1.43
diff -u -r1.43 Class.java
--- java/lang/Class.java	18 Dec 2005 13:03:48 -0000	1.43
+++ java/lang/Class.java	30 Mar 2006 11:04:57 -0000
@@ -1127,7 +1127,8 @@
 	    (Modifier.isPrivate(modifiers)
 	     || getClassLoader() != caller.getClassLoader()
 	     || !getPackagePortion(getName())
-	     .equals(getPackagePortion(caller.getName()))))
+	     .equals(getPackagePortion(caller.getName())))
+            && !VMClass.checkAccess(contructor, caller))
 	  throw new IllegalAccessException(getName()
 					   + " has an inaccessible
constructor");
       }

The vm/reference implementation of VMClass.checkAccess() would simply
return false.

Regards,
Jeroen


[Index of Archives]     [Linux Kernel]     [Linux Cryptography]     [Fedora]     [Fedora Directory]     [Red Hat Development]

  Powered by Linux