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

Bug 340323

Summary: NPE when weaving java.lang.Object at org.aspectj.weaver.bcel.BcelTypeMunger.createAnyBridgeMethodsForCovariance(BcelTypeMunger.java:1251)
Product: [Tools] AspectJ Reporter: Owen Stephens <owen>
Component: CompilerAssignee: aspectj inbox <aspectj-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: aclement
Version: 1.6.11   
Target Milestone: 1.6.12   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
AJ core dump
none
Test class
none
Aspect with inter-type declaration causing NPE. none

Description Owen Stephens CLA 2011-03-17 10:34:56 EDT
Created attachment 191423 [details]
AJ core dump

I'm trying to add a method to Object using a inter-type declaration. When calling ajc, I encounter a NPE. From a cursory glance, it would appear that the code is looking for the parents classes of Object, which presumably is null.

I've attached the dump and a simple example that causes it.
Comment 1 Owen Stephens CLA 2011-03-17 10:35:42 EDT
Created attachment 191424 [details]
Test class
Comment 2 Owen Stephens CLA 2011-03-17 10:36:20 EDT
Created attachment 191425 [details]
Aspect with inter-type declaration causing NPE.
Comment 3 Owen Stephens CLA 2011-03-24 09:45:40 EDT
Note that this only happens if the compliance level is set to 1.6 or 1.5. The example test case I gave doesn't require this level, but my original code will not compile without it, since it uses generics.
Comment 4 Owen Stephens CLA 2011-03-25 16:40:52 EDT
I wasn't able to build the sources, but I was able to manually modify the class file, within the jar. I added a null reference check for the createAnyBridgeMethodsForCovariance method, around line 1250 of BcelTypeMunger.java. ajc now compiles the test example correctly.
Comment 5 Andrew Clement CLA 2011-03-28 15:37:46 EDT
Hi,

Sorry I didn't reply sooner.

I've put in the null check, I think I've done the same as you have tried out.  I don't have a test harness for checking weaving against JDK classes so haven't added a regression test.  I've never heard anyone weave into Object like that either, but I guess it is working for you :)

Fix will be in 1.6.12.