Skip to main content

Is JVMTI RedefineClasses implemented?

2 replies [Last post]
Joined: 2007-12-06

Does RedefineClasses work? I've extracted cdc from the repository and built it on linux-x86 with JVMTI enabled. RedefineClasses seems to be implemented, and potential capabilities contain can_redefine_classes=1, but when my agent calls RedefineClasses, it returns JVMTI_ERROR_INVALID_CLASS. I stepped through with gdb - RedefineClasses calls CVMdefineClass() which returns the error. gdb couldn't go any further. The same test works fine in Java SE.

Do you guys plan to implement RetransformClasses?


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2006-09-19

RedefineClasses should be working as we have used the current CVM code with internal test suites and other agents. What you can do to figure this out is to take the class that you are passing in as the new class and just load it programmatically via Class.forName() and see if it loads that way. If you can't do that, then try running CVM with tracing to see what kind of fault is happening -Xtrace:0x12c0000 which will turn on class loading/lookup, verifier and class linking tracing. (set for flag values). You might also try adding in exception tracing with 0x4000.


Joined: 2007-12-06

It looks like RedefineClasses works, but only one of my tests succeeded, when called from a JVMTI_EVENT_CLASS_PREPARE handler. I tried redefining classes from a JVMTI_EVENT_DATA_DUMP_REQUEST handler, and it failed with JVMTI_ERROR_INVALID_CLASS. My original post is not quite correct: jvmti_RedefineClasses calls CVMjvmtiObject2Class(), and that returned NULL.

I've also tried spawning a new native thread in the agent and attaching the thread to jvm. The thread waits for an external event and calls RedefineClasses. It fails with the same error.

All my tests work with Java SE.

As you recommended, I 've tried calling Class.forName. Class.forName("MyClass") works.

ANy thoughts? Thanks.