Repository navigation
Closed
Labels
Description
Description of the problem / feature request:
Unused variable & parameter name checks cause error prone to crash with
java.lang.IndexOutOfBoundsException
Failed in custom JPA config, also failed in SLF4J.
What version of Error Prone are you using?
2.4.0
Please report this at https://github.com/google/error-prone/issues/new and include the following:
error-prone version: 2.4.0
BugPattern: UnusedVariable
Stack Trace:
java.lang.IndexOutOfBoundsException
at java.nio.HeapCharBuffer.subSequence(HeapCharBuffer.java:580)
at java.nio.HeapCharBuffer.subSequence(HeapCharBuffer.java:42)
at com.google.errorprone.VisitorState.getOffsetTokens(VisitorState.java:589)
at com.google.errorprone.fixes.SuggestedFixes.replaceIncludingComments(SuggestedFixes.java:1445)
at com.google.errorprone.bugpatterns.UnusedVariable.buildUnusedVarFixes(UnusedVariable.java:381)
at com.google.errorprone.bugpatterns.UnusedVariable.matchCompilationUnit(UnusedVariable.java:233)
at com.google.errorprone.scanner.ErrorProneScanner.processMatchers(ErrorProneScanner.java:451)
at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:557)
at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:152)
at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:591)
at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:56)
at com.google.errorprone.scanner.Scanner.scan(Scanner.java:58)
at com.google.errorprone.scanner.ErrorProneScannerTransformer.apply(ErrorProneScannerTransformer.java:43)
at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:152)
at com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:120)
at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1404)
at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1353)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:946)
at com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:100)
at com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:142)
at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:96)
at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:90)
at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:50)
at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:36)
at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerCallable.call(AbstractDaemonCompiler.java:88)
at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerCallable.call(AbstractDaemonCompiler.java:76)
at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:42)
at org.gradle.workers.internal.WorkerDaemonServer.execute(WorkerDaemonServer.java:46)
at org.gradle.workers.internal.WorkerDaemonServer.execute(WorkerDaemonServer.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.process.internal.worker.request.WorkerAction.run(WorkerAction.java:101)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:155)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:137)
at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:748)
Reacted by Hakanai, Răzvan Petruescu and Saucistophe
Reacted by Christoph Linder, typingtanuki, Larry Crochet and Răzvan Petruescu
Activity
crolarlibertyva commentedon Jul 22, 2020
I got the same. The issue occurred on an abstract class that uses lombok annotations.
@RequiredArgsConstructor @Slf4j public abstract classsumitbhagwani commentedon Jul 24, 2020
Can you provide a small self contained example to trigger this failure? Thanks!
pramod199 commentedon Jul 26, 2020
Any code with lombok anootation processor fails.
HonoluluHenk commentedon Aug 2, 2020
Hmm... not quite (for me at least).
The variables generated by lombok actually need to be unused.
With the @slf4j example: as soon as I call e.g. log.info() in the class having the @slf4j annotation, the exception goes away.
Also: when I add @SuppressWarnings("unused") at class level, the exception goes away (but also the actual check which is quite a bummer).
HonoluluHenk commentedon Aug 2, 2020
I created a minimal testcase:
https://github.com/HonoluluHenk/error-prone-lombok-bug-report
Just run
./mvnw clean compilerspilker commentedon Oct 16, 2020
Based on the stacktrace, I guess that the problem is that Error Prone wants to come up with suggested fix for code that isn't actually there.
As suggested, #1863 might fix this problem.
cushon commentedon Jan 19, 2021
This is a duplicate of #1250