extending the constant pool continued

Tom Rodriguez Thomas.Rodriguez at Sun.COM
Thu Jun 21 12:49:33 PDT 2007

Patrick McNally wrote:
> So what I've 
> been doing is creating a new constant pool with the extra number of 
> entries, adding what I want to this new pool and then reassigning the 
> original constant pool's handle to point to my new one.

What do you mean by this?  Handles aren't like reference parameters where you 
can assign to them and have every piece of code which referred the old handle 
refer to the new one.  You have to make sure that the code is structured so that 
every user picks up the new one either by returning the new one or reloading it 
from the class.  Also there are cross links between the class and the constant 
pool and you'll need to update those.  It's a little hard to tell you what 
you're doing wrong without the actual code too.

As Tim pointed out there are ways using JVMTI and 
java.lang.instrument.Instrumentation to do bytecode rewriting without modifying 
the JVM which might be easier and more appropriate.


More information about the hotspot-dev mailing list