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

lombok causes an IllegalArgumentException in ReferenceEquality #447

Closed
Ferada opened this issue Aug 16, 2016 · 8 comments
Closed

lombok causes an IllegalArgumentException in ReferenceEquality #447

Ferada opened this issue Aug 16, 2016 · 8 comments
Labels

Comments

@Ferada
Copy link

Ferada commented Aug 16, 2016

I tracked down this crash to a single Wither annotation from Lombok. Haven't checked the GitHub master branch nor any other versions though.

Minimal example is at https://github.com/Ferada/errorprone-test with mvn clean install.

Stacktrace:

/home/olof/workspace/errorprone-test/src/main/java/com/example/Setting.java:10: error: An unhandled exception was thrown by the Error Prone static analysis plugin.
    String key;
           ^
     Please report this at https://github.com/google/error-prone/issues/new and include the following:

     error-prone version: 2.0.11
     Stack Trace:
     java.lang.IllegalArgumentException: Invalid range: [163‥-1)
        at com.google.common.collect.Range.<init>(Range.java:352)
        at com.google.common.collect.Range.create(Range.java:146)
        at com.google.common.collect.Range.closedOpen(Range.java:182)
        at com.google.errorprone.fixes.Replacement.create(Replacement.java:38)
        at com.google.errorprone.fixes.SuggestedFix$ReplacementFix.getReplacement(SuggestedFix.java:365)
        at com.google.errorprone.fixes.SuggestedFix.getReplacements(SuggestedFix.java:94)
        at com.google.errorprone.fixes.AppliedFix$Applier.apply(AppliedFix.java:67)
        at com.google.errorprone.JavacErrorDescriptionListener$1.apply(JavacErrorDescriptionListener.java:51)
...
@cushon
Copy link
Collaborator

cushon commented Dec 17, 2017

The crash indicates that the suggest fix logic is seeing an AST node without an end position.

@cushon cushon changed the title Unhandled exception / Wither annotation. lombok causes an IllegalArgumentException in SuggestedFix.getReplacements Dec 17, 2017
@Raniz85
Copy link

Raniz85 commented Mar 28, 2018

I'm getting this with Lombok 1.16.20 and Error Prone 2.2.0

@mkadan
Copy link

mkadan commented Aug 9, 2018

Still doesn't work with @Wither.

ErrorProne 2.3.1
Lombok 1.16.20

    @Value
    public static class Payment {

        Long id;
        // for tests
        @Wither
        String name;
    }

leads to:

error: An unhandled exception was thrown by the Error Prone static analysis plugin.
        @Wither
        ^
     Please report this at https://github.com/google/error-prone/issues/new and include the following:
     error-prone version: 2.3.1
     BugPattern: ReferenceEquality
     Stack Trace:
     java.lang.IllegalArgumentException: invalid replacement: [5882, -1) (Objects.equals(null, null))
  	at com.google.common.base.Preconditions.checkArgument(Preconditions.java:458)
  	at com.google.errorprone.fixes.Replacement.create(Replacement.java:37)
  	at com.google.errorprone.fixes.SuggestedFix$ReplacementFix.getReplacement(SuggestedFix.java:372)
  	at com.google.errorprone.fixes.SuggestedFix.getReplacements(SuggestedFix.java:84)
  	at com.google.errorprone.fixes.AppliedFix$Applier.apply(AppliedFix.java:66)
  	at com.google.errorprone.JavacErrorDescriptionListener.lambda$new$0(JavacErrorDescriptionListener.java:62)
  	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
  	at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
  	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
  	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
  	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
  	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
  	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
  	at com.google.errorprone.JavacErrorDescriptionListener.onDescribed(JavacErrorDescriptionListener.java:76)
  	at com.google.errorprone.VisitorState.reportMatch(VisitorState.java:160)
  	at com.google.errorprone.scanner.Scanner.reportMatch(Scanner.java:153)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitBinary(ErrorProneScanner.java:506)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitBinary(ErrorProneScanner.java:145)
  	at com.sun.tools.javac.tree.JCTree$JCBinary.accept(JCTree.java:1993)
  	at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:82)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:42)
  	at com.sun.source.util.TreeScanner.visitConditionalExpression(TreeScanner.java:403)
...

@yasserg
Copy link

yasserg commented Feb 25, 2019

Still getting this with Lombok 1.18.6 and Error Prone 2.3.3

@msridhar
Copy link
Contributor

Maybe a fix similar to #1135 inside this code will do the trick here

@yasserg
Copy link

yasserg commented Feb 25, 2019

It seems like a fix has been proposed here: #1195

@cushon
Copy link
Collaborator

cushon commented Jan 19, 2021

package t;

import lombok.Value;
import lombok.With;

@Value
public class I447 {

  Long x;
  @With String y;
}
  @With String y;
  ^
     error-prone version: 2.5.1
     BugPattern: ReferenceEquality
     Stack Trace:
     java.lang.IllegalArgumentException: invalid replacement: [94, -1) (Objects.equals(null, null))
  	at com.google.common.base.Preconditions.checkArgument(Preconditions.java:459)
  	at com.google.errorprone.fixes.Replacement.create(Replacement.java:37)

@cushon cushon changed the title lombok causes an IllegalArgumentException in SuggestedFix.getReplacements lombok causes an IllegalArgumentException in ReferenceEquality Jan 19, 2021
@cushon
Copy link
Collaborator

cushon commented Apr 14, 2022

Please re-open this or file a new bug if you're still seeing issues with Lombok and Error Prone 2.13.0 when -XepDisableWarningsInGeneratedCode is enabled.

@cushon cushon closed this as completed Apr 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants