unimined / JvmDowngrader

Downgrades modern java bytecode to older versions. at either compile or runtime.
https://jvmdowngrader.wagyourtail.xyz
Other
48 stars 5 forks source link

`Bad type on operand stack` when converting through the CLI #10

Closed Ledmington closed 1 month ago

Ledmington commented 1 month ago

Steps to reproduce:

git clone https://github.com/Ledmington/emu.git
cd emu
./gradlew readelf:fatjar
cp readelf/build/libs/emu-readelf.jar .
wget https://github.com/unimined/JvmDowngrader/releases/download/0.8.3/jvmdowngrader-0.8.3-all.jar
java21 -jar jvmdowngrader-0.8.3-all.jar -c 52 downgrade -t emu-readelf.jar output.jar
java8 -jar output.jar

The output is this:

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    com/ledmington/readelf/Main.<clinit>()V @49: invokespecial
  Reason:
    Type 'java/io/BufferedWriter' (current frame, stack[3]) is not assignable to integer
  Current Frame:
    bci: @49
    flags: { }
    locals: { }
    stack: { uninitialized 15, uninitialized 15, integer, 'java/io/BufferedWriter' }
  Bytecode:
    0x0000000: b806 02c6 000c b806 02b6 0608 a700 28bb
    0x0000010: 00b2 59b2 060b 03b2 0611 5d5f 57bb 0613
    0x0000020: 5b5b 57b7 0616 5f57 bb06 185b 5fb7 061b
    0x0000030: 5fb7 061e b300 b003 b300 f5b1
  Stackmap Table:
    same_frame(@15)
    same_locals_1_stack_item_frame(@52,Object[#178])

        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
        at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
        at java.lang.Class.getMethod0(Class.java:3018)
        at java.lang.Class.getMethod(Class.java:1784)
        at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:670)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:652)

Not sure if it may help, but it gives the same error when trying to run it with java 21.

Unfortunately I wasn't able to create a minimal non-working example but, judging from the error, it seems that the problem may be realated to this.