Skip to content

Error when decompiling code with reflection call. #14

@faustocarva

Description

@faustocarva

Hi, the decompile method in Decompiler class is generating an error when processing classes with java reflection mechanism.
Below is the code to reproduce the error:

public class Reflection {
	
  public static void staticInvokeReflection() throws NoSuchMethodException {
    // Invoking static method using reflection
    Method method = A.class.getMethod("staticFoo");
    try {
      method.invoke(null);
    } catch (IllegalAccessException e) {
      e.printStackTrace();
    } catch (InvocationTargetException e) {
      e.printStackTrace();
    }
  }
}

The A.java file:

public class A {
	public static void staticFoo() {
		System.out.println("foo");
	}
}

Error message:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running lang.jimple.internal.TestDecompiler
java.lang.ClassCastException: lang.jimple.internal.generated.Immediate$c_iValue cannot be cast to lang.jimple.internal.generated.Immediate$c_local
	at lang.jimple.internal.Decompiler$InstructionSetVisitor.invokeMethodIns(Decompiler.java:698)
	at lang.jimple.internal.Decompiler$InstructionSetVisitor.visitMethodInsn(Decompiler.java:555)
	at org.objectweb.asm.tree.MethodInsnNode.accept(Unknown Source)
	at org.objectweb.asm.tree.InsnList.accept(Unknown Source)
	at lang.jimple.internal.Decompiler$GenerateJimpleClassVisitor.visitMethod(Decompiler.java:210)
	at lang.jimple.internal.Decompiler$GenerateJimpleClassVisitor.visitEnd(Decompiler.java:162)
	at org.objectweb.asm.ClassReader.accept(Unknown Source)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions