Open rpau opened 8 years ago
I don't think it's related to that bug. I suspect a classloader issue that those classes are loaded by different class loaders and especially that the super class of AccessibleJFrame is loaded by a different class loader than javax/accessibility/AccessibleContext class used here.
Here some class loaders involved. Note sure how to interpret that.
} catch (VerifyError e) {
System.out.println("clazz " + clazz.getName() + " class loader: " + clazz.getClassLoader());
final Class<?> superclass = clazz.getSuperclass();
if (superclass != null) {
System.out.println("superclazz " + superclass.getName() + " class loader: " + superclass.getClassLoader());
}
System.out.println("AccessibleContext class loader: " + AccessibleContext.class.getClassLoader());
throw e;
}
clazz javax.swing.JOptionPane class loader: org.walkmod.rawclasspath.providers.RawClasspathProvider$1@20ccf40b
superclazz javax.swing.JComponent class loader: org.walkmod.rawclasspath.providers.RawClasspathProvider$1@20ccf40b
AccessibleContext class loader: null
package de.walkmod.classloader;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
public class VerifyError {
public void m() throws Exception {
BufferedImage image = ImageIO.read(new ByteArrayInputStream("no-image".getBytes()));
JOptionPane.showMessageDialog(null,null,"title",JOptionPane.ERROR_MESSAGE,new ImageIcon(image));
}
}
results:
Error processing the analysis of [.../src/main/java/de/walkmod/classloader/VerifyError.java] - [-1:-1]
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
at java.lang.Class.getDeclaredField(Class.java:2068)
at org.walkmod.javalang.compiler.reflection.FieldInspector.findFieldType(FieldInspector.java:72)
at org.walkmod.javalang.compiler.types.TypeVisitorAdapter.visit(TypeVisitorAdapter.java:347)
at org.walkmod.javalang.compiler.types.TypeVisitorAdapter.visit(TypeVisitorAdapter.java:115)
at org.walkmod.javalang.ast.expr.FieldAccessExpr.accept(FieldAccessExpr.java:114)
at org.walkmod.javalang.compiler.types.TypeVisitorAdapter.visit(TypeVisitorAdapter.java:402)
at org.walkmod.javalang.compiler.types.TypeVisitorAdapter.visit(TypeVisitorAdapter.java:115)
at org.walkmod.javalang.ast.expr.MethodCallExpr.accept(MethodCallExpr.java:138)
at org.walkmod.javalang.compiler.symbols.SymbolVisitorAdapter.visit(SymbolVisitorAdapter.java:723)
at org.walkmod.javalang.compiler.symbols.SymbolVisitorAdapter.visit(SymbolVisitorAdapter.java:92)
at org.walkmod.javalang.ast.stmt.ExpressionStmt.accept(ExpressionStmt.java:79)
at org.walkmod.javalang.visitors.VoidVisitorAdapter.visit(VoidVisitorAdapter.java:203)
at org.walkmod.javalang.compiler.symbols.SymbolVisitorAdapter.visit(SymbolVisitorAdapter.java:522)
at org.walkmod.javalang.compiler.symbols.SymbolVisitorAdapter.visit(SymbolVisitorAdapter.java:92)
at org.walkmod.javalang.ast.stmt.BlockStmt.accept(BlockStmt.java:89)
at org.walkmod.javalang.visitors.VoidVisitorAdapter.visit(VoidVisitorAdapter.java:564)
at org.walkmod.javalang.compiler.symbols.SymbolVisitorAdapter.visit(SymbolVisitorAdapter.java:550)
at org.walkmod.javalang.compiler.symbols.SymbolVisitorAdapter.visit(SymbolVisitorAdapter.java:92)
at org.walkmod.javalang.ast.body.MethodDeclaration.accept(MethodDeclaration.java:207)
at org.walkmod.javalang.compiler.symbols.SymbolVisitorAdapter.visit(SymbolVisitorAdapter.java:445)
at org.walkmod.javalang.compiler.symbols.SymbolVisitorAdapter.visit(SymbolVisitorAdapter.java:92)
at org.walkmod.javalang.ast.body.ClassOrInterfaceDeclaration.accept(ClassOrInterfaceDeclaration.java:136)
at org.walkmod.javalang.compiler.symbols.SymbolVisitorAdapter.visit(SymbolVisitorAdapter.java:174)
at org.walkmod.javalang.walkers.DefaultJavaWalker.visit(DefaultJavaWalker.java:198)
at org.walkmod.javalang.walkers.DefaultJavaWalker.accept(DefaultJavaWalker.java:86)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.walkmod.walkers.AbstractWalker.walk(AbstractWalker.java:261)
at org.walkmod.walkers.AbstractWalker.execute(AbstractWalker.java:276)
at org.walkmod.javalang.walkers.DefaultJavaWalker.execute(DefaultJavaWalker.java:160)
at org.walkmod.impl.DefaultChainWalkerInvocation.invoke(DefaultChainWalkerInvocation.java:41)
at org.walkmod.impl.DefaultChainInvocation.invoke(DefaultChainInvocation.java:38)
at org.walkmod.impl.DefaultChainAdapter.execute(DefaultChainAdapter.java:165)
at org.walkmod.WalkModFacade.executeAllChains(WalkModFacade.java:911)
at org.walkmod.WalkModFacade.apply(WalkModFacade.java:376)
at org.walkmod.commands.ApplyCommand.execute(ApplyCommand.java:40)
at org.walkmod.WalkModDispatcher.execute(WalkModDispatcher.java:171)
at org.walkmod.WalkModDispatcher.main(WalkModDispatcher.java:196)
Caused by: java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
javax/swing/JOptionPane.getAccessibleContext()Ljavax/accessibility/AccessibleContext; @16: putfield
Reason:
Type 'javax/swing/JOptionPane$AccessibleJOptionPane' (current frame, stack[1]) is not assignable to 'javax/accessibility/AccessibleContext'
Current Frame:
bci: @16
flags: { }
locals: { 'javax/swing/JOptionPane' }
stack: { 'javax/swing/JOptionPane', 'javax/swing/JOptionPane$AccessibleJOptionPane' }
Bytecode:
0x0000000: 2ab4 00ef c700 0f2a bb00 f059 2ab7 00f1
0x0000010: b500 ef2a b400 efb0
Stackmap Table:
same_frame(@19)
... 42 more
Great :+1:
Most people won't call it "Great" having to deal with class loader issues. ;-)
I am an exception in many things :P
I am getting a similar error when trying to run walkmod on one of my projects (throws VerifyError; Type 'javax/swing/JDialog$AccessibleJDialog' is not assignable to 'javax/accessibility/AccessibleContext'). Can you offer some clues on working around this?
ERROR [main] - TRANSFORMATION CHAIN (default) FAILS An exeception has been produced during the null transformation - org.walkmod.util.location.LocationImpl@1d5f07df at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.walkmod.walkers.AbstractWalker.walk(AbstractWalker.java:250) at org.walkmod.walkers.AbstractWalker.execute(AbstractWalker.java:265) at org.walkmod.javalang.walkers.DefaultJavaWalker.execute(DefaultJavaWalker.java:158) at org.walkmod.impl.DefaultChainWalkerInvocation.invoke(DefaultChainWalkerInvocation.java:41) at org.walkmod.impl.DefaultChainInvocation.invoke(DefaultChainInvocation.java:38) at org.walkmod.impl.DefaultChainAdapter.execute(DefaultChainAdapter.java:165) at org.walkmod.WalkModFacade.executeAllChains(WalkModFacade.java:911) at org.walkmod.WalkModFacade.apply(WalkModFacade.java:376) at org.walkmod.commands.ApplyCommand.execute(ApplyCommand.java:40) at org.walkmod.WalkModDispatcher.execute(WalkModDispatcher.java:171) at org.walkmod.WalkModDispatcher.main(WalkModDispatcher.java:196) Caused by: java.lang.reflect.InvocationTargetException ... 14 more Caused by: java.lang.VerifyError: Bad type on operand stack Exception Details: Location: javax/swing/JFrame.getAccessibleContext()Ljavax/accessibility/AccessibleContext; @16: putfield Reason: Type 'javax/swing/JFrame$AccessibleJFrame' (current frame, stack[1]) is not assignable to 'javax/accessibility/AccessibleContext' Current Frame: bci: @16 flags: { } locals: { 'javax/swing/JFrame' } stack: { 'javax/swing/JFrame', 'javax/swing/JFrame$AccessibleJFrame' } Bytecode: 0x0000000: 2ab4 0005 c700 0f2a bb00 6659 2ab7 0067 0x0000010: b500 052a b400 05b0
Stackmap Table: same_frame(@19)