Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Lombok visitor handler class lombok.javac.handlers.HandleVal failed: java.lang.NullPointerException #3148

Open
MineYuanlu opened this issue Mar 23, 2022 · 8 comments
Assignees
Labels
accepted The issue/enhancement is valid, sensible, and explained in sufficient detail bug javac

Comments

@MineYuanlu
Copy link

MineYuanlu commented Mar 23, 2022

Describe the bug
NPE encountered while "mvn clean install".
like #2999 , But I'm using the latest version of Lombok

To Reproduce
I can't separate a single original file because he relies too much on other lib.
repo
File with NPE: yuan/plugins/serverDo/bungee/ConfigManager.java

I used the build of idea and the command line of "mvn install", which caused the following problems:

[INFO] Compiling 6 source files to D:\document\development\java\project\yuanluServerDo\yuanluServerDo-bungeecord\target\classes
Exception while resolving: NODE LOCAL (class com.sun.tools.javac.tree.JCTree$JCVariableDecl) @val()
final ___Lombok_VAL_Attrib__ name = e.getKey()(RegularFileObject[D:\document\development\java\project\yuanluServerDo\yuanluServerDo-bungeecord\src\main\java\yuan\plugins\serverDo\bungee\ConfigManager.java])
java.lang.NullPointerException
        at com.sun.tools.javac.comp.Check$Validator.visitTypeApply(Check.java:1259)
        at com.sun.tools.javac.tree.JCTree$JCTypeApply.accept(JCTree.java:2135)
        at com.sun.tools.javac.comp.Check$Validator.validateTree(Check.java:1359)
        at com.sun.tools.javac.comp.Check.validate(Check.java:1230)
        at com.sun.tools.javac.comp.Attr.visitVarDef(Attr.java:1055)
        at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:852)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:576)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:645)
        at com.sun.tools.javac.comp.Attr.visitForeachLoop(Attr.java:1168)
        at com.sun.tools.javac.tree.JCTree$JCEnhancedForLoop.accept(JCTree.java:1035)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:576)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:645)
        at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:661)
        at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1124)
        at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:909)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:576)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:645)
        at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1013)
        at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:778)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:576)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:645)
        at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4364)
        at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4272)
        at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4201)
        at com.sun.tools.javac.comp.Attr.visitClassDef(Attr.java:870)
        at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:693)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:576)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:645)
        at com.sun.tools.javac.comp.Attr.visitNewClass(Attr.java:2144)
        at com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1516)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:576)
        at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:618)
        at com.sun.tools.javac.comp.Attr.visitVarDef(Attr.java:1075)
        at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:852)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:576)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:645)
        at lombok.javac.JavacResolution.attrib(JavacResolution.java:259)
        at lombok.javac.JavacResolution.memberEnterAndAttribute(JavacResolution.java:221)
        at lombok.javac.JavacResolution.resolveMethodMember(JavacResolution.java:169)
        at lombok.javac.handlers.HandleVal.endVisitLocal(HandleVal.java:150)
        at lombok.javac.JavacNode.traverse(JavacNode.java:122)
        at lombok.javac.JavacAST.traverseChildren(JavacAST.java:222)
        at lombok.javac.JavacNode.traverse(JavacNode.java:126)
        at lombok.javac.JavacAST.traverseChildren(JavacAST.java:222)
        at lombok.javac.JavacNode.traverse(JavacNode.java:126)
        at lombok.javac.JavacAST.traverseChildren(JavacAST.java:222)
        at lombok.javac.JavacNode.traverse(JavacNode.java:105)
        at lombok.javac.JavacAST.traverseChildren(JavacAST.java:222)
        at lombok.javac.JavacNode.traverse(JavacNode.java:95)
        at lombok.javac.JavacAST.traverseChildren(JavacAST.java:222)
        at lombok.javac.JavacNode.traverse(JavacNode.java:126)
        at lombok.javac.JavacAST.traverseChildren(JavacAST.java:222)
        at lombok.javac.JavacNode.traverse(JavacNode.java:100)
        at lombok.javac.JavacAST.traverseChildren(JavacAST.java:222)
        at lombok.javac.JavacNode.traverse(JavacNode.java:95)
        at lombok.javac.JavacAST.traverseChildren(JavacAST.java:222)
        at lombok.javac.JavacNode.traverse(JavacNode.java:95)
        at lombok.javac.JavacAST.traverseChildren(JavacAST.java:222)
        at lombok.javac.JavacNode.traverse(JavacNode.java:90)
        at lombok.javac.JavacAST.traverse(JavacAST.java:218)
        at lombok.javac.HandlerLibrary.callASTVisitors(HandlerLibrary.java:276)
        at lombok.javac.JavacTransformer.transform(JavacTransformer.java:64)
        at lombok.javac.apt.LombokProcessor.process(LombokProcessor.java:328)
        at lombok.core.AnnotationProcessor$JavacDescriptor.process(AnnotationProcessor.java:187)
        at lombok.core.AnnotationProcessor.process(AnnotationProcessor.java:241)
        at lombok.launch.AnnotationProcessorHider$AnnotationProcessor.process(AnnotationProcessor.java:90)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
        at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
        at com.sun.tools.javac.main.Main.compile(Main.java:523)
        at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
        at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
        at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:126)
        at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:174)
        at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:1134)
        at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:187)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
        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:56)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:972)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:293)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:196)
        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:282)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Lombok visitor handler class lombok.javac.handlers.HandleVal failed: java.lang.NullPointerException
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for yuanluServerDo 1.1.8-SNAPSHOT:
[INFO]
[INFO] yuanluServerDo ..................................... SUCCESS [  0.218 s]
[INFO] yuanluServerDo-common .............................. SUCCESS [  5.050 s]
[INFO] YuanluServerDo Bukkit .............................. SUCCESS [  7.789 s]
[INFO] YuanluServerDo BungeeCord .......................... FAILURE [ 15.781 s]
[INFO] YuanluServerDo Velocity ............................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  28.980 s
[INFO] Finished at: 2022-03-23T20:23:50+08:00
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "dev" could not be activated because it does not exist.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project yuanluServerDo-bungeecord: Compilation failure
[ERROR] Lombok visitor handler class lombok.javac.handlers.HandleVal failed: java.lang.NullPointerException
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :yuanluServerDo-bungeecord

Expected behavior
Correct build

Version info (please complete the following information):

  • Lombok version: 1.18.22
  • Platform: IDEA U 2021.3.3
  • Java: 1.8.0_261
  • Apache Maven 3.8.3
Apache Maven 3.8.3 (ff8e977a158738155dc465c6a97ffaf31982d739)
Maven home: D:\document\development\java\maven\apache-maven-3.8.3
Java version: 1.8.0_171, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk1.8.0_171\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Additional context
old repo
When I used eclipse before, I occasionally encountered the same problem. At that time, there was the same problem with the same file. No matter how I operate, I can't successful build. But without any operation, I can build normally in a week later.
But after switching to the command line or idea, this method fails. I can't build it anymore.

@Rawi01
Copy link
Collaborator

Rawi01 commented Mar 23, 2022

The new repo requires a login

@MineYuanlu
Copy link
Author

The new repo requires a login

https://github.com/MineYuanlu/yuanluServerDo
Sorry, there may be something wrong with that platform.

@Rawi01
Copy link
Collaborator

Rawi01 commented Mar 23, 2022

Thanks, managed to reproduce it

@Rawi01 Rawi01 added bug javac accepted The issue/enhancement is valid, sensible, and explained in sufficient detail labels Mar 23, 2022
@Rawi01 Rawi01 self-assigned this Mar 23, 2022
@Rawi01
Copy link
Collaborator

Rawi01 commented Mar 23, 2022

Simple reproducer:

import java.util.HashMap;
import java.util.Map;

public class ValTest {
	public enum A {
		A {
			void method() {
				lombok.val wa = new ValTest();
				
				for (lombok.val x : new HashMap<String, Long>().entrySet()) {
					lombok.val name = x.getKey();
				}
			}
		}
	}
}

The enum seems to be the problem. I managed to run this example but this reverts the changes for #278 which is probably not a good idea...

@MineYuanlu
Copy link
Author

Oh! Thank you very much. It seems that's the problem. After I replace all the "val" inside the enum with the actual type, I can build it.

But can Lombok fix this problem? Or we can only to avoid the problem by not using this form of code?

图片

@MineYuanlu
Copy link
Author

@Rawi01 Do I need to close this issue?

@rzwitserloot
Copy link
Collaborator

Well, it is a bug. It's not the only one with val. Let's leave it open for now.

@gisrenliang
Copy link

dd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted The issue/enhancement is valid, sensible, and explained in sufficient detail bug javac
Projects
None yet
Development

No branches or pull requests

4 participants