lombok-intellij-plugin: Support for Records in Java - false compilation error reported
Short description
Incorrect compilation issue reported by the plugin while using the records.
Since the latest version of IntelliJ, the IDE has started supporting Records in Java introduced as a preview feature in Java-14.
Expected behavior
There should be no compile error reported by the plugin based on the .class generated.
Version information
IDEA Version: IntelliJ IDEA 2020.1 EAP (Community Edition) Build #IC-201.6487.11, built on March 18, 2020 Runtime version: 11.0.6+8-b765.15 x86_64 macOS 10.14.6
Plugin Version: 0.29-EAP
Steps to reproduce
- Create a
recordtype as follows
@lombok.AllArgsConstructor public record Java(String version) { }
- Create an instance of this class using the appropriate constructor and observe the behavior.
System.out.println(new Java("14").version());
- The plugin highlights the “Cannot resolve constructor” message, on the other hand, the code compiles and executes correctly on the IDE.
Sample project
I have reported a reproducible issue on Stackoverflow with the observation and behavior with and without the plugin installed in the IDE.
- I am able to reproduce this error on the sample project by following the steps described above
Additional information
In general, seems like Lombok in itself needs to support Records as well - https://github.com/rzwitserloot/lombok/issues/2356
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 7
- Comments: 18 (2 by maintainers)
Same issue here. We’re using
@Builderon records, but IntelliJ doesn’t recognise them properly.This doesn’t work:
This does:
Both scenarios work when compiling from the command-line with Maven.
So, it’s pretty easy to work around, but we’re using Lombok to get rid of boilerplate, not introduce more of it 😉
@Buildersupport would be very helpful 😃 https://youtrack.jetbrains.com/issue/IDEA-266513Hi, it seems that Lombok supports Java 16 records https://github.com/projectlombok/lombok/issues/2356, any update?
Unable to reproduce this issue, this issue should be closed and marked as fixed.
I’m not sure how useful the
@AllArgsConstructorannotation is on a record - in my case it’s the@Builderi’d like 😃Same thing here… this is the only thing stopping me to update my projects to Java 17 LTS.
Workaround does not seem to work when
@Builderis used together with@With.Here
@Withworks, but not@Builder:Here
@Builderworks, but not@With:@mplushnikov Any update on this? This is currently the only block for us to adopt using Records in our projects. Lombok support for Records was added in v1.18.20, so it should be possible to implement 😄 Thanks!
@hajdamak Brilliant! Thank you, the builder finally works. I wasn’t even aware that
@Withexists.Then I’d suggest using @With