Before NPG the GC would find all used methodOopDescs by tracing through the heap. With NPG Methods are not java Objects anymore, and the GC don't find them by normal tracing of the heap.
The users of Method* needs to do two thing:
1) Make sure that the Klass is kept alive by exposing either the mirror or the class loader to the GC.
2) Make sure that the the JVM still knows that the Method is being used.
If (1) is missed, we might unload the Klass prematurely.
If (2) is missed, the method can be deallocated if it has been redefined.
We currently have two options to handle (2).
a) Make sure that Method::set_on_stack(true) is called during MetadataOnStackMark()
b) Use a methodHandle instead of a Method*.
We need to make sure that uses of Method* adhere to these requirements. Preferably, by some code constructs rather then by convention.
The users of Method* needs to do two thing:
1) Make sure that the Klass is kept alive by exposing either the mirror or the class loader to the GC.
2) Make sure that the the JVM still knows that the Method is being used.
If (1) is missed, we might unload the Klass prematurely.
If (2) is missed, the method can be deallocated if it has been redefined.
We currently have two options to handle (2).
a) Make sure that Method::set_on_stack(true) is called during MetadataOnStackMark()
b) Use a methodHandle instead of a Method*.
We need to make sure that uses of Method* adhere to these requirements. Preferably, by some code constructs rather then by convention.
- relates to
-
JDK-8008511 JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
- Resolved
-
JDK-8022887 Assertion hit while using class and redefining it with RedefineClasses simultaneously
- Closed