jasm icon indicating copy to clipboard operation
jasm copied to clipboard

Instruction "new" doesn't work for classes with empty package

Open kmatveev opened this issue 10 months ago • 1 comments

Here is a minimal self-contained example. If we have a following class:

public class Test {
  public static void main(String[] args) {
    Test test = new Test();
  }
}

After a compilation and disassembly there will be a following JASM code:

public class Test {
    public <init>()V {
        label0:
        aload 0
        invokespecial java/lang/Object.<init>()V
        return
    }

    public static main([java/lang/String)V {
        label0:
        new Test
        dup
        invokespecial Test.<init>()V
        astore 1
        
        label1:
        return
    }

}

An attempt to assembly this code will fail with

Test.jasm : Cannot invoke "org.antlr.v4.runtime.tree.TerminalNode.getText()" because the return value of "com.roscopeco.jasm.antlr.JasmParser$Insn_newContext.QNAME()" is null

kmatveev avatar Feb 23 '25 07:02 kmatveev

I've created a pull request to fix this bug

kmatveev avatar Feb 23 '25 07:02 kmatveev