Repository navigation
Closed
Description
[ERROR] error-prone version: 2.3.1
[ERROR] BugPattern: InconsistentCapitalization
[ERROR] Stack Trace:
[ERROR] java.lang.NullPointerException
[ERROR] at com.google.errorprone.fixes.SuggestedFixes.renameVariable(SuggestedFixes.java:374)
[ERROR] at com.google.errorprone.bugpatterns.InconsistentCapitalization.matchClass(InconsistentCapitalization.java:83)
[ERROR] at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:581)
[ERROR] at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:145)
[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:602)
[ERROR] at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:145)
[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:43)
[ERROR] at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:152)
[ERROR] at com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:120)
[ERROR] at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1404)
[ERROR] at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1353)
[ERROR] at com.sun.tools.javac.main.JavaCompiler.desugarByFile(JavaCompiler.java:1597)
[ERROR] at com.sun.tools.javac.main.JavaCompiler.desugar(JavaCompiler.java:1501)
[ERROR] at com.sun.tools.javac.main.JavaCompiler.desugar(JavaCompiler.java:1418)
[ERROR] at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:952)
[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.GeneratedMethodAccessor63.invoke(Unknown Source)
[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:137)
[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:56)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
[ERROR] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
[ERROR] at org.apache.maven.cli.MavenCli.execute(MavenCli.java:956)
[ERROR] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:290)
[ERROR] at org.apache.maven.cli.MavenCli.main(MavenCli.java:194)
[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:55)
Metadata
Metadata
Assignees
Labels
No labels
Activity
cushon commentedon Apr 23, 2018
Thanks for the report. Can you provide a self-contained example that reproduces the crash?
lgemeinhardt commentedon May 7, 2018
I have the same issue using this simplified code
package com.sample;
import java.util.function.Consumer;
public abstract class Callback {
}
madrob commentedon Jun 29, 2018
I also have run into this issue with 2.3.0 and 2.3.1, this is a new issue that was not present in 2.2.0.
I was able to pare down the test case provided by @lgemeinhardt into something shorter. The NPE goes away if the
doOnSuccessmethod is removed. It doesn't have anything to do with the null argument being passed to the constructor because if I replace that line withreturn new Callback(new WaitHandler() {}) {};then I still get the same crash.@cushon Any further insights on what is going on here?
madrob commentedon Jun 29, 2018
In 0283b46 we added a check for
state.getSourceForNode(tree.getType())might be null, but then two lines later we dereference it anyway.cushon commentedon Jun 29, 2018
@madrob thanks for the repro!
We later dereference
state.getSourceForNode(tree), which is different thanstate.getSourceForNode(tree.getType()). The latter can be null without the former also being null, in the case of implicitly-type lambda parameters. Or am I missing something?madrob commentedon Jun 29, 2018
Oh, no, you're right, they are different. I wasn't reading the code carefully enough. I poked around further and it looks like it matters that we're doing an anonymous type. I switched my repro from using WaitHandler to AutoCloseable like the other InconsistentCapitalization tests and noticed that the compilation unit becomes:
Trying to suggest a replacement for the
final java.lang.AutoCloseable autocloseablebit is what causes NPE since it doesn't exist in the source, which causesstate.getSourceForNode(tree)to also return null. In this case, I think we can skip the whole suggested fix, since there is no source to replace. Will have a PR up shortly.fix google#1008 InconsistentCapitalization NPE
cushon commentedon Jun 29, 2018
Thanks, I noticed the same thing look at your repro. Generally we want to run Error Prone checks over the IR prior to any desugaring, but javac adds implicit default constructors really early in the compilation, and we have to ignore them in Error Prone. Here's one example:
error-prone/check_api/src/main/java/com/google/errorprone/scanner/ErrorProneScanner.java
Line 881 in fc16cc5
I have a fix in progress to use the same approach in this check.
madrob commentedon Jul 2, 2018
Is this bugfix enough to motivate a 2.3.2 (or 2.4.0?)