Community
Participate
Working Groups
Eclipse has this problem compiling my AspectJ project: ======= java.lang.NullPointerException at org.aspectj.ajdt.internal.core.builder.AsmHierarchyBuilder.visit(AsmHierarchyBuilder.java:830) at org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldDeclaration.traverse(FieldDeclaration.java:278) at org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1340) at org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitD ... AutoBuildJob.run(AutoBuildJob.java:241) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53) Compile error: NullPointerException thrown: null ========= Clean + rebuild does not help -- the problem always reproduces. Building from Maven (mvn install), everything is fine. The following message appears in the Event Log and may be related: ========= java.lang.NullPointerException at org.aspectj.ajdt.internal.core.builder.AsmHierarchyBuilder.visit(AsmHierarchyBuilder.java:830) at org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldDeclaration.traverse(FieldDeclaration.java:278) at org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1340) at org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:690) at org.aspectj.ajdt.internal.core.builder.AsmHierarchyBuilder.internalBuild(AsmHierarchyBuilder.java:189) at org.aspectj.ajdt.internal.core.builder.AsmHierarchyBuilder.buildStructureForCompilationUnit(AsmHierarchyBuilder.java:132) at org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory.finishedCompilationUnit(EclipseFactory.java:1084) at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.afterProcessing(AjPipeliningCompilerAdapter.java:419) at org.aspectj.ajdt.internal.compiler.CompilerAdapter.ajc$after$org_aspectj_ajdt_internal_compiler_CompilerAdapter$5$6b855184(CompilerAdapter.aj:98) at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:805) at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:468) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:1028) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performBuild(AjBuildManager.java:272) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:185) at org.aspectj.ajde.core.internal.AjdeCoreBuildManager.performBuild(AjdeCoreBuildManager.java:105) at org.aspectj.ajde.core.AjCompiler.buildFresh(AjCompiler.java:100) at org.eclipse.ajdt.core.builder.AJBuilder.build(AJBuilder.java:255) at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:726) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239) at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295) at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351) at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374) at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143) at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53) ====== I'm unable to provide a sample since it's quite a large project.
A maven build doesn't construct the model (doesn't call AsmHierarchyBuilder) so I'd expect things to be OK in maven. The NPE here is in a bit of code handling construction of the model with respect to an enum, one of the elements here leading to the NPE: fieldDeclaration.binding.type.debugName() Without a sample project it'll be tricky to fix properly, the best I could do is guards and perhaps some extra debug that could come out.
I just pushed a new aspectj with debug and a workaround in it into the eclipse 4.2 branch of AJDT. You didn't mention what version of eclipse you were using so I guessed 4.2. It should be in a dev build a bit later today. It *should* get around the problem. If you launch eclipse with a console you may get some debug info to that console referencing the bug which may help with putting in a better fix.
Thanks! The workaround works as expected and my project now builds successfully. Regarding the extra debug info, I ran Eclipse in console but could not see any info there; the only messages printed to the console are a few lines about SLF4J and a "[debug] execute contextualize" line repeating multiple times.
workaround seems fine, closing for now - can revisit if this debug ever triggers.
oops, forget to press the resolved button. done now.