Catch common Java mistakes as compile-time errors

Related tags

java static-analysis
Overview

Error Prone

Error Prone is a static analysis tool for Java that catches common programming mistakes at compile-time.

public class ShortSet {
  public static void main (String[] args) {
    Set<Short> s = new HashSet<>();
    for (short i = 0; i < 100; i++) {
      s.add(i);
      s.remove(i - 1);
    }
    System.out.println(s.size());
  }
}
error: [CollectionIncompatibleType] Argument 'i - 1' should not be passed to this method;
its type int is not compatible with its collection's type argument Short
      s.remove(i - 1);
              ^
    (see https://errorprone.info/bugpattern/CollectionIncompatibleType)
1 error

Getting Started

Our documentation is at errorprone.info.

Error Prone works with Bazel, Maven, Ant, and Gradle. See our installation instructions for details.

Developing Error Prone

Developing and building Error Prone is documented on the wiki.

Links

Issues
  • JDK 14/15 compatibility

    JDK 14/15 compatibility

    What version of Error Prone are you using?

    2.3.4 (originally 2.3.1)

    Does this issue reproduce with the latest release?

    Yes

    What did you do?

    Error-prone does not work with JDK12 EA b09 and produces the following exception:

        [javac] 1 warning
        [javac] An exception has occurred in the compiler (12-ea). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
        [javac] java.lang.NoSuchMethodError: com.sun.tools.javac.util.Log.error(Lcom/sun/tools/javac/util/JCDiagnostic$DiagnosticPosition;Ljava/lang/String;[Ljava/lang/Object;)V
        [javac] 	at com.google.errorprone.ErrorProneError.logFatalError(ErrorProneError.java:55)
        [javac] 	at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:155)
        [javac] 	at jdk.compiler/com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:132)
        [javac] 	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1418)
        [javac] 	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1365)
        [javac] 	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:960)
        [javac] 	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:311)
        [javac] 	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:170)
        [javac] 	at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
        [javac] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        [javac] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        [javac] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        [javac] 	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        [javac] 	at org.apache.tools.ant.taskdefs.compilers.Javac13.execute(Javac13.java:57)
        [javac] 	at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1404)
        [javac] 	at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:1133)
        [javac] 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
        [javac] 	at jdk.internal.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
        [javac] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        [javac] 	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        [javac] 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
        [javac] 	at org.apache.tools.ant.Task.perform(Task.java:350)
        [javac] 	at org.apache.tools.ant.Target.execute(Target.java:449)
        [javac] 	at org.apache.tools.ant.Target.performTasks(Target.java:470)
        [javac] 	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1388)
        [javac] 	at org.apache.tools.ant.Project.executeTarget(Project.java:1361)
        [javac] 	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        [javac] 	at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
        [javac] 	at org.apache.tools.ant.Main.runBuild(Main.java:834)
        [javac] 	at org.apache.tools.ant.Main.startAnt(Main.java:223)
        [javac] 	at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284)
        [javac] 	at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)
    

    It works fine with previous build (JDK 12 EA b08). I don't know what change causes this error.

    opened by don-vip 48
  • Full Java 8 support

    Full Java 8 support

    Original issue created by [email protected] on 2014-03-27 at 04:19 PM


    Right now we have a build for javac 8 but are missing two important items needed for full support:

    1. Our Jenkins continuous build does not run Java 8 yet, only 6 and 7.

    2. We don't yet distribute the error-prone 8 jars to Sonatype. We probably want to distribute two sets of jars, one for versions 6 and 7, and one for 8. It would be nice if Maven could figure out which dependency to use based on the version of javac installed.

    Priority-High Status-Accepted migrated 
    opened by cushon 26
  • NullPointerException in 2.1.1 in Android compilation

    NullPointerException in 2.1.1 in Android compilation

    I can't see an obvious check that's failing here. This is compiling an Android application.

    3 warnings
    An exception has occurred in the compiler (1.8.0_112-release). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
    java.lang.NullPointerException
    	at com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitApply(Flow.java:1233)
    	at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1628)
    	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
    	at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:393)
    	at com.sun.tools.javac.tree.TreeScanner.visitExec(TreeScanner.java:213)
    	at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1446)
    	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
    	at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:393)
    	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
    	at com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitBlock(Flow.java:995)
    	at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1014)
    	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
    	at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:393)
    	at com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitMethodDef(Flow.java:962)
    	at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:866)
    	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
    	at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:393)
    	at com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitClassDef(Flow.java:925)
    	at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:774)
    	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
    	at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:393)
    	at com.sun.tools.javac.comp.Flow$FlowAnalyzer.analyzeTree(Flow.java:1325)
    	at com.sun.tools.javac.comp.Flow$FlowAnalyzer.analyzeTree(Flow.java:1315)
    	at com.sun.tools.javac.comp.Flow.analyzeTree(Flow.java:213)
    	at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1410)
    	at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1374)
    	at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973)
    	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 com.google.errorprone.BaseErrorProneCompiler.run(BaseErrorProneCompiler.java:137)
    	at com.google.errorprone.BaseErrorProneCompiler.run(BaseErrorProneCompiler.java:108)
    	at com.google.errorprone.ErrorProneCompiler.run(ErrorProneCompiler.java:118)
    	at com.google.errorprone.ErrorProneCompiler.compile(ErrorProneCompiler.java:65)
    	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 net.ltgt.gradle.errorprone.ErrorProneCompiler.execute(ErrorProneCompiler.java:76)
    	at net.ltgt.gradle.errorprone.ErrorProneCompiler.execute(ErrorProneCompiler.java:26)
    	at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJavaCompiler.java:104)
    	at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:53)
    	at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:38)
    	at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:35)
    	at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:25)
    	at org.gradle.api.tasks.compile.JavaCompile.performCompilation(JavaCompile.java:206)
    	at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:187)
    	at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:130)
    	at com.android.build.gradle.tasks.factory.AndroidJavaCompile.compile(AndroidJavaCompile.java:49)
    	at sun.reflect.GeneratedMethodAccessor1187.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    	at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:163)
    	at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
    	at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:123)
    	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:95)
    	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:76)
    	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:55)
    	at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
    	at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    	at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
    	at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:46)
    	at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
    	at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
    	at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    	at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
    	at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:236)
    	at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:228)
    	at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
    	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
    	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:61)
    	at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:228)
    	at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:215)
    	at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:77)
    	at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:58)
    	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
    	at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    	at java.lang.Thread.run(Thread.java:745)
    
     FAILED
    
    FAILURE: Build failed with an exception.
    
    opened by leepa 24
  • 'An illegal reflective access operation has occurred' warnings

    'An illegal reflective access operation has occurred' warnings

    The warning:

    Changes detected - recompiling the module!
    Compiling 8 source files to /home/my_stuff/target/classes
    WARNING: An illegal reflective access operation has occurred
    WARNING: Illegal reflective access by com.google.errorprone.bugpatterns.FutureReturnValueIgnored (file:/my_home/.m2/repository/com/google/errorprone/error_prone_core/2.3.2/error_prone_core-2.3.2.jar) to field com.sun.tools.javac.code.Type$StructuralTypeMapping$4.this$0
    WARNING: Please consider reporting this to the maintainers of com.google.errorprone.bugpatterns.FutureReturnValueIgnored
    WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
    WARNING: All illegal access operations will be denied in a future release
    
    $ java --version
    openjdk 11.0.1 2018-10-16
    OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
    OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)
    

    Java code that (rightfully) triggers the warning:

    @SuppressWarnings("FutureReturnValueIgnored")
    private void schedule(Runnable runnable, long delayMs) {
        try {
            scheduledExecutorService.schedule(runnable, delayMs, TimeUnit.MILLISECONDS);
        } catch (RejectedExecutionException ex) {
            // shutting down, no more checks
        }
    }
    

    I'm using the maven plugin as such:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.0</version>
        <configuration>
            <release>11</release>
            <debug>true</debug>
            <showDeprecation>true</showDeprecation>
            <showWarnings>true</showWarnings>
            <compilerArgument>-parameters</compilerArgument>
            <compilerArgs>
                <arg>-Xlint:all</arg>
                <arg>-Xlint:-processing</arg>
                <arg>-Werror</arg>
                <arg>-XDcompilePolicy=simple</arg>
                <arg>-Xplugin:ErrorProne</arg> 
            </compilerArgs>
            <annotationProcessorPaths>
                <path>
                    <groupId>com.google.errorprone</groupId>
                    <artifactId>error_prone_core</artifactId>
                    <version>2.3.2</version>
                </path>
            </annotationProcessorPaths> 
        </configuration>
    </plugin>
    
    opened by zimmi 24
  • lombok causes an IndexOutOfBoundsException in ParameterName

    lombok causes an IndexOutOfBoundsException in ParameterName

    After #690 was fixed, I removed the exclusions for the problematic bug patterns and tried to compile a project using Lombok, but it looks like the new bug pattern ParameterName also does not work well with Lombok it seems. Next time I'll make sure to try out Error Prone snapshots before a release :)

    Versions

    Error Prone version: 2.1.2 Lombok version: 1.16.18 / 1.16.16 Maven version: Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-04T04:39:06+09:00) Java version: 1.8.0_144, vendor: Oracle Corporation

    Note that I am also able to reproduce the issue with JDK 9.

    Reproducing Class:

    import lombok.Data;
    
    @Data
    public class SomeData {}
    

    Stack trace

    [ERROR]      Please report this at https://github.com/google/error-prone/issues/new and include the following:
    [ERROR]   
    [ERROR]      error-prone version: 2.1.2
    [ERROR]      Stack Trace:
    [ERROR]      java.lang.IndexOutOfBoundsException
    [ERROR]         at java.nio.HeapCharBuffer.subSequence(HeapCharBuffer.java:580)
    [ERROR]         at java.nio.HeapCharBuffer.subSequence(HeapCharBuffer.java:42)
    [ERROR]         at com.google.errorprone.bugpatterns.ParameterName.checkArguments(ParameterName.java:85)
    [ERROR]         at com.google.errorprone.bugpatterns.ParameterName.matchMethodInvocation(ParameterName.java:64)
    [ERROR]         at com.google.errorprone.scanner.ErrorProneScanner.visitMethodInvocation(ErrorProneScanner.java:907)
    [ERROR]         at com.google.errorprone.scanner.ErrorProneScanner.visitMethodInvocation(ErrorProneScanner.java:146)
    [ERROR]         at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1644)
    [ERROR]         at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
    [ERROR]         at com.google.errorprone.scanner.Scanner.scan(Scanner.java:82)
    [ERROR]         at com.google.errorprone.scanner.Scanner.scan(Scanner.java:42)
    [ERROR]         at com.sun.source.util.TreeScanner.visitUnary(TreeScanner.java:612)
    [ERROR]         at com.google.errorprone.scanner.ErrorProneScanner.visitUnary(ErrorProneScanner.java:1126)
    [ERROR]         at com.google.errorprone.scanner.ErrorProneScanner.visitUnary(ErrorProneScanner.java:146)
    [ERROR]         at com.sun.tools.javac.tree.JCTree$JCUnary.accept(JCTree.java:1956)
    [ERROR]         at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
    [ERROR]         at com.google.errorprone.scanner.Scanner.scan(Scanner.java:82)
    [ERROR]         at com.google.errorprone.scanner.Scanner.scan(Scanner.java:42)
    [ERROR]         at com.sun.source.util.TreeScanner.visitIf(TreeScanner.java:418)
    [ERROR]         at com.google.errorprone.scanner.ErrorProneScanner.visitIf(ErrorProneScanner.java:758)
    [ERROR]         at com.google.errorprone.scanner.ErrorProneScanner.visitIf(ErrorProneScanner.java:146)
    [ERROR]         at com.sun.tools.javac.tree.JCTree$JCIf.accept(JCTree.java:1427)
    [ERROR]         at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
    [ERROR]         at com.google.errorprone.scanner.Scanner.scan(Scanner.java:82)
    [ERROR]         at com.google.errorprone.scanner.Scanner.scan(Scanner.java:42)
    [ERROR]         at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:90)
    [ERROR]         at com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)
    [ERROR]         at com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:248)
    [ERROR]         at com.google.errorprone.scanner.ErrorProneScanner.visitBlock(ErrorProneScanner.java:530)
    [ERROR]         at com.google.errorprone.scanner.ErrorProneScanner.visitBlock(ErrorProneScanner.java:146)
    [ERROR]         at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1026)
    [ERROR]         at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
    [ERROR]         at com.google.errorprone.scanner.Scanner.scan(Scanner.java:82)
    [ERROR]         at com.google.errorprone.scanner.Scanner.scan(Scanner.java:42)
    [ERROR]         at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:90)
    [ERROR]         at com.sun.source.util.TreeScanner.visitMethod(TreeScanner.java:206)
    [ERROR]         at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:898)
    [ERROR]         at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:146)
    [ERROR]         at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:898)
    [ERROR]         at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
    [ERROR]         at com.google.errorprone.scanner.Scanner.scan(Scanner.java:82)
    [ERROR]         at com.google.errorprone.scanner.Scanner.scan(Scanner.java:42)
    [ERROR]         at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:90)
    [ERROR]         at com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)
    [ERROR]         at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:113)
    [ERROR]         at com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:187)
    [ERROR]         at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:590)
    [ERROR]         at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:146)
    [ERROR]         at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:808)
    [ERROR]         at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
    [ERROR]         at com.google.errorprone.scanner.Scanner.scan(Scanner.java:82)
    [ERROR]         at com.google.errorprone.scanner.Scanner.scan(Scanner.java:42)
    [ERROR]         at com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)
    [ERROR]         at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:113)
    [ERROR]         at com.sun.source.util.TreeScanner.visitCompilationUnit(TreeScanner.java:144)
    [ERROR]         at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:605)
    [ERROR]         at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:146)
    [ERROR]         at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:591)
    [ERROR]         at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:56)
    [ERROR]         at com.google.errorprone.scanner.Scanner.scan(Scanner.java:64)
    [ERROR]         at com.google.errorprone.scanner.ErrorProneScannerTransformer.apply(ErrorProneScannerTransformer.java:41)
    [ERROR]         at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:145)
    [ERROR]         at com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:120)
    [ERROR]         at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1425)
    [ERROR]         at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1374)
    [ERROR]         at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973)
    [ERROR]         at com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:100)
    [ERROR]         at com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:142)
    [ERROR]         at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:96)
    [ERROR]         at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:90)
    [ERROR]         at com.google.errorprone.BaseErrorProneCompiler.run(BaseErrorProneCompiler.java:137)
    [ERROR]         at com.google.errorprone.BaseErrorProneCompiler.run(BaseErrorProneCompiler.java:108)
    [ERROR]         at com.google.errorprone.ErrorProneCompiler.run(ErrorProneCompiler.java:118)
    [ERROR]         at org.codehaus.plexus.compiler.javac.errorprone.JavacCompilerWithErrorProne$CompilerInvoker.compile(JavacCompilerWithErrorProne.java:222)
    [ERROR]         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [ERROR]         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    [ERROR]         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [ERROR]         at java.lang.reflect.Method.invoke(Method.java:498)
    [ERROR]         at org.codehaus.plexus.compiler.javac.errorprone.JavacCompilerWithErrorProne.performCompile(JavacCompilerWithErrorProne.java:91)
    [ERROR]         at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:1075)
    [ERROR]         at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:168)
    [ERROR]         at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    [ERROR]         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    [ERROR]         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
    [ERROR]         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
    [ERROR]         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
    [ERROR]         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
    [ERROR]         at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    [ERROR]         at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    [ERROR]         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
    [ERROR]         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
    [ERROR]         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
    [ERROR]         at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
    [ERROR]         at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
    [ERROR]         at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
    [ERROR]         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [ERROR]         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    [ERROR]         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [ERROR]         at java.lang.reflect.Method.invoke(Method.java:498)
    [ERROR]         at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    [ERROR]         at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    [ERROR]         at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    [ERROR]         at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
    [ERROR]         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [ERROR]         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    [ERROR]         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [ERROR]         at java.lang.reflect.Method.invoke(Method.java:498)
    [ERROR]         at org.apache.maven.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:39)
    [ERROR]         at org.apache.maven.wrapper.WrapperExecutor.execute(WrapperExecutor.java:122)
    [ERROR]         at org.apache.maven.wrapper.MavenWrapperMain.main(MavenWrapperMain.java:50)
    

    Workaround

    Disable the newly introduced ParameterName bug pattern via a compiler argument: -Xep:ParameterName:OFF

    lombok 
    opened by shakuzen 24
  • Infinite compilation on JDK11

    Infinite compilation on JDK11

    When upgrading to JDK 11.01, the compilation never finishes but has high CPU activity. When removing ErrorProne, the compilation completes without a problem. I am unsure how to debug, e.g. to see what the javac process is doing, to provide more details.

    Environment:

    • JDK 11.01 (upgrading from 10+46)
    • Mac OS X Mojave
    • Gradle 5.0
    • ErrorProne:
      • core: 2.3.2
      • javac: 9+181-r4173-1
      • plugin: 0.6
    • Annotation Processors:
      • autoFactory: 1.0-beta6
      • autoValue: 1.6.3
      • autoValueBuilder: 2.9.1

    Of course if I disable the annotation processors then it fails due to the missing generated classes, but does terminate. Removing autoFactory leads to the hang, while autoValue is used too frequently to get a hang prior. So there is a chance that it is related to annotation processing (such as due to Gradle's incremental support), but could be something else.

    opened by ben-manes 21
  • Lombok breaks NestedInstanceOfConditions and InstanceOfAndCastMatchWrongType

    Lombok breaks NestedInstanceOfConditions and InstanceOfAndCastMatchWrongType

    Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T15:39:06-04:00) Java version: 1.8.0_131, vendor: Oracle Corporation Lombok version: 1.16.16

    java.lang.NullPointerException
            at lombok.javac.apt.LombokFileObjects.createEmpty(LombokFileObjects.java:123)
            at lombok.javac.apt.InterceptingJavaFileManager.getJavaFileForOutput(InterceptingJavaFileManager.java:47)
            at com.sun.tools.javac.processing.JavacFiler.createSourceOrClassFile(JavacFiler.java:478)
            at com.sun.tools.javac.processing.JavacFiler.createSourceFile(JavacFiler.java:417)
            at lombok.javac.apt.LombokProcessor.forceNewRound(LombokProcessor.java:333)
            at lombok.javac.apt.LombokProcessor.process(LombokProcessor.java:322)
            at lombok.core.AnnotationProcessor$JavacDescriptor.process(AnnotationProcessor.java:114)
            at lombok.core.AnnotationProcessor.process(AnnotationProcessor.java:164)
            at lombok.launch.AnnotationProcessorHider$AnnotationProcessor.process(AnnotationProcessor.java:74)
            at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:968)
            at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:884)
            at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$2200(JavacProcessingEnvironment.java:108)
            at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1204)
            at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1313)
            at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1267)
            at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:943)
            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 com.google.errorprone.BaseErrorProneCompiler.run(BaseErrorProneCompiler.java:137)
            at com.google.errorprone.BaseErrorProneCompiler.run(BaseErrorProneCompiler.java:108)
            at com.google.errorprone.ErrorProneCompiler.run(ErrorProneCompiler.java:118)
            at com.google.errorprone.ErrorProneCompiler.compile(ErrorProneCompiler.java:65)
            at org.codehaus.plexus.compiler.javac.errorprone.JavacCompilerWithErrorProne$CompilerInvoker.compile(JavacCompilerWithErrorProne.java:219)
            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.codehaus.plexus.compiler.javac.errorprone.JavacCompilerWithErrorProne.performCompile(JavacCompilerWithErrorProne.java:91)
            at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:825)
            at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
            at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
            at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
            at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
            at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
            at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
            at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
            at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
            at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
            at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
            at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
            at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
            at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
            at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
            at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
            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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
            at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
            at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
            at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
    
    error-prone version: 2.0.21                                                                                                                                                 
    Stack Trace:                                                                                                                                                                
    java.lang.ClassCastException: com.sun.tools.javac.tree.JCTree$JCBinary cannot be cast to com.sun.source.tree.ParenthesizedTree                                              
       at com.google.errorprone.bugpatterns.NestedInstanceOfConditions.matchIf(NestedInstanceOfConditions.java:53)                                                              
       at com.google.errorprone.scanner.ErrorProneScanner.visitIf(ErrorProneScanner.java:752)                                                                                   
       at com.google.errorprone.scanner.ErrorProneScanner.visitIf(ErrorProneScanner.java:146)                                                                                   
       at com.sun.tools.javac.tree.JCTree$JCIf.accept(JCTree.java:1427)                                                                                                         
       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.scan(TreeScanner.java:105)                                                                                                            
       at com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:248)                                                                                                      
       at com.google.errorprone.scanner.ErrorProneScanner.visitBlock(ErrorProneScanner.java:530)                                                                                
       at com.google.errorprone.scanner.ErrorProneScanner.visitBlock(ErrorProneScanner.java:146)                                                                                
       at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1026)                                                                                                      
       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.scanAndReduce(TreeScanner.java:90)                                                                                                    
       at com.sun.source.util.TreeScanner.visitMethod(TreeScanner.java:206)                                                                                                     
       at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:898)                                                                               
       at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:146)                                                                               
       at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:898)                                                                                                  
       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.scanAndReduce(TreeScanner.java:90)                                                                                                    
       at com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)                                                                                                            
       at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:113)                                                                                                   
       at com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:187)                                                                                                      
       at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:590)                                                                                
       at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:146)                                                                                
       at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:808)                                                                                                   
       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.scan(TreeScanner.java:105)                                                                                                            
       at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:113)                                                                                                   
       at com.sun.source.util.TreeScanner.visitCompilationUnit(TreeScanner.java:144)                                                                                            
       at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:605)                                                                      
       at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:146)                                                                      
       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:64)                                                                                                           
       at com.google.errorprone.scanner.ErrorProneScannerTransformer.apply(ErrorProneScannerTransformer.java:41)                                                                
       at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:145)                                                                                        
       at com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:120)                                                                                        
       at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1425)                                                                                                    
       at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1374)                                                                                                    
       at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973)                                                                                                  
       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 com.google.errorprone.BaseErrorProneCompiler.run(BaseErrorProneCompiler.java:137)                                                                                     
       at com.google.errorprone.BaseErrorProneCompiler.run(BaseErrorProneCompiler.java:108)                                                                                     
       at com.google.errorprone.ErrorProneCompiler.run(ErrorProneCompiler.java:118)                                                                                             
       at com.google.errorprone.ErrorProneCompiler.compile(ErrorProneCompiler.java:65)                                                                                          
       at org.codehaus.plexus.compiler.javac.errorprone.JavacCompilerWithErrorProne$CompilerInvoker.compile(JavacCompilerWithErrorProne.java:219)                               
       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.codehaus.plexus.compiler.javac.errorprone.JavacCompilerWithErrorProne.performCompile(JavacCompilerWithErrorProne.java:91)                                         
       at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:825)                                                                          
       at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)                                                                                          
       at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)                                                                     
       at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)                                                                                       
       at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)                                                                                       
       at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)                                                                                       
       at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)                                                              
       at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)                                                               
       at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)                                                 
       at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)                                                                               
       at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)                                                                                                        
       at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)                                                                                                        
       at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)                                                                                                          
       at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)                                                                                                              
       at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)                                                                                                               
       at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)                                                                                                                 
       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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)                                                                                   
       at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)                                                                                           
       at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)                                                                                 
       at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)                                                                                             
    
    opened by davidmontoyago 20
  • Upgrade javac to JDK10 to support classfile version 54

    Upgrade javac to JDK10 to support classfile version 54

    When running error-prone with JDK 10-ea+35 we get the following compilation warnings:

    [javac] warning: /modules/java.base/java/lang/Deprecated.class: major version 54 is newer than 53, the highest major version supported by this compiler.
    [javac]   It is recommended that the compiler be upgraded.
    

    for each class of the JDK. This is due to JDK-8188870: Bump classfile version number to 54.

    With the new release cycle, the compiler will have to be updated every 6 months to support the new classfile version.

    Maybe you could directly switch to JDK11 as classfile version 55 is coming soon, see JDK-8191913: Bump classfile version number to 55.

    opened by don-vip 19
  • Calling Map/Collection methods with arguments that are not compatible with type parameters

    Calling Map/Collection methods with arguments that are not compatible with type parameters

    Original issue created by [email protected] on 2013-03-05 at 03:23 PM


    There are some methods on Map<K,V> or Collection<V> that accept Object because of compatibility reasons, while in fact they should accept <V>. We can check that arguments passed to those methods are compatible with V.

    Example: Map<MyProto, Integer> map = ...; MyProto.Builder proto = MyProto.newBuilder()...; if (map.get(proto)) { ... };

    Following checks can be introduced for all "Map<K,V> map" and "T arg" variables:

    1. map.containsKey(arg) --> check that either "T extends K" or "T super K"
    2. map.containsValue(arg) --> check that either "T extends V" or "T super V"
    3. map.get(arg) --> check that either "T extends K" or "T super K"
    4. map.remove(arg) --> check that either "T extends K" or "T super K"

    Following checks can be introduced for all "Collection<V> coll" and "T arg" variables:

    1. coll.contains(arg) --> check that either "T extends V" or "T super V"
    2. coll.remove(arg) --> check that either "T extends V" or "T super V"

    Same for List.indexOf, List.lastIndexOf.

    Priority-High Status-Accepted Type-NewCheck migrated 
    opened by cushon 19
  • No error-prone scanner registered in context

    No error-prone scanner registered in context

    Original issue created by Arne.Osthues on 2013-09-12 at 10:18 AM


    When I try to compile I get the error:

    No error-prone scanner registered in context. Is annotation processing enabled? Please report bug to error-prone

    I am using the maven configuration from the wiki. I using the maven-processor-plugin for annotation processing but without any luck. Did I miss something in my configuration?

    Do you need more Information? Using win 8 x64; java 1.7.0_25

    Priority-Medium Status-Fixed Type-Defect migrated 
    opened by cushon 17
  • AssertionError in FieldCanBeStatic due to using a record

    AssertionError in FieldCanBeStatic due to using a record

    ATTENTION! Please read and follow:

    • if this is a question about Error Prone, send it to [email protected]
    • if this is a bug or feature request, fill the form below as best as you can.

    Description of the problem / feature request:

    FieldCanBeStatic is failing because of the presence of a record.

    [ERROR]      error-prone version: 2.6.0
    [ERROR]      BugPattern: FieldCanBeStatic
    [ERROR]      Stack Trace:
    [ERROR]      java.lang.AssertionError: Unexpected type kind RECORD
    [ERROR]   	at com.google.errorprone.bugpatterns.threadsafety.ThreadSafety$ThreadSafeTypeVisitor.visitType(ThreadSafety.java:565)
    [ERROR]   	at com.google.errorprone.bugpatterns.threadsafety.ThreadSafety$ThreadSafeTypeVisitor.visitType(ThreadSafety.java:499)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.code.Types$DefaultTypeVisitor.visitClassType(Types.java:4903)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.accept(Type.java:1010)
    [ERROR]   	at com.google.errorprone.bugpatterns.threadsafety.ThreadSafety.isThreadSafeType(ThreadSafety.java:495)
    [ERROR]   	at com.google.errorprone.bugpatterns.FieldCanBeStatic.isTypeKnownImmutable(FieldCanBeStatic.java:292)
    [ERROR]   	at com.google.errorprone.bugpatterns.FieldCanBeStatic.matchVariable(FieldCanBeStatic.java:190)
    [ERROR]   	at com.google.errorprone.scanner.ErrorProneScanner.processMatchers(ErrorProneScanner.java:450)
    [ERROR]   	at com.google.errorprone.scanner.ErrorProneScanner.visitVariable(ErrorProneScanner.java:885)
    [ERROR]   	at com.google.errorprone.scanner.ErrorProneScanner.visitVariable(ErrorProneScanner.java:151)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:1001)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)
    [ERROR]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
    [ERROR]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:94)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:109)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:117)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:193)
    [ERROR]   	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:549)
    [ERROR]   	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:151)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:832)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)
    [ERROR]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
    [ERROR]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:94)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:109)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:117)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:193)
    [ERROR]   	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:549)
    [ERROR]   	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:151)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:832)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)
    [ERROR]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
    [ERROR]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:109)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:117)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitCompilationUnit(TreeScanner.java:148)
    [ERROR]   	at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:561)
    [ERROR]   	at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:151)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:603)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:60)
    [ERROR]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:58)
    [ERROR]   	at com.google.errorprone.scanner.ErrorProneScannerTransformer.apply(ErrorProneScannerTransformer.java:43)
    [ERROR]   	at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:152)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:132)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1421)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1368)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:960)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:317)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:176)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:64)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:50)
    

    Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

    This appears to be enough. The suppression is needed because this example also causes a different problem in another checker (issue #2323).

    package example;
    
    @SuppressWarnings("PrivateConstructorForUtilityClass")
    public final class ExampleClass
    {
        public record OtherRecord(String value) { }
    
        public record SomeRecord(OtherRecord value)
        {
            public static SomeRecord fromValue(final OtherRecord value)
            {
                return new SomeRecord(value);
            }
        }
    
        private ExampleClass() {
        }
    }
    

    What version of Error Prone are you using?

    2.6.0

    opened by dododge 0
  • Nested record causes AssertionError in PrivateConstructorForUtilityClass

    Nested record causes AssertionError in PrivateConstructorForUtilityClass

    ATTENTION! Please read and follow:

    • if this is a question about Error Prone, send it to [email protected]
    • if this is a bug or feature request, fill the form below as best as you can.

    Description of the problem / feature request:

    PrivateConstructorForUtilityClass doesn't seem to handle a utility class that has a record inside.

         error-prone version: 2.6.0
         BugPattern: PrivateConstructorForUtilityClass
         Stack Trace:
         java.lang.AssertionError: unknown member type:RECORD
      	at com.google.errorprone.bugpatterns.PrivateConstructorForUtilityClass.isInstance(PrivateConstructorForUtilityClass.java:110)
      	at java.base/java.util.stream.MatchOps$1MatchSink.accept(MatchOps.java:90)
      	at java.base/java.util.Collections$2.tryAdvance(Collections.java:4820)
      	at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129)
      	at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
      	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
      	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
      	at java.base/java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:230)
      	at java.base/java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:196)
      	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      	at java.base/java.util.stream.ReferencePipeline.anyMatch(ReferencePipeline.java:632)
      	at com.google.errorprone.bugpatterns.PrivateConstructorForUtilityClass.matchClass(PrivateConstructorForUtilityClass.java:76)
      	at com.google.errorprone.scanner.ErrorProneScanner.processMatchers(ErrorProneScanner.java:450)
      	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:548)
      	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:151)
      	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:832)
      	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)
      	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
      	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
      	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:109)
      	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:117)
      	at jdk.compiler/com.sun.source.util.TreeScanner.visitCompilationUnit(TreeScanner.java:148)
      	at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:561)
      	at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:151)
      	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:603)
      	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:60)
      	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 jdk.compiler/com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:132)
      	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1421)
      	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1368)
      	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:960)
      	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:317)
      	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:176)
      	at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:64)
      	at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:50)
    

    Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

    This seems to be enough to trigger the problem:

    package example;
    
    public final class ExampleUtilityClass
    {
        public record SomeRecord(String value) { }
    }
    

    What version of Error Prone are you using?

    2.6.0

    opened by dododge 0
  • VerifyException in StreamResourceLeak

    VerifyException in StreamResourceLeak

    ATTENTION! Please read and follow:

    • if this is a question about Error Prone, send it to [email protected]
    • if this is a bug or feature request, fill the form below as best as you can.

    Description of the problem / feature request:

    Getting an unhandled exception within StreamResourceLeak. It looks very much like issue #1629 but is happening in 2.6.0 which I assume includes the fix from that issue.

    [ERROR]      error-prone version: 2.6.0
    [ERROR]      BugPattern: StreamResourceLeak
    [ERROR]      Stack Trace:
    [ERROR]      com.google.common.base.VerifyException
    [ERROR]   	at java.base/java.util.Optional.orElseThrow(Optional.java:403)
    [ERROR]   	at com.google.errorprone.matchers.Matchers.methodCallInDeclarationOfThrowingRunnable(Matchers.java:1321)
    [ERROR]   	at com.google.errorprone.bugpatterns.AbstractReturnValueIgnored.lambda$static$8059ac76$1(AbstractReturnValueIgnored.java:275)
    [ERROR]   	at com.google.errorprone.matchers.Matchers.lambda$allOf$93cd24cb$1(Matchers.java:136)
    [ERROR]   	at com.google.errorprone.matchers.Matchers.lambda$anyOf$5390886b$1(Matchers.java:168)
    [ERROR]   	at com.google.errorprone.bugpatterns.AbstractReturnValueIgnored.expectedExceptionTest(AbstractReturnValueIgnored.java:288)
    [ERROR]   	at com.google.errorprone.bugpatterns.AbstractMustBeClosedChecker.matchNewClassOrMethodInvocation(AbstractMustBeClosedChecker.java:80)
    [ERROR]   	at com.google.errorprone.bugpatterns.StreamResourceLeak.matchMethodInvocation(StreamResourceLeak.java:68)
    [ERROR]   	at com.google.errorprone.scanner.ErrorProneScanner.processMatchers(ErrorProneScanner.java:450)
    [ERROR]   	at com.google.errorprone.scanner.ErrorProneScanner.visitMethodInvocation(ErrorProneScanner.java:747)
    [ERROR]   	at com.google.errorprone.scanner.ErrorProneScanner.visitMethodInvocation(ErrorProneScanner.java:151)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1761)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)
    [ERROR]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
    [ERROR]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitMemberSelect(TreeScanner.java:720)
    [ERROR]   	at com.google.errorprone.scanner.ErrorProneScanner.visitMemberSelect(ErrorProneScanner.java:729)
    [ERROR]   	at com.google.errorprone.scanner.ErrorProneScanner.visitMemberSelect(ErrorProneScanner.java:151)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2281)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)
    [ERROR]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
    [ERROR]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:94)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitMethodInvocation(TreeScanner.java:531)
    [ERROR]   	at com.google.errorprone.scanner.ErrorProneScanner.visitMethodInvocation(ErrorProneScanner.java:752)
    [ERROR]   	at com.google.errorprone.scanner.ErrorProneScanner.visitMethodInvocation(ErrorProneScanner.java:151)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1761)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)
    [ERROR]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
    [ERROR]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitReturn(TreeScanner.java:492)
    [ERROR]   	at com.google.errorprone.scanner.ErrorProneScanner.visitReturn(ErrorProneScanner.java:818)
    [ERROR]   	at com.google.errorprone.scanner.ErrorProneScanner.visitReturn(ErrorProneScanner.java:151)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1665)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)
    [ERROR]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
    [ERROR]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:109)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:254)
    [ERROR]   	at com.google.errorprone.scanner.ErrorProneScanner.visitBlock(ErrorProneScanner.java:521)
    [ERROR]   	at com.google.errorprone.scanner.ErrorProneScanner.visitBlock(ErrorProneScanner.java:151)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1059)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)
    [ERROR]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
    [ERROR]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:94)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitMethod(TreeScanner.java:212)
    [ERROR]   	at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:741)
    [ERROR]   	at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:151)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:925)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)
    [ERROR]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
    [ERROR]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:94)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:109)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:117)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:193)
    [ERROR]   	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:549)
    [ERROR]   	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:151)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:832)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)
    [ERROR]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
    [ERROR]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:109)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:117)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitCompilationUnit(TreeScanner.java:148)
    [ERROR]   	at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:561)
    [ERROR]   	at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:151)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:603)
    [ERROR]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:60)
    [ERROR]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:58)
    [ERROR]   	at com.google.errorprone.scanner.ErrorProneScannerTransformer.apply(ErrorProneScannerTransformer.java:43)
    [ERROR]   	at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:152)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:132)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1421)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1368)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:960)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:317)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:176)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:64)
    [ERROR]   	at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:50)
    

    Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

    Trying to compile this produces the exception:

    package example;
    
    import java.io.IOException;
    import java.nio.file.Files;
    import java.nio.file.Path;
    import java.util.stream.Stream;
    
    record ExampleRecord(Path path)
    {
        public Stream<Path> list() throws IOException {
            return Files.list(path);
        }
    }
    

    What version of Error Prone are you using?

    2.6.0

    Also maven 3.8.1 and JDK 16.0.1.

    Have you found anything relevant by searching the web?

    Issue #1629

    opened by dododge 0
  • InvalidParam warning on Javadoc for Java record components

    InvalidParam warning on Javadoc for Java record components

    Description of the problem / feature request:

    Javadoc on Java record components are @param tags on the record itself. It's also possible to override the accessor methods, but that shouldn't be necessary. error-prone produces an InvalidParam warning here though, as it doesn't seem to understand the Java record syntax.

    Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

    /**
     * Example record.
     * @param name Name of the example record.
     */
    public record ExampleRecord(String name) {
    }
    

    What version of Error Prone are you using?

    2.6.0

    opened by DemonWav 0
  • Feature Request - Check-Then-Act misusage on Java concurrent collections

    Feature Request - Check-Then-Act misusage on Java concurrent collections

    Description of the problem / feature request:

    While checking the Check-Then-Act of Java Concurrent Collections famous paper on http://dig.cs.illinois.edu/papers/checkThenAct.pdf , I could not find any implementation of this checker in Errorprone. So, I would like to know that if it is a current need from the community. If so, I could help in developing such a checker.

    Feature requests: what underlying problem are you trying to solve with this feature?

    Detect misusage of Check-Then-Act pattern on Java concurrent collections described on http://dig.cs.illinois.edu/papers/checkThenAct.pdf

    Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

    Wrong usage:

    PermissionCollection pc;
    chk: if ((pc = loaderPC.get(codeUrl)) == null) {
      pc = super.getPermissions(codeSource);
      if (pc != null) {
        ... // initializing "pc"
    act: loaderPC.put(codeUrl,pc);
      }
    }
    return (pc);
    

    Reasoning: Suppose that both Thread 1 and Thread 2 execute statement chk and find that the map does not contain the key. Thus, they both calculate the value and put it on the map. Whoever is the last one will overwrite the value put by the other thread. This breaks the put-if-absent semantics of the original code.

    What version of Error Prone are you using?

    2.6.0

    opened by sergiofigueras 0
  • Lombok UtilityClass causes NPE from SameNameButDifferent (Java 16)

    Lombok UtilityClass causes NPE from SameNameButDifferent (Java 16)

    After upgrading to Java 16 (from 15) and Lombok 1.18.20 (from 1.18.16) compiling class annotated with @UtilityClass causes NPE:

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project common: Compilation failure
    [ERROR] /home/pfus/touk/workspace/[***]/OptionalUtils.java:[1] error: An unhandled exception was thrown by the Error Prone static analysis plugin.
    [ERROR]      Please report this at https://github.com/google/error-prone/issues/new and include the following:
    [ERROR]
    [ERROR]      error-prone version: 2.6.0
    [ERROR]      BugPattern: SameNameButDifferent
    [ERROR]      Stack Trace:
    [ERROR]      java.lang.NullPointerException: Cannot read field "owner" because "owner" is null
    [ERROR]         at com.google.errorprone.bugpatterns.SameNameButDifferent.getBetterImport(SameNameButDifferent.java:187)
    [ERROR]         at com.google.errorprone.bugpatterns.SameNameButDifferent.matchCompilationUnit(SameNameButDifferent.java:142)
    [ERROR]         at com.google.errorprone.scanner.ErrorProneScanner.processMatchers(ErrorProneScanner.java:450)
    [ERROR]         at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:556)
    [ERROR]         at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:151)
    
    

    I use error prone 2.6.0.

    Sample code:

    import lombok.experimental.UtilityClass;
    import org.slf4j.MDC;
    
    import java.util.Map;
    import java.util.Optional;
    import java.util.function.Supplier;
    
    @UtilityClass
    public class LoggingContext {
        public void withMdc(Map<String, Object> context, Runnable action) {
            withMdc(context, () -> {
                action.run();
                return null;
            });
        }
    
        public <T> T withMdc(Map<String, Object> context, Supplier<T> supplier) {
            context.forEach((key, value) -> Optional.ofNullable(value).map(Object::toString).ifPresent(v -> MDC.put(key, v)));
            try {
                return supplier.get();
            } finally {
                context.keySet().forEach(MDC::remove);
            }
        }
    }
    
    opened by piotrekfus91 0
  • Configuring ErrorProne with Java 16

    Configuring ErrorProne with Java 16

    Description of the problem / feature request:

    The Error Prone Installation page contains configuration for Java 16 that sets source and target down to Java 8. Is this intended?

    <source>8</source>
    <target>8</target>
    
    opened by Alos 3
  • ImmutableMemberCollection not detecting JDK Set.of(...)

    ImmutableMemberCollection not detecting JDK Set.of(...)

    Description of the problem / feature request:

    I have following code,

    private static final Set<String> SUPPORTED_METHODS = Set.of(
          HttpMethods.GET, HttpMethods.POST, HttpMethods.PUT, HttpMethods.DELETE,
          HttpMethods.HEAD, HttpMethods.OPTIONS, HttpMethods.TRACE
    );
    

    I have enabled ImmutableMemberCollection in my gradle file. On error-prone version 2.5.1, this works fine. But when I upgrade to 2.6.0, I get following error.

     error: [ImmutableMemberCollection] If you don't intend to mutate a member collection prefer using Immutable types.
    public final class OkHttpTransport extends HttpTransport {
                 ^
        (see https://errorprone.info/bugpattern/ImmutableMemberCollection)
      Did you mean 'private static final ImmutableSet<String> SUPPORTED_METHODS = ImmutableSet.copyOf(Set.of('?
    1 error
    

    Feature requests: what underlying problem are you trying to solve with this feature?

    Set.of already returns an immutable collection, so error-prone should detect this and not throw an error.

    Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

    public final class MyClass {
    private static final Set<String> MY_STRINGS = Set.of("a", "b", "c");
    }
    

    What version of Error Prone are you using?

    2.6.0

    Have you found anything relevant by searching the web?

    Nothing in particular.

    opened by vivekkothari 0
  • Lombok & Errorprone not working

    Lombok & Errorprone not working

    Description of the problem / feature request:

    error: An unhandled exception was thrown by the Error Prone static analysis plugin. package .... error-prone version: 2.6.0 BugPattern: SameNameButDifferent Stack Trace: java.lang.IllegalArgumentException: invalid source positions (629, 593) for: NonNull at com.google.common.base.Preconditions.checkArgument(Preconditions.java:459) at com.google.errorprone.VisitorState.getSourceForNode(VisitorState.java:553) at com.google.errorprone.bugpatterns.SameNameButDifferent$1.handle(SameNameButDifferent.java:101) at com.google.errorprone.bugpatterns.SameNameButDifferent$1.visitIdentifier(SameNameButDifferent.java:84) at com.google.errorprone.bugpatterns.SameNameButDifferent$1.visitIdentifier(SameNameButDifferent.java:61)

    Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

    package token;
    
    import java.util.List;
    
    import com.fasterxml.jackson.annotation.JsonInclude;
    import com.fasterxml.jackson.annotation.JsonInclude.Include;
    
    import lombok.Builder;
    import lombok.Getter;
    import lombok.NonNull;
    
    @JsonInclude(Include.NON_NULL)
    @Builder
    @Getter
    public class GenerateTokenRequest {
        @NonNull
        private final TokenAccessLevel accessLevel;
        private final boolean allowSaveAs;
        private final String datasetId;
        private final List<EffectiveIdentity> identities;
    }
    

    What version of Error Prone are you using?

    error-prone version: 2.6.0

    Have you found anything relevant by searching the web?

    https://github.com/google/error-prone/issues/690

    opened by benjamineckstein 0
  • JDK15 - Illegal reflective access by com.google.errorprone.util.ErrorProneTokens$CommentSavingTokenizer

    JDK15 - Illegal reflective access by com.google.errorprone.util.ErrorProneTokens$CommentSavingTokenizer

    Description of the problem / feature request:

    Compiling josm.openstreetmap.de with ant and JDK 15 shows :

    [javac] WARNING: An illegal reflective access operation has occurred
    [javac] WARNING: Illegal reflective access by com.google.errorprone.util.ErrorProneTokens$CommentSavingTokenizer (file:/../com.google.errorprone/error_prone_check_api/jars/error_prone_check_api-2.5.1.jar) to field com.sun.tools.javac.parser.JavaTokenizer.reader
    [javac] WARNING: Please consider reporting this to the maintainers of com.google.errorprone.util.ErrorProneTokens$CommentSavingTokenizer
    [javac] WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
    [javac] WARNING: All illegal access operations will be denied in a future release
    

    Feature requests: what underlying problem are you trying to solve with this feature?

    Replace this line with your answer.

    Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

    Compile with javac 15.0.2

    What version of Error Prone are you using?

    2.5.1

    Have you found anything relevant by searching the web?

    no

    opened by jorisgeer 1
Releases(v2.6.0)
Owner
Google
Google ❤️ Open Source
Google
Testing tools for javac and annotation processors

Compile Testing A library for testing javac compilation with or without annotation processors. See the javadoc for usage examples. License Copyright 2

Google 559 Mar 10, 2021
A Java API for generating .java source files.

JavaPoet JavaPoet is a Java API for generating .java source files. Source file generation can be useful when doing things such as annotation processin

Square 8.7k Mar 12, 2021
Java 8 annotation processor and framework for deriving algebraic data types constructors, pattern-matching, folds, optics and typeclasses.

Derive4J: Java 8 annotation processor for deriving algebraic data types constructors, pattern matching and more! tl;dr Show me how to write, say, the

null 511 Feb 23, 2021
A collection of source code generators for Java.

Auto A collection of source code generators for Java. Auto‽ Java is full of code that is mechanical, repetitive, typically untested and sometimes the

Google 9.1k Mar 13, 2021
将枚举映射为数据字典,可用于前后端共享数据字典

DictMapper 这是一个从个人项目中剥离出来的小组件,用于前后端统一维护数据字典。在我的项目里面,它叫常量字典。 使用场景 被注解的枚举类 @MapDict(code = "status_flags", name = "状态") public enum StatusEnum { @Labe

null 13 Mar 22, 2021
Java 1-15 Parser and Abstract Syntax Tree for Java, including preview features to Java 13

JavaParser This project contains a set of libraries implementing a Java 1.0 - Java 14 Parser with advanced analysis functionalities. This includes pre

JavaParser 3.6k Mar 13, 2021
This open source project allows you to easily integrate Camunda's External Task Clients into Micronaut projects: simply add a dependency in your Micronaut project

micronaut-camunda-external-client This open source project allows you to easily integrate Camunda 's External Task Clients into Micronaut projects. Mi

Novatec Consulting GmbH 13 Apr 20, 2021
Write parsers for arbitrary text inputs, entirely in Java, with no preprocessing phase

Read me first The license of this project is Apache 2.0. Requires Java 7 or later. The latest versions are: development: 2.1.0-beta.3; requires Java 8

Francis Galiegue 63 Nov 10, 2020
Compiler of Java bytecode to JavaScript

TeaVM See documentation at the project web site. Useful links: Getting started Gallery Flavour source code repository Site source code repository Disc

Alexey Andreev 1.7k Mar 13, 2021
GraalVM: Run Programs Faster Anywhere :rocket:

GraalVM GraalVM is a universal virtual machine for running applications written in JavaScript, Python, Ruby, R, JVM-based languages like Java, Scala,

Oracle 14.7k Mar 13, 2021
Build parsers in Java

jparsec Builds mini parsers in pure Java. Latest version: 3.0 (requires Java 8+) News 2016-12-05 Removed references to Codehaus in copyright and packa

null 288 Feb 24, 2021
Elegant parsing in Java and Scala - lightweight, easy-to-use, powerful.

Please see https://repo1.maven.org/maven2/org/parboiled/ for download access to the artifacts https://github.com/sirthias/parboiled/wiki for all docum

Mathias 1.2k Mar 13, 2021
提供Java对动态字符串支持的语法插件

Zircon 支持在Java语言中使用内插字符串 实现类似于kotlin、Groovy等语言中内插字符串 支持android、java等所有使用javac的项目 几乎不会增加额外编译时间 代码内容支持idea补全提示(需自行配置) 使用示例 String add = "test2"; ass

null 15 Mar 7, 2021
The Eta Programming Language, a dialect of Haskell on the JVM

Eta - Modern Haskell on the JVM The Eta programming language is a dialect of Haskell which runs on the JVM and has the following goals: accessibility

TypeLead 2.5k Mar 13, 2021