Bug 286375 - NullPointerException at org.aspectj.weaver.ReferenceType.getTypeVariables(ReferenceType.java:738)
Summary: NullPointerException at org.aspectj.weaver.ReferenceType.getTypeVariables(Ref...
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.6.5   Edit
Hardware: PC Windows Server 2003
: P3 trivial (vote)
Target Milestone: 1.6.6   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-12 06:25 EDT by Alvin CLA
Modified: 2009-09-04 16:49 EDT (History)
2 users (show)

See Also:


Attachments
aspects causing the exception. (3.96 KB, application/octet-stream)
2009-08-12 06:27 EDT, Alvin CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alvin CLA 2009-08-12 06:25:30 EDT
java.lang.NullPointerException
at org.aspectj.weaver.ReferenceType.getTypeVariables(ReferenceType.java:738)
at org.aspectj.weaver.bcel.BcelGenericSignatureToTypeXConverter.fixUpCircularDependencies(BcelGenericSignatureToTypeXConverter.java:221)
at org.aspectj.weaver.bcel.BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(BcelGenericSignatureToTypeXConverter.java:42)
at org.aspectj.weaver.bcel.BcelObjectType.ensureGenericSignat ... oBuildJob.run(AutoBuildJob.java:238)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

Compile error: NullPointerException thrown: null
Comment 1 Alvin CLA 2009-08-12 06:27:27 EDT
Created attachment 144199 [details]
aspects causing the exception.

Aspects build properly, but exception occurs when added as aspectpath to another project, or during LTW
Comment 2 Alvin CLA 2009-08-12 06:35:04 EDT
Resolved exception. NullPointerException occurred due to the following:

privileged public abstract aspect DatabaseOperationMonitor<T extends AggregatedDatabaseStats<T>> extends BaseOperationMonitor<T> {...

Null pointer occurred due to a circular dependency in generic type T above. Will be good if this is detected and resolved at compile-time instead of at weave-time.
Comment 3 Andrew Clement CLA 2009-09-03 20:13:40 EDT
Can make it happen all on the command line using:

---DatabaseOperationMonitor.java ---
privileged public abstract aspect DatabaseOperationMonitor<T extends AggregatedDatabaseStats<T>> extends BaseOperationMonitor<T> {}
class BaseOperationMonitor<P> {}
class AggregatedDatabaseStats<Q> {}
class Wibble extends AggregatedDatabaseStats<Wibble> {}
aspect Foo extends DatabaseOperationMonitor<Wibble> {}
---

ajc -1.5 DatabaseOperationMonitor.java -d bin
ajc -inpath bin -1.5

This simulates what LTW is doing which is loading the aspect definition from a .class file.

java.lang.NullPointerException
        at org.aspectj.weaver.ReferenceType.getTypeVariables(ReferenceType.java:738)
        at org.aspectj.weaver.bcel.BcelGenericSignatureToTypeXConverter.fixUpCircularDependencies(BcelGenericSignatureToTypeXConvert
er.java:221)
        at org.aspectj.weaver.bcel.BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(BcelGenericSignatureToTypeXConverte
r.java:42)
        at org.aspectj.weaver.bcel.BcelObjectType.ensureGenericSignatureUnpacked(BcelObjectType.java:708)
        at org.aspectj.weaver.bcel.BcelObjectType.getDeclaredInterfaces(BcelObjectType.java:226)
        at org.aspectj.weaver.ReferenceType.getDeclaredInterfaces(ReferenceType.java:569)
        at org.aspectj.weaver.ResolvedType.getDirectSupertypes(ResolvedType.java:66)
Comment 4 Andrew Clement CLA 2009-09-04 16:49:06 EDT
There is nothing wrong with the recursive nature of the definition, but AspectJ doesn't cope with it very well.  I've committed a fix.  It looks like entries were being cached in the world typemap that should never have made it there.  I've added an isCacheable() method to ResolvedType so that some subtypes are not cached (in this case FTPHolder).