Bug 402832 - NullPointerException in AsmHierarchyBuilder.visit() when building
Summary: NullPointerException in AsmHierarchyBuilder.visit() when building
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X
: P3 blocker (vote)
Target Milestone: 1.7.3   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-10 05:29 EDT by Arie Zilberstein CLA
Modified: 2013-06-26 14:15 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arie Zilberstein CLA 2013-03-10 05:29:28 EDT
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.
Comment 1 Andrew Clement CLA 2013-03-11 12:04:31 EDT
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.
Comment 2 Andrew Clement CLA 2013-03-11 13:28:21 EDT
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.
Comment 3 Arie Zilberstein CLA 2013-03-12 03:22:20 EDT
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.
Comment 4 Andrew Clement CLA 2013-06-26 14:15:24 EDT
workaround seems fine, closing for now - can revisit if this debug ever triggers.
Comment 5 Andrew Clement CLA 2013-06-26 14:15:41 EDT
oops, forget to press the resolved button. done now.