lishunli / projectlombok

Automatically exported from code.google.com/p/projectlombok
0 stars 0 forks source link

NullPointerException during compilation because of val #581

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Put that in a file :
public class TestLombok {
    @Getter
    Object test = new Object() {
      void test() {
          val test = "TEST";
      }
    };
}

2. Compile it.
3. Observe the crash.

What is the expected output? What do you see instead?

Expected is a successful compilation. Observed is crash with a 
NullPointerException

What version of the product are you using? On what operating system?

Lombok 0.12.0 on openjdk 1.7.0_21 (64 bit) on linux 3.10-12 amd64.

Please provide any additional information below.

IMPORTANT : remove the Getter annotation and it compiles fine. (but substitute 
it with any other one - SuppressWarning for example - and the crash is back)

Stacktrace :

Exception while resolving: NODE LOCAL (class 
com.sun.tools.javac.tree.JCTree$JCVariableDecl) @val()
final java.lang.Object test = "TEST"
java.lang.NullPointerException
    at com.sun.tools.javac.comp.Check$Validator.visitTypeApply(Check.java:1066)
    at com.sun.tools.javac.tree.JCTree$JCTypeApply.accept(JCTree.java:1866)
    at com.sun.tools.javac.comp.Check$Validator.validateTree(Check.java:1150)
    at com.sun.tools.javac.comp.Check.validate(Check.java:1038)
    at com.sun.tools.javac.comp.Check.validate(Check.java:1035)
    at com.sun.tools.javac.comp.Attr.visitVarDef(Attr.java:859)
    at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:725)
    at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:431)
    at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:418)
    at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:480)
    at lombok.javac.JavacResolution.attrib(JavacResolution.java:364)
    at lombok.javac.JavacResolution.resolveMethodMember(JavacResolution.java:332)
    at lombok.javac.handlers.HandleVal.visitLocal(HandleVal.java:99)
    at lombok.javac.JavacNode.traverse(JavacNode.java:92)
    at lombok.javac.JavacAST.traverseChildren(JavacAST.java:116)
    at lombok.javac.JavacNode.traverse(JavacNode.java:77)
    at lombok.javac.JavacAST.traverseChildren(JavacAST.java:116)
    at lombok.javac.JavacNode.traverse(JavacNode.java:67)
    at lombok.javac.JavacAST.traverseChildren(JavacAST.java:116)
    at lombok.javac.JavacNode.traverse(JavacNode.java:98)
    at lombok.javac.JavacAST.traverseChildren(JavacAST.java:116)
    at lombok.javac.JavacNode.traverse(JavacNode.java:72)
    at lombok.javac.JavacAST.traverseChildren(JavacAST.java:116)
    at lombok.javac.JavacNode.traverse(JavacNode.java:67)
    at lombok.javac.JavacAST.traverseChildren(JavacAST.java:116)
    at lombok.javac.JavacNode.traverse(JavacNode.java:62)
    at lombok.javac.JavacAST.traverse(JavacAST.java:112)
    at lombok.javac.HandlerLibrary.callASTVisitors(HandlerLibrary.java:259)
    at lombok.javac.JavacTransformer.transform(JavacTransformer.java:71)
    at lombok.javac.apt.Processor.process(Processor.java:252)
    at lombok.core.AnnotationProcessor$JavacDescriptor.process(AnnotationProcessor.java:117)
    at lombok.core.AnnotationProcessor.process(AnnotationProcessor.java:167)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:793)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:722)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1700(JavacProcessingEnvironment.java:97)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1029)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1163)
    at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1108)
    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:824)
    at com.sun.tools.javac.main.Main.compile(Main.java:439)
    at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:132)
    at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:126)
    at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:169)
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:785)
    at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:318)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:153)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:414)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:357)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

Original issue reported on code.google.com by gregoire...@gmail.com on 24 Sep 2013 at 5:00

GoogleCodeExporter commented 9 years ago
Reproduced in 0.11.8, 0.12 HEAD using OpenJDK 1.7.0-15.

This is almost the exact same stacktrace as issue 543 and issue 361, but there 
Roel says "*ANY* use of 'val' *ANYWHERE* in *ANY* local class, if the local 
class has generics, will fail with an NPE." Which this doesn't have. So it's 
not only generics that make the bomb explode.

Original comment by askon...@gmail.com on 7 Oct 2013 at 6:15

GoogleCodeExporter commented 9 years ago
This should be fixed in edge, and this fix will be rolled out 1.16.2 which will 
be out in a day or two.

Original comment by reini...@gmail.com on 8 Feb 2015 at 9:07