-
Bug
-
Resolution: Won't Fix
-
P4
-
11
-
None
I found the issue when I tried to instrument jdk.internal.net.http.Http2Connection class, which's in java.net.http module.
If I construct a ClassWriter with parameter ClassWriter.COMPUTE_FRAMES and update the class code with it, the following exception is raised:
java.lang.RuntimeException: java.lang.ClassNotFoundException: jdk/internal/net/http/frame/ContinuationFrame
at java.base/jdk.internal.org.objectweb.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1788)
at java.base/jdk.internal.org.objectweb.asm.ClassWriter.getMergedType(ClassWriter.java:1758)
at java.base/jdk.internal.org.objectweb.asm.Frame.merge(Frame.java:1559)
at java.base/jdk.internal.org.objectweb.asm.Frame.merge(Frame.java:1458)
at java.base/jdk.internal.org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1526)
at java.base/jdk.internal.org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:864)
at java.base/jdk.internal.org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:756)
at java.base/jdk.internal.org.objectweb.asm.tree.ClassNode.accept(ClassNode.java:481)
It is because ClassWriter.java has the following code :
protected String getCommonSuperClass(final String type1, final String type2) {
Class<?> c, d;
ClassLoader classLoader = getClass().getClassLoader();
try {
c = Class.forName(type1.replace('/', '.'), false, classLoader);
d = Class.forName(type2.replace('/', '.'), false, classLoader);
....
(Similar code is also in SimpleVerifier.java)
ClassWriter is loaded by bootstrap loader, but java.net.http module is loaded by platform loader, when sometime ClassWriter need to access any other classes not loaded by bootstrap loader, it will fail.
The original objectweb.asm is 3rd library, so should be loaded by application class loader, when we integrated it into jdk library, we don't consider the impact of this difference.
We may provide a way to allow user sets his loader(e.g. thread context loader) for objectweb.asm, or guide user to update the frame size manully and use new ClassWriter(0).
If I construct a ClassWriter with parameter ClassWriter.COMPUTE_FRAMES and update the class code with it, the following exception is raised:
java.lang.RuntimeException: java.lang.ClassNotFoundException: jdk/internal/net/http/frame/ContinuationFrame
at java.base/jdk.internal.org.objectweb.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1788)
at java.base/jdk.internal.org.objectweb.asm.ClassWriter.getMergedType(ClassWriter.java:1758)
at java.base/jdk.internal.org.objectweb.asm.Frame.merge(Frame.java:1559)
at java.base/jdk.internal.org.objectweb.asm.Frame.merge(Frame.java:1458)
at java.base/jdk.internal.org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1526)
at java.base/jdk.internal.org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:864)
at java.base/jdk.internal.org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:756)
at java.base/jdk.internal.org.objectweb.asm.tree.ClassNode.accept(ClassNode.java:481)
It is because ClassWriter.java has the following code :
protected String getCommonSuperClass(final String type1, final String type2) {
Class<?> c, d;
ClassLoader classLoader = getClass().getClassLoader();
try {
c = Class.forName(type1.replace('/', '.'), false, classLoader);
d = Class.forName(type2.replace('/', '.'), false, classLoader);
....
(Similar code is also in SimpleVerifier.java)
ClassWriter is loaded by bootstrap loader, but java.net.http module is loaded by platform loader, when sometime ClassWriter need to access any other classes not loaded by bootstrap loader, it will fail.
The original objectweb.asm is 3rd library, so should be loaded by application class loader, when we integrated it into jdk library, we don't consider the impact of this difference.
We may provide a way to allow user sets his loader(e.g. thread context loader) for objectweb.asm, or guide user to update the frame size manully and use new ClassWriter(0).