Details
-
Enhancement
-
Resolution: Incomplete
-
P4
-
None
-
None
-
None
Description
retransformClasses() throws java.lang.InternalError while re-transforming a class if it could not re-transform it for some reason. For instance, if it couldn't link the class while retransforming:
---------
java.lang.InternalError
at sun.instrument.InstrumentationImpl.retransformClasses0(Native Method)
at sun.instrument.InstrumentationImpl.retransformClasses(InstrumentationImpl.java:144) at Main.main(Main.java:36)
--------------
It would be useful to have an API to check if a class can be retransformed successfully before actually making a call to do it. A few suggestions from a user of these APIs:
* java.lang.instrument.Instrumentation.isModifiableClass(badClass) returns
false
* java.lang.Class.isNotLoaded() returns true (for badClass)
* java.lang.Class.isNotVerified() returns true (for badClass)
* <or-anything-else>
These new and enhanced APIs can be used when deciding on which classes to retransform. Example:
% cat -n moreRealTest/agent-src/Agent.java
...
20 for (Class c : inst.getAllLoadedClasses()) {
21 if (c == null ||
22 !inst.isModifiableClass(c) ||
23 skip(c.getName()))
24 continue;
25 classList.add(c);
---------
java.lang.InternalError
at sun.instrument.InstrumentationImpl.retransformClasses0(Native Method)
at sun.instrument.InstrumentationImpl.retransformClasses(InstrumentationImpl.java:144) at Main.main(Main.java:36)
--------------
It would be useful to have an API to check if a class can be retransformed successfully before actually making a call to do it. A few suggestions from a user of these APIs:
* java.lang.instrument.Instrumentation.isModifiableClass(badClass) returns
false
* java.lang.Class.isNotLoaded() returns true (for badClass)
* java.lang.Class.isNotVerified() returns true (for badClass)
* <or-anything-else>
These new and enhanced APIs can be used when deciding on which classes to retransform. Example:
% cat -n moreRealTest/agent-src/Agent.java
...
20 for (Class c : inst.getAllLoadedClasses()) {
21 if (c == null ||
22 !inst.isModifiableClass(c) ||
23 skip(c.getName()))
24 continue;
25 classList.add(c);