diff options
7 files changed, 39 insertions, 3 deletions
diff --git a/tests/java5/annotations/binding/usingPackageNames/MyAnnotation.java b/tests/java5/annotations/binding/usingPackageNames/MyAnnotation.java new file mode 100644 index 000000000..1e6dcbd31 --- /dev/null +++ b/tests/java5/annotations/binding/usingPackageNames/MyAnnotation.java @@ -0,0 +1,6 @@ +package test; +import java.lang.annotation.*; + +@Retention(RetentionPolicy.RUNTIME) +public @interface MyAnnotation {} + diff --git a/tests/java5/annotations/binding/usingPackageNames/MyAspect.aj b/tests/java5/annotations/binding/usingPackageNames/MyAspect.aj new file mode 100644 index 000000000..41fda5537 --- /dev/null +++ b/tests/java5/annotations/binding/usingPackageNames/MyAspect.aj @@ -0,0 +1,8 @@ +package test;
+
+public aspect MyAspect {
+ after(test.MyAnnotation ma) : set (public String test.MyClass._myField) && @target(ma){
+ System.err.println("pointcut matching : " + ma);
+ }
+}
+
diff --git a/tests/java5/annotations/binding/usingPackageNames/MyClass.java b/tests/java5/annotations/binding/usingPackageNames/MyClass.java new file mode 100644 index 000000000..6a373d091 --- /dev/null +++ b/tests/java5/annotations/binding/usingPackageNames/MyClass.java @@ -0,0 +1,13 @@ +package test; +@MyAnnotation public class MyClass { + + public String _myField; + + public static void main(String[] args) { + new MyClass().setMyField("test"); + } + + public void setMyField(String nv) { + this._myField = nv; + } +} diff --git a/tests/src/org/aspectj/systemtest/ajc150/AnnotationBinding.java b/tests/src/org/aspectj/systemtest/ajc150/AnnotationBinding.java index 811b0d6b2..61b704667 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/AnnotationBinding.java +++ b/tests/src/org/aspectj/systemtest/ajc150/AnnotationBinding.java @@ -107,6 +107,14 @@ public class AnnotationBinding extends TestUtils { RunResult rR = run("AtTarget4"); } + // @target() with an annotation in a package + public void testAtTargetAnnotationBinding5() { + CompilationResult cR = ajc(new File(baseDir,"usingPackageNames"), + new String[]{"MyAspect.aj","MyAnnotation.java","MyClass.java","-1.5"}); + assertMessages(cR,new EmptyMessageSpec()); + RunResult rR = run("test.MyClass"); + } + ///////////////////////////////////// @THIS diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelRenderer.java b/weaver/src/org/aspectj/weaver/bcel/BcelRenderer.java index 5d8d432e8..553da757e 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelRenderer.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelRenderer.java @@ -186,7 +186,8 @@ public class BcelRenderer implements ITestVisitor, IExprVisitor { Member getClass = Member.method(TypeX.OBJECT, 0, "getClass", "()Ljava/lang/Class;"); il.append(Utility.createInvoke(fact, world, getClass)); // aload annotationClass - il.append(fact.createConstant(new ObjectType(hasAnnotation.getAnnotationType().getClassName()))); + String s = hasAnnotation.getAnnotationType().getName(); + il.append(fact.createConstant(new ObjectType(hasAnnotation.getAnnotationType().getName()))); // int annClassIndex = fact.getConstantPool().addClass(hasAnnotation.getAnnotationType().getSignature()); // il.append(new LDC_W(annClassIndex)); Member isAnnotationPresent = Member.method(TypeX.forName("java/lang/Class"),0, diff --git a/weaver/src/org/aspectj/weaver/bcel/TypeAnnotationAccessVar.java b/weaver/src/org/aspectj/weaver/bcel/TypeAnnotationAccessVar.java index c30e4ba58..3bcac2842 100644 --- a/weaver/src/org/aspectj/weaver/bcel/TypeAnnotationAccessVar.java +++ b/weaver/src/org/aspectj/weaver/bcel/TypeAnnotationAccessVar.java @@ -61,7 +61,7 @@ public class TypeAnnotationAccessVar extends BcelVar { Type jlaAnnotation = BcelWorld.makeBcelType(TypeX.forSignature("Ljava.lang.annotation.Annotation;")); il.append(target.createLoad(fact)); il.append(fact.createInvoke("java/lang/Object","getClass",jlClass,new Type[]{},Constants.INVOKEVIRTUAL)); - il.append(fact.createConstant(new ObjectType(toType.getClassName()))); + il.append(fact.createConstant(new ObjectType(toType.getName()))); il.append(fact.createInvoke("java/lang/Class","getAnnotation",jlaAnnotation,new Type[]{jlClass},Constants.INVOKEVIRTUAL)); il.append(Utility.createConversion(fact,jlaAnnotation,BcelWorld.makeBcelType(toType))); return il; diff --git a/weaver/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java index 64dac28ff..23a36e84d 100644 --- a/weaver/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java @@ -118,7 +118,7 @@ public class ExactAnnotationTypePattern extends AnnotationTypePattern { } else { // Non binding case - String cleanname = annotationType.getClassName(); + String cleanname = annotationType.getName(); annotationType = scope.getWorld().resolve(annotationType,true); // We may not have found it if it is in a package, lets look it up... |