-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
8u112
-
x86
-
linux_ubuntu
FULL PRODUCT VERSION :
A DESCRIPTION OF THE PROBLEM :
When a class that is loaded by an anonymous class loader (e.g. a lambda expression's class) is retransformed, the retransformation process causes the class to loose its properties as an anonymous class. As a result, verifier errors or no class def found errors are triggered.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the below code example from a Java agent in order to get hold of an instance of the instrumentation interface.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The transformation should be a no-op, i.e. the transformation should not have an effect.
ACTUAL -
Errors are thrown.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
class Foo {
void notFoundAfterRetransform() throws Exception {
Instrumentation instrumentation = ... // run via an agent.
instrumentation.addTransformer((loader, className, classBeingRedefined, protectionDomain, classfileBuffer) -> null, true); // No-op
instrumentation.retransformClasses(fooHolder().getClass()); // instrumentation.isModifiableClass(type) == true
fooHolder().getClass();
}
void verifierErrorOnRetransform() throws Exception {
Instrumentation instrumentation = ByteBuddyAgent.install();
instrumentation.addTransformer((loader, className, classBeingRedefined, protectionDomain, classfileBuffer) -> null, true); // No-op
instrumentation.retransformClasses(barHolder().getClass()); // instrumentation.isModifiableClass(type) == true
}
Function<?, ?> fooHolder() {
return this::foo;
}
public Object foo(Object p) {
return null;
}
Function<?, ?> barHolder() {
return this::bar;
}
private Object bar(Object p) {
return null;
}
}
---------- END SOURCE ----------
A DESCRIPTION OF THE PROBLEM :
When a class that is loaded by an anonymous class loader (e.g. a lambda expression's class) is retransformed, the retransformation process causes the class to loose its properties as an anonymous class. As a result, verifier errors or no class def found errors are triggered.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the below code example from a Java agent in order to get hold of an instance of the instrumentation interface.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The transformation should be a no-op, i.e. the transformation should not have an effect.
ACTUAL -
Errors are thrown.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
class Foo {
void notFoundAfterRetransform() throws Exception {
Instrumentation instrumentation = ... // run via an agent.
instrumentation.addTransformer((loader, className, classBeingRedefined, protectionDomain, classfileBuffer) -> null, true); // No-op
instrumentation.retransformClasses(fooHolder().getClass()); // instrumentation.isModifiableClass(type) == true
fooHolder().getClass();
}
void verifierErrorOnRetransform() throws Exception {
Instrumentation instrumentation = ByteBuddyAgent.install();
instrumentation.addTransformer((loader, className, classBeingRedefined, protectionDomain, classfileBuffer) -> null, true); // No-op
instrumentation.retransformClasses(barHolder().getClass()); // instrumentation.isModifiableClass(type) == true
}
Function<?, ?> fooHolder() {
return this::foo;
}
public Object foo(Object p) {
return null;
}
Function<?, ?> barHolder() {
return this::bar;
}
private Object bar(Object p) {
return null;
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-8145964 NoClassDefFound error in transforming lambdas
-
- Resolved
-