Bug 108245 - NullPointerException for wildcard annotation type pattern match
Summary: NullPointerException for wildcard annotation type pattern match
Status: RESOLVED WORKSFORME
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 1.5.0RC1   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-29 03:26 EDT by Mohan Radhakrishnan CLA
Modified: 2005-10-28 09:26 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 Mohan Radhakrishnan CLA 2005-08-29 03:26:12 EDT
I declare a Java bean like this.

package com.blueprint.util.mixin.test;

import java.io.Serializable;

public class Bean implements Serializable{
	
	private String name;

	public String getName() {
		return name;
	}
	public void setName( String name ) {
		this.name = name;
	}
}

My aspect has a pointcut like this.

pointcut callSetter( Bean b ) 
	    : call( @propertyChanger * *(..) ) && target( b );

I am using the full compilation feature. So whenever it compiles I see a popup
that shows
--------------------------------------------------
NullPointerException thrown:null
Reason
NullPointerException thrown:null
--------------------------------------------------

The trace is 

!ENTRY org.eclipse.ajdt.ui 4 0 2005-08-29 12:51:26.445
!MESSAGE NullPointerException thrown: null
!STACK 0
java.lang.NullPointerException
	at org.aspectj.weaver.patterns.WildAnnotationTypePattern.matches
(WildAnnotationTypePattern.java:61)
	at org.aspectj.weaver.patterns.SignaturePattern.matchesAnnotations
(SignaturePattern.java:326)
	at org.aspectj.weaver.patterns.SignaturePattern.matchesExactly
(SignaturePattern.java:179)
	at org.aspectj.weaver.patterns.SignaturePattern.matches
(SignaturePattern.java:152)
	at org.aspectj.weaver.patterns.KindedPointcut.matchInternal
(KindedPointcut.java:111)
	at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:151)
	at org.aspectj.weaver.patterns.AndPointcut.matchInternal
(AndPointcut.java:61)
	at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:151)
	at org.aspectj.weaver.patterns.AndPointcut.matchInternal
(AndPointcut.java:61)
	at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:151)
	at org.aspectj.weaver.ShadowMunger.match(ShadowMunger.java:62)
	at org.aspectj.weaver.Advice.match(Advice.java:101)
	at org.aspectj.weaver.bcel.BcelClassWeaver.match
(BcelClassWeaver.java:1724)
	at org.aspectj.weaver.bcel.BcelClassWeaver.matchInvokeInstruction
(BcelClassWeaver.java:1713)
	at org.aspectj.weaver.bcel.BcelClassWeaver.match
(BcelClassWeaver.java:1526)
	at org.aspectj.weaver.bcel.BcelClassWeaver.match
(BcelClassWeaver.java:1355)
	at org.aspectj.weaver.bcel.BcelClassWeaver.weave
(BcelClassWeaver.java:381)
	at org.aspectj.weaver.bcel.BcelClassWeaver.weave
(BcelClassWeaver.java:96)
	at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1368)
	at org.aspectj.weaver.bcel.BcelWeaver.weaveWithoutDump
(BcelWeaver.java:1333)
	at org.aspectj.weaver.bcel.BcelWeaver.weaveAndNotify
(BcelWeaver.java:1110)
	at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:997)
	at org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.weave
(AjCompilerAdapter.java:286)
	at org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.afterCompiling
(AjCompilerAdapter.java:165)
	at 
org.aspectj.ajdt.internal.compiler.CompilerAdapter.ajc$afterReturning$org_aspec
tj_ajdt_internal_compiler_CompilerAdapter$2$f9cc9ca0(CompilerAdapter.aj:70)
	at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile
(Compiler.java:367)
	at 
org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation
(AjBuildManager.java:728)
	at org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild
(AjBuildManager.java:206)
	at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild
(AjBuildManager.java:140)
	at org.aspectj.ajde.internal.CompilerAdapter.compile
(CompilerAdapter.java:121)
	at org.aspectj.ajde.internal.AspectJBuildManager$CompilerThread.run
(AspectJBuildManager.java:191)

In another package I have the following files.

package com.blueprint.util.aspectj5.test;

import java.io.Serializable;
@javaBean()
public class Bean implements Serializable{
		
		private String name;

		public String getName() {
			return name;
		}
		@propertyChanger()
		public void setName( String name ) {
			this.name = name;
		}
}

My annotation is 

package com.blueprint.util.aspectj5.test;

import java.lang.annotation.*;
import java.lang.*;
@Retention( RetentionPolicy.RUNTIME )
@Target({ ElementType.METHOD })
public @interface propertyChanger {
}
Comment 1 Mohan Radhakrishnan CLA 2005-08-29 03:28:32 EDT
Clarification.

The first bean and the aspect with the pointcut shown are both in the same 
package.

The second bean and the annotation are in a different package.
Comment 2 Matt Chapman CLA 2005-08-29 07:08:56 EDT
Passing over to the compiler
Comment 3 Adrian Colyer CLA 2005-08-30 06:40:19 EDT
There's definitely a bug lurking here, but I couldn't reproduce it yet from the
information provided so far. The pointcut you've given in the snippet should
compile to a pointcut with an *ExactAnnotationTypePattern* (which it does for
me), but in your stack trace you have a *WildAnnotationTypePattern*. I tried a
variant in which the propertyChanger annotation was not visible to the aspect,
but this just gave the expected type not found message. 

Could you please attach the full source of your aspect if possible? Also, do you
have any other pointcuts or advice in your application that are working with
annotations? Is it possible one of these is the culprit?  If you could attach a
self-contained zip with all files needed to reproduce that would be absolutely
fantastic, otherwise we can continue the detective work as is....

Thanks, Adrian.
Comment 4 Mohan Radhakrishnan CLA 2005-08-31 10:17:30 EDT
I tried to repeat this but somehow my original configuration is lost. Actually 
when I moved everything to the same package I didn't see this bug.
Comment 5 Andrew Clement CLA 2005-10-28 09:26:59 EDT
cant reproduce on our side - but given all the compiler changes, it might have
been resolved.  Please reopen if it happens again.