Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Machine > Re: Adding cons...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 8 Topic 760 of 816
Post > Topic >>

Re: Adding constructor by bytecode instrumentation

by Moritz Hammer <newsgroup001@[EMAIL PROTECTED] > Mar 27, 2007 at 08:58 AM

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
 




 8 Posts in Topic:
Adding constructor by bytecode instrumentation
Moritz Hammer <newsgro  2007-03-20 10:31:39 
Re: Adding constructor by bytecode instrumentation
"Chris Uppal" &  2007-03-20 22:59:01 
Re: Adding constructor by bytecode instrumentation
Moritz Hammer <newsgro  2007-03-23 10:18:44 
Re: Adding constructor by bytecode instrumentation
"Chris Uppal" &  2007-03-26 11:36:05 
Re: Adding constructor by bytecode instrumentation
Moritz Hammer <newsgro  2007-03-26 12:24:53 
Re: Adding constructor by bytecode instrumentation
"Chris Uppal" &  2007-03-27 06:30:04 
Re: Adding constructor by bytecode instrumentation
Moritz Hammer <newsgro  2007-03-27 08:58:39 
Re: Adding constructor by bytecode instrumentation
"Cyril Shelest"  2007-03-29 22:23:19 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 17:43:53 CDT 2008.