Bug 287315 - NPE using declare @type
Summary: NPE using declare @type
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Windows NT
: P3 normal (vote)
Target Milestone: 1.6.6   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-21 11:30 EDT by Andrew Clement CLA
Modified: 2009-08-24 14:04 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Clement CLA 2009-08-21 11:30:34 EDT
reported by Ramnivas:

java.lang.NullPointerException
        at 
org.aspectj.weaver.bcel.BcelObjectType.hasAnnotation(BcelObjectType.java:558)
        at 
org.aspectj.weaver.ReferenceType.hasAnnotation(ReferenceType.java:161)
        at 
org.aspectj.weaver.patterns.ExactAnnotationTypePattern.matches(ExactAnnotationTypePattern.java:101)
        at 
org.aspectj.weaver.patterns.ExactAnnotationTypePattern.matches(ExactAnnotationTypePattern.java:94)
        at 
org.aspectj.weaver.patterns.AnyWithAnnotationTypePattern.matchesExactly(TypePattern.java:513)
        at 
org.aspectj.weaver.patterns.TypePattern.matchesStatically(TypePattern.java:129)
        at 
org.aspectj.weaver.patterns.DeclareAnnotation.matches(DeclareAnnotation.java:269)
        at 
org.aspectj.weaver.bcel.BcelWeaver.applyDeclareAtType(BcelWeaver.java:1590)
Comment 1 Andrew Clement CLA 2009-08-24 13:31:35 EDT
The problem here is that the weaver is being treated as re-entrant.  On re-entering the weaver we attempt to access the list of annotations on a type which was in the process of being built before we re-entered.  The NPE is due to an array which has yet to have all its elements initialized.

In this case I will fix it by allowing for re-entrancy and performing the check in another way.  This sub-optimal way will only be used whilst in a re-entrant state and once we 'unwind' it will go back to an optimal mechanism.

Comment 2 Andrew Clement CLA 2009-08-24 14:04:51 EDT
fix committed