On Tue, 27 Mar 2007 06:30:04 +0100, Chris Uppal wrote:
> I'm probably misunderstanding you, but I don't see why you'd have to
load class
> not.defined.Anywhere at all -- there's no need to create an instance
just to
> call a method with that signature. I was able to call my additional
Object
> constuctor with bytecode:
>
> new java/lang/Object
> aconst_null
> invokespecial java/lang/Object/<init> ([Lnot/defined/Anywhere;)V
>
> Which worked, in that my constuctor was called, but of course I had
nothing
> comparable to your custom classloader in my test settup.
I instrument every class with the additional constructor, and if
not.defined.Anywhere is not in the bootclasspath, I get the exception:
Error occurred during initialization of VM
java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:394)
at java.lang.System.initProperties(Native Method)
at java.lang.System.initializeSystemClass(System.java:1072)
This is independent on whether not.defined.Anywhere is in the classpath or
not. I excluded various cl***** from instrumentation, and eventually found
that if I exclude the ClassLoader subcl***** and some cl***** from sun.*
packages (apparently related to reading the actual bytecode), thinks work
ok. Therefore I suspect that the ClassLoader cannot be instrumented.
If I instrument java.lang.Object only, things are ok even if
not.defined.Anywhere is indeed not defined anywhere. But then I get a
ClassNotFoundException when I use reflection to see the constructors. I
have not tried assembling the bytecode to invoke the special
java.lang.Object constructor. That might work.
I assume you are right, and not.defined.Anywhere needs not be loaded if it
is used for the signature of a constructor invoked directly. If reflection
is used to get the constructor, and I guess this is the case with the
ClassLoader subcl*****, then not.defined.Anywhere needs to be loaded.
Regards,
Moritz


|