Reputation:

redefineClasses in JVMTI

I have two questions

  1. Does redefineClasses work with JIT enabled JVM?

  2. If so, in multithreaded applications, if one thread uses redefineClasses to redefine a class, does another thread see that redefined class? (especially, if the other thread is running jit compiled code?)

Upvotes: 0

Views: 1072

Answers (2)

JZeeb
JZeeb

Reputation: 321

Regarding question 2 - yes, the others threads will see the redefined classes. There is one restriction - if you modify a method in one thread while another thread is executing that method, that thread continues to execute the old bytecodes. If the other thread returns from the method, then call the method again; it will execute the new bytecodes. The JVM will not switch the bytecodes for a method while that method is active.

Upvotes: 1

Paul Keeble
Paul Keeble

Reputation: 1222

A1 - Using a Javaagent redefineClasses works within JIT, but puts limitations on the changes that can be made. Obviously this is not the same mechanism as JVMTI but underneith they are both using the same API so I would expect you will see the same result.

A2 - I have never used anything other than the thread that the JVM gave me. Since the changes affect the ClassLoaders I see no reason why it won't work but that does not help you know for sure.

Upvotes: 0

Related Questions