Lombok: [BUG] SneakyThrows doesn't work with JDK 15

Created on 17 Sep 2020  路  7Comments  路  Source: projectlombok/lombok

Describe the bug
When compiling with javac, I get the following warning:

error: Error during the transformation of 'foo.bar.SomeClass'; post-compiler 'lombok.bytecode.SneakyThrowsRemover' caused an exception: java.lang.IllegalArgumentException: Unsupported class file major version 59

To Reproduce

// Test.java
import lombok.SneakyThrows;
import java.io.IOException;

public class Test {

    @SneakyThrows
    public void testMethod() {
      throw new IOException();
    }

}

Run javac -cp lombok-1.18.12.jar Test.java observe output:

error: Error during the transformation of 'Test'; post-compiler 'lombok.bytecode.SneakyThrowsRemover' caused an exception: java.lang.IllegalArgumentException: Unsupported class file major version 59
    at org.objectweb.asm.ClassReader.<init>(ClassReader.java:195)
    at org.objectweb.asm.ClassReader.<init>(ClassReader.java:176)
    at org.objectweb.asm.ClassReader.<init>(ClassReader.java:162)
    at lombok.bytecode.AsmUtil.fixJSRInlining(AsmUtil.java:37)
    at lombok.bytecode.SneakyThrowsRemover.applyTransformations(SneakyThrowsRemover.java:46)
    at lombok.core.PostCompiler.applyTransformations(PostCompiler.java:43)
    at lombok.core.PostCompiler$1.close(PostCompiler.java:76)
    at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeClass(ClassWriter.java:1507)
    at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:757)
    at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1644)
    at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1612)
    at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973)
    at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:317)
    at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:176)
    at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:59)
    at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:45)

Expected behavior
Compilation succeeds

Version info:

  • Lombok 1.18.12 or Edge
  • openjdk version "15" 2020-09-15
    OpenJDK Runtime Environment AdoptOpenJDK (build 15+36)
    OpenJDK 64-Bit Server VM AdoptOpenJDK (build 15+36, mixed mode, sharing)

Additional context
This is a new version of the https://github.com/rzwitserloot/lombok/issues/2302 bug

Most helpful comment

Thank you everyone on the Lombok Team. This appears to be fixed in Lombok 1.18.14

All 7 comments

There already is a PR (https://github.com/rzwitserloot/lombok.patcher/pull/6) that might fix this issue.

I ended up by just not using SneakyThrows, and it works fine now.

I ended up by just not using SneakyThrows, and it works fine now.

It isn't possible to remove them all in huge project :)

I ended up by just not using SneakyThrows, and it works fine now.

It isn't possible to remove them all in huge project :)

yeah I can imagine, hope there will be a release soon fixing the issue.

@rzwitserloot Hi, could you give any est. about Java 15 support?

Thanks.

I tested using the latest edge build today (https://projectlombok.org/download-edge), and this issue is still present there.

Thank you everyone on the Lombok Team. This appears to be fixed in Lombok 1.18.14

Was this page helpful?
0 / 5 - 0 ratings