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

Created on 2 Dec 2019  路  9Comments  路  Source: projectlombok/lombok

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

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

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.10.jar Test.java, observe output: warning: Error during the transformation of 'Test'; post-compiler 'lombok.bytecode.SneakyThrowsRemover' caused an exception: java.lang.IllegalArgumentException: Unsupported class file major version 57

Expected behavior
Compilation succeeds.

Version info (please complete the following information):

  • 1.18.10
  • javac 13.0.1

Most helpful comment

Well, that JDK14 stuff wasn't difficult. Got that sorted. Thursday's looking good.

All 9 comments

As far as I can see, it is "just" a warning, but gets compiled.

@mpetersen By definition that is correct, but not helpful. The compiled classes do not have the expected transformation applied, so are not usable. In fact in our case we do not have lombok as a runtime dependency, so our code does not run.

decompiled class emitted by java 12:

import java.io.IOException;

public class Test {
  public Test() {
  }

  public void testMethod() {
    try {
      throw new IOException();
    } catch (Throwable var2) {
      throw var2;
    }
  }
}

decompiled class emitted by java 13:

import java.io.IOException;
import lombok.Lombok;

public class Test {
  public Test() {
  }

  public void testMethod() {
    try {
      throw new IOException();
    } catch (Throwable var2) {
      throw Lombok.sneakyThrow(var2);
    }
  }
}

Thanks for clarification.

You can temporary have lombok on the rintime classpath as a fix, the code is luckily robust enough for that.

We'll fix it.

I can reproduce the problem in 1.18.10. However, building lombok on the current code base does not contain this problem.

According to the release notes, it is fixed in the next release. You should already be able to test this using the edge release.

Is there any estimation when the next release will be published? Having an edge/snapshot dependency in my projects feels bad ;-)

We're aware there is some time pressure. I had one major blocker (weirdness with the @With rename, but that's tackled), I just finished a feature that I did not want to miss the boat. There's one more crucial thing I want done before then: Check JDK14 compat.

I'm going to try for this thursday evening european time.

Well, that JDK14 stuff wasn't difficult. Got that sorted. Thursday's looking good.

Was this page helpful?
0 / 5 - 0 ratings