Bug 269902 - NPE in AsmRelationshipProvider.addRelationship
Summary: NPE in AsmRelationshipProvider.addRelationship
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.6.4   Edit
Hardware: PC Linux-GTK
: P3 normal (vote)
Target Milestone: 1.6.4   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-24 18:39 EDT by Erik Onnen CLA
Modified: 2009-03-27 15:19 EDT (History)
1 user (show)

See Also:


Attachments
Replacement class file (6.21 KB, application/octet-stream)
2009-03-24 19:51 EDT, Andrew Clement CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Erik Onnen CLA 2009-03-24 18:39:30 EDT
When doing a clean build of my project, seeing dozens, upwards of 100 of NPEs similar to the following:

java.lang.NullPointerException
at org.aspectj.weaver.model.AsmRelationshipProvider.addRelationship(AsmRelationshipProvider.java:168)
at org.aspectj.weaver.bcel.BcelTypeMunger.munge(BcelTypeMunger.java:124)
at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:441)
at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:103)
at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1732)
at org.aspectj.weaver.b ...  

FWIW, this is seen for Spring-managed auto-injection of beans with the @Configurable annotation.

Official AJDT version is: 1.6.4.20090304172355
Version: 3.4.2
Build id: M20090211-17
Comment 1 Andrew Clement CLA 2009-03-24 19:06:51 EDT
By some coincidence, I fixed something like this earlier on today - it manifested for me because I had some aspects on my aspectpath that used the same package name as source in my project, but I believe it could also happen if using split packages where source code in two different source folders shares the same package name.  Do you have that situation?

The fix was to AspectJElementHierarchy - to make it continue searching even after finding a match in case there are others. The proposed fix has not made it into an AJDT dev build yet but it should do shortly.  (bug I raised to cover it was bug 269840)
Comment 2 Erik Onnen CLA 2009-03-24 19:35:09 EDT
> By some coincidence, I fixed something like this earlier on today - it
> manifested for me because I had some aspects on my aspectpath that used the
> same package name as source in my project, but I believe it could also happen
> if using split packages where source code in two different source folders
> shares the same package name.  Do you have that situation?
>

I do indeed.
 
> The fix was to AspectJElementHierarchy - to make it continue searching even
> after finding a match in case there are others. The proposed fix has not made
> it into an AJDT dev build yet but it should do shortly.  (bug I raised to cover
> it was bug 269840)
> 

Is there a development plugin build produced automatically somewhere? Or maybe some documentation on how to c/o and compile? Happy to test the fix to see if it applied to my case before I go too deep into the source.

Comment 3 Andrew Clement CLA 2009-03-24 19:44:46 EDT
the ajdt builds are currently failing some tests (my fault).  But let me work out how to give you a patch for this.
Comment 4 Andrew Clement CLA 2009-03-24 19:51:16 EDT
Created attachment 129779 [details]
Replacement class file

This replaces the version in the org.aspectj.weaver plugin.

Shutdown eclipse, go to your eclipse installation folder, then the plugins directory.  Within their go to org.aspectj.weaver_XXX - go into the latest version you have.

backup the weaver jar: 
cp aspectjweaver.jar aspectjweaver.jar.original

apply the patch: 
jar -xvf patch266902.zip
jar -uvf aspectjweaver.jar org

This will replace the .class file in that jar with a build of the latest version from HEAD.  Let me know what happens...
Comment 5 Erik Onnen CLA 2009-03-25 19:04:01 EDT
Thanks for that, unfortunately same NPEs still coming up. Happy to test further or debug if you have a guide on how to debug the compiler.

Comment 6 Andrew Clement CLA 2009-03-25 19:43:33 EDT
i'll look at it next after what I'm working on.  If you have a minimal project that exhibits the problem, that would be great.
Comment 7 Andrew Clement CLA 2009-03-25 19:47:52 EDT
you could try the latest AJDT 1.6.5 dev build that has just been made available.
Comment 8 Erik Onnen CLA 2009-03-25 20:08:57 EDT
(In reply to comment #7)
> you could try the latest AJDT 1.6.5 dev build that has just been made
> available.
> 

Similar error with the dev build, one line difference in the location of the NPE:

java.lang.NullPointerException
at org.aspectj.weaver.model.AsmRelationshipProvider.addRelationship(AsmRelationshipProvider.java:167)
at org.aspectj.weaver.bcel.BcelTypeMunger.munge(BcelTypeMunger.java:124)
at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:441)
at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:103)
at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1735)
at org.aspectj.weaver.b ... 

Comment 9 Andrew Clement CLA 2009-03-25 20:18:19 EDT
ah, it is similar to the npe i fixed but not on exactly the same line, I should have checked.  I suspect it has a similar root cause though, hopefully now I have an up to date stack trace I'll be able to recreate - thanks!
Comment 10 Andrew Clement CLA 2009-03-25 20:28:11 EDT
i've recreated it, yey.
Comment 11 Andrew Clement CLA 2009-03-26 20:24:11 EDT
hmm, well i only managed a recreate by using a broken aspect (that had syntax errors in it).  But anyway - I've put guards in place to prevent the NPE, this change is in todays AJDT dev build that includes AspectJ 1.6.4.20090326115100
Comment 12 Erik Onnen CLA 2009-03-27 15:04:29 EDT
(In reply to comment #11)
> hmm, well i only managed a recreate by using a broken aspect (that had syntax
> errors in it).  But anyway - I've put guards in place to prevent the NPE, this
> change is in todays AJDT dev build that includes AspectJ 1.6.4.20090326115100
> 

That seems to have remove the NPE, thanks. FWIW, all of my advice is applied using annotations and they compile and weave fine with a stand-alone ant task. Entirely possible that something is wrong with them, but it doesn't surface when outside the AJDT context.

I seem to now be encountering 267794 so its hard for me to know if I'm entirely out of the woods yet, but appreciate the help.
Comment 13 Andrew Clement CLA 2009-03-27 15:19:40 EDT
Running with Ant outside of eclipse you aren't building a structure model (which drives the markers/etc in eclipse) - so you don't trigger the codepath that leads to the NPE.

Are you really hitting an OutOfMemory problem?  Please can you comment on that bug with any details if you are...