| Summary: | [save actions][clean up] save actions fail when @JsonProperty(access = Access.READ_ONLY) is present | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Giacomo Baso <giacomo.baso> | ||||
| Component: | Core | Assignee: | Fabrice Tiercelin <fabrice.tiercelin> | ||||
| Status: | CLOSED WORKSFORME | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | carsten.hammer, fabrice.tiercelin, jjohnstn, Lars.Vogel | ||||
| Version: | 4.17 | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Linux | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Giacomo Baso
Please attach full error log. Created attachment 284724 [details]
eclipse log
Fabrice, could you please take a look? Stack: java.lang.IllegalArgumentException: startPos = 2118 and length is -1607. This breaks the rule that lengths are not allowed to be negative. Affected Node: class org.eclipse.jdt.core.dom.MemberValuePair: access=Access.READ_ONLY at lombok.eclipse.agent.PatchDiagnostics.setSourceRangeCheck(PatchDiagnostics.java:36) at org.eclipse.jdt.core.dom.ASTNode.setSourceRange(ASTNode.java) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2538) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2587) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1097) at org.eclipse.jdt.core.dom.ASTConverter.setModifiers(ASTConverter.java:5591) at org.eclipse.jdt.core.dom.ASTConverter.setModifiers(ASTConverter.java:5541) at org.eclipse.jdt.core.dom.ASTConverter.setModifiers(ASTConverter.java:5650) at org.eclipse.jdt.core.dom.ASTConverter.convertToFieldDeclaration(ASTConverter.java:3619) at org.eclipse.jdt.core.dom.ASTConverter.checkAndAddMultipleFieldDeclaration(ASTConverter.java:541) at org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations(ASTConverter.java:201) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:3302) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1513) at org.eclipse.jdt.core.dom.CompilationUnitResolver.convert(CompilationUnitResolver.java:323) at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1231) at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:820) at org.eclipse.jdt.core.manipulation.CoreASTProvider$1.run(CoreASTProvider.java:272) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) at org.eclipse.jdt.core.manipulation.CoreASTProvider.createAST(CoreASTProvider.java:264) at org.eclipse.jdt.core.manipulation.CoreASTProvider.getAST(CoreASTProvider.java:197) at org.eclipse.jdt.core.manipulation.SharedASTProviderCore.getAST(SharedASTProviderCore.java:138) at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:167) at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup$1.run(SelectionListenerWithASTManager.java:152) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63) Can you reproduce the bug? If yes, can you reproduce it with the minimum checked options in Save Actions settings (Window -> Preference -> Java -> Editor -> Save Actions -> Configure...) ? Are you using Eclipse 2020-09 or a recent build? If yes, which build? I'm using Eclipse 2020-09 JEE. Bug is reproducible with a clean workspace and only "organize imports" checked, on a new Spring Boot 2.3.4 project with just a single class:
```
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty.Access;
import lombok.Data;
@Data
public class MyDto {
private Long id;
@JsonProperty(access = Access.READ_ONLY)
private String test;
}
```
From the log it looks like a weird interaction with the lombok agent? I tried updating the lombok agent to version 1.18.16 (latest, from boot managed version 1.18.12) and the problem was not present. Still, the error message is not helpful and there could be something else going on.
I already faced issues on save actions using Lombok. Unfortunately, I have never found a solution :( Those issues seem hard to solve because the bytecode and the source do not match. The only feature I can implement would be to disable save actions on a class in which Lombok is used. Others? Do I do that? As a heavy user of both lombok and save actions, I can say that for me it would be highly undesirable, I'd rather live with some breakage every now and then. Can I suggest a checkbox in the save action menu, toggable when lombok agent is detected, to enable/disable what you proposed? Beware, Save Actions on Lombok can also break your code without throwing errors. Bug seems to be fixed in Eclipse 2021-03 |