Search code examples
javajava-bytecode-asmjasmin

Jasmin NoSuchMethodError when converting to binary Java class


I am trying to use Jasmin to convert Jasmin assembly code to a Java class file. Using the Hello World example from here.

The following error is returned:

Exception in thread "main" java.lang.NoSuchMethodError: jasmin.parser.parse()V
    at jasmin.ClassFile.readJasmin(ClassFile.java:1160)
    at jasmin.Main.assemble(Main.java:81)
    at jasmin.Main.run(Main.java:200)
    at jasmin.Main.main(Main.java:157)

I suspect that it may be a problem with the Java version since Jasmin seems to be old and probably implemented using an older Java version.

So far I have tried to run the example using this command: java -jar jasmin.jar test.j.

I have tried to run it with Java 8, 7, 6 and 4 unsuccessfully.

The version of Jasmin I have used is 2.4.

Furthermore I have also tried to download Jasmin's source code and compile it manually, with the same result.

Does anybody have any pointers or ideas on how to solve this issue?


Solution

  • The issue is that, if you have other versions of cup in Java's classpath, jasmin might run intro troubles and it will throw a NoSuchMethodError.

    To fix this, just remove the other CUP versions from Java's classpath.

    All credit goes to @MargaretBloom for finding the issue.