Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 349963

Summary: NullPointerException after building the project
Product: [Tools] AJDT Reporter: stefano.dacchille
Component: CoreAssignee: AJDT-inbox <AJDT-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3 CC: aclement, andrew.eisenberg, yuriy.eclipsebugs
Version: 2.1.1   
Target Milestone: 2.2.0   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description stefano.dacchille CLA 2011-06-21 12:41:50 EDT
Almost every time I rebuild my project I get this message:

Errors occurred during the build.
Errors running builder 'AspectJ Builder' on project 'project-name'.
java.lang.NullPointerException

I have the "Build Automatically" option checked, and this happens when I save an AspectJ file. After this message appears the information displayed in the Cross-reference view are gone. This doesn't happen when the project is re-builded after saving a Java file.
Comment 1 Andrew Clement CLA 2011-06-21 13:18:29 EDT
any more information about the NPE in your error log? (Window>Show View>Error Log)
Comment 2 stefano.dacchille CLA 2011-06-22 04:10:06 EDT
Yes, here it is:

Error
Wed Jun 22 10:10:18 CEST 2011
Errors running builder 'AspectJ Builder' on project 'project-name'.

java.lang.NullPointerException
	at org.eclipse.ajdt.core.builder.AJBuilder.postBuild(AJBuilder.java:341)
	at org.eclipse.ajdt.core.builder.AJBuilder.build(AJBuilder.java:270)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:629)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:172)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:203)
	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:255)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:258)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:311)
	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:343)
	at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:144)
	at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:242)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Comment 3 Andrew Eisenberg CLA 2011-06-27 16:37:11 EDT
Is your project using annotation processors?

I can easily add a null check here, but I'd rather figure out why there is a null value being found where we are not expecting.
Comment 4 stefano.dacchille CLA 2011-06-28 03:48:58 EDT
Yes, it is. Please tell me if you need some more info.
Comment 5 Andrew Eisenberg CLA 2011-06-28 13:46:24 EDT
Consider for the 2.2.0 release.
Comment 6 Yuriy CLA 2011-08-14 23:05:29 EDT
I am getting the same exception - same stack trace with only slightly different line numbers in BuildManager.
I am not sure though what you mean by using "annotation processors" ?
google did not come up with anything to enlighten, could you elaborate please?

I am not using annotations in/for aspects but I do have some annotations defined for home-grown serialization they are all @Retention(RetentionPolicy.RUNTIME)
and various :
@Target(ElementType.TYPE) or METHOD OR FIELD

One difference from the original report - I have it happening every single time - I have just imported a whole source tree into a blank project and was unable to have it built even once.

If this was patched I would gladly run a dev build (in fact i just installed it to see if it would make any difference - it didn't).
Comment 7 Yuriy CLA 2011-08-14 23:25:26 EDT
One more thing - after spending some more time with it - it is clear that exception happens when the regardless of ajdt project does not compile i.e. - I have not added all the required jars to the project. 
And as I add them one at the time - the progress % goes further before the NPE.
So maybe the "result" is null because the "java" build failed.
It would not be all that bad if only the "Problems" view showed the errors - as it is - I have to guess.

I is also a guess but I expect the NPE to not happen once the build or at may be the buildpath is complete.
Comment 8 Yuriy CLA 2011-08-15 02:10:11 EDT
Small update

my intuition betrayed my optimism - after fixing all the dependencies the NPE still happens

However, here is one more bit of info:
I've added -debug to eclipse command line and that produced lots of these errors in the error log:

<quote>
eclipse.buildId=I20110613-1736
java.version=1.6.0_26
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Command-line arguments:  -os linux -ws gtk -arch x86_64 -debug -clean

Error
Sun Aug 14 22:40:49 PDT 2011
File outside of project is being compiled: FileName.java
</quote>
This is the complete "Error Details" content.

There are lots of these errors each time build happens, listing many files that are in reality safely asleep very much inside project source directories.

having done some searching - this does not seem to be reported, I have submitted a new bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=354713
Comment 9 Andrew Eisenberg CLA 2011-08-15 13:36:05 EDT
I committed a workaround so that the NPE is avoided, but this will mean that any annotation processors for your project will not be invoked.  Since you say that you are not aware of using an annotation processor, this may not be an issue.

The change will be available in the next dev build on the 3.7 stream.  I will let you know when it is available.  And if you can try it out, can you let me know if this fixes your problem?
Comment 10 Yuriy CLA 2011-08-15 15:20:05 EDT
I will definitely get the updated build and post the result here.
Comment 11 Andrew Eisenberg CLA 2011-08-16 12:39:51 EDT
The new AJDT build for 3.7 is available.  This will bypass the NPE that you were experiencing earlier.
Comment 12 Andrew Eisenberg CLA 2011-11-07 14:59:42 EST
Assuming fixed.