Lombok-intellij-plugin: Lombok + Eclipse compiler problem

Created on 26 Oct 2020  Â·  6Comments  Â·  Source: mplushnikov/lombok-intellij-plugin

Short description

The combination of Lombok and the Eclipse compiler produces illegal class files (contains the "normal" byte code twice).

Also see my issue in the IntelliJ IDEA forum: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360009866900-Lombok-Eclipse-compiler-problem-java-lang-ClassFormatError-Extra-bytes-at-the-end-of-class-file-

Expected behavior

Usage of lombok and Eclipse compiler produces executable byte code

Version information

  • IDEA Version:
    IntelliJ IDEA 2020.2.3 (Ultimate Edition)
    Build #IU-202.7660.26, built on October 6, 2020
    Runtime version: 11.0.8+10-b944.34 amd64
    VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
    Windows 10 10.0
    GC: ParNew, ConcurrentMarkSweep
    Memory: 4029M
    Cores: 8
    Registry: debugger.watches.in.variables=false
    Non-Bundled Plugins: com.alayouni.ansiHighlight, EclipseCodeFormatter, Lombook Plugin, PIT mutation testing Idea plugin, com.dubreuia, com.oliverlockwood.plugins.jenkinsfile, com.intellij.plugins.watcher, com.renemaas.intellij.zipper, mobi.hsz.idea.nodesecurity, net.seesharpsoft.intellij.plugins.csv, org.exbin.deltahex.intellij, org.sonarlint.idea, intellij.prettierJS, Karma, org.jetbrains.plugins.vue, org.jetbrains.kotlin, org.mapstruct.intellij, org.intellij.scala, training, org.asciidoctor.intellij.asciidoc

  • JDK Version: jdk1.8.0_202-x86

  • OS Type & Version: Windows 10
  • Lombok Plugin Version: 0.32-2020.2
  • Lombok Dependency Version: lombok-1.18.16.jar

Steps to reproduce

_What steps do we need to take to reproduce this issue?_

See the sample project included...

  1. Create a project with a lombok annotated class and an application/test using the class
  2. Set Eclipse compiler in the settings dialog and add the lombok jar as VM option with javaagent (also see https://github.com/mplushnikov/lombok-intellij-plugin/issues/89)
  3. Compile the code
  4. Start the application/test

Sample project

Please provide a sample project that exhibits the problem.
You should also include .idea folder so we can inspect the settings.

lombok-test.zip

  • [x] Sample project provided
  • [x] I am able to reproduce this error on the sample project by following the steps described above

Additional information

see https://intellij-support.jetbrains.com/hc/en-us/community/posts/360009866900-Lombok-Eclipse-compiler-problem-java-lang-ClassFormatError-Extra-bytes-at-the-end-of-class-file-

Stacktrace

java.lang.ClassFormatError: Extra bytes at the end of class file de/lomboktest/Application
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" 
Process finished with exit code 1

Most helpful comment

Fixed in lombok (slightly different take on the fix, but the hard work was figuring out what was wrong – all credit goes to @Rawi01), will be in next release.

All 6 comments

Update:
I changed the version of lombok to lombok-1.18.12.jar and the problem went away. So maybe it's either a bug in the lombok jar or perhaps in the interaction between the plugin and lombok???

I added scripts to my example projects that directly compile the code via command line using eclipse compiler.
As can be seen using the scripts, the problem is not in lombok jar itself, since both variants (compiling with version 1.18.12 AND version 1.18.16) work!

Thus, I guess the problem really seems to come either from the IDEA lombok plugin or the integration of this plugin with IDEA.

lombok-test-with-scripts.zip

Hello @eilensm,
I think this can be some issue of fixing another problem for IntelliJ in lombok 1.18.16 https://github.com/rzwitserloot/lombok/issues/2592
Can you maybe verify it together with @Rawi01 ?

Hi, I finally managed to debug it and developed a small fix that solves the problem. This probem is unrelated to the InteliJ annotation processing change as lombok uses a javagent for eclipse/ecj.

@Rawi01 Thank you very much!

Fixed in lombok (slightly different take on the fix, but the hard work was figuring out what was wrong – all credit goes to @Rawi01), will be in next release.

Was this page helpful?
0 / 5 - 0 ratings