Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Runtime dependency with Lombok APIs when using @SneakyThrows in combination with ECJ + Takari Lifecycle Plugin #3775

Open
pjmartos opened this issue Nov 6, 2024 · 0 comments

Comments

@pjmartos
Copy link

pjmartos commented Nov 6, 2024

Describe the bug
Lombok code leaks when using Takari Lifecycle + jdt compilerId (via ECJ) + @SneakyThrows, thus forcing the lombok artifact to be available at runtime.
Any other combinations lead to the correct code being generated:

  • Maven Compiler Plugin + javac compilerId
  • Maven Compiler Plugin + eclipse compilerId (via Plexus Compiler Eclipse)
  • Takari Lifecycle + javac compilerId

To Reproduce

  1. Clone https://github.com/pjmartos/lombok-takari-ecj-issue.git
  2. Run mvn compile from the project's root folder
  3. After decompiling the compiled class com.pmartos.App, we can see that the generated code has a runtime dependency with Lombok APIs:
        try {
            // code throwing an exception
        } catch (Throwable var2) {
            throw Lombok.sneakyThrow(var2);
        }
  1. Run java -cp target/classes com.pmartos.App from the project's root folder (the POM is configured to use Java 21 but it should be possible to use Java 11+ if needed)
  2. A ClassDefNotFoundError is returned; there shouldn't be such errors at runtime, but due to point 3 the error happens nonetheless.

In more elaborate applications for which an uber JAR or similar archive is built, the error will likely surface as soon as lombok has scope provided in the project's POM.

Expected behavior

  1. The code does not fail and instead prints a message Successfully thrown and caught! Exception message: This is a test.
  2. The generated code for class com.pmartos.App no longer has a runtime-dependency with Lombok APIs:
        try {
            // code throwing an exception
        } catch (Throwable var2) {
            throw var2;
        }

Version info

  • Lombok 1.18.20 to 1.18.34
  • Javac 21.0.3 (Oracle JDK)
  • Javac 17.0.10 (Oracle JDK)
  • Takari Lifecycle Plugin 2.1.5 to 2.2.0
  • Eclipse ECJ 3.33.0 to 3.39.0 (Takari Lifecycle breaks with 3.39.0)

Additional context
None

@pjmartos pjmartos changed the title [BUG] Lombok @SneakyThrows [BUG] Runtime dependency with Lombok APIs when using @SneakyThrows in combination with ECJ + Takari Lifecycle Plugin Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant