From: Andy Clement Date: Thu, 6 Aug 2015 20:53:56 +0000 (-0700) Subject: Support annotation conversion for class annotation values X-Git-Tag: V1_8_7~10 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7a61a0d50d7371ef0a8e9904e8da7e93922fe8e4;p=aspectj.git Support annotation conversion for class annotation values Issue: https://bugs.eclipse.org/bugs/show_bug.cgi?id=474165 --- diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseAnnotationConvertor.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseAnnotationConvertor.java index efd2a152a..47c56f939 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseAnnotationConvertor.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseAnnotationConvertor.java @@ -14,6 +14,7 @@ package org.aspectj.ajdt.internal.compiler.lookup; import org.aspectj.apache.bcel.classfile.annotation.ElementValue; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayInitializer; +import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MemberValuePair; @@ -33,6 +34,7 @@ import org.aspectj.weaver.AnnotationAJ; import org.aspectj.weaver.AnnotationNameValuePair; import org.aspectj.weaver.AnnotationValue; import org.aspectj.weaver.ArrayAnnotationValue; +import org.aspectj.weaver.ClassAnnotationValue; import org.aspectj.weaver.EnumAnnotationValue; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.SimpleAnnotationValue; @@ -218,24 +220,14 @@ public class EclipseAnnotationConvertor { } } else { // class type + if (defaultValue instanceof ClassLiteralAccess) { + ClassLiteralAccess cla = (ClassLiteralAccess)defaultValue; + ClassAnnotationValue cav = new ClassAnnotationValue(new String(cla.targetType.signature())); + return cav; + } throw new MissingImplementationException( "Please raise an AspectJ bug. AspectJ does not know how to convert this annotation value [" + defaultValue + "]"); - // if (contentsOffset + 3 >= this.contents.length) { - // resizeContents(3); - // } - // contents[contentsOffset++] = (byte) 'c'; - // if (defaultValue instanceof ClassLiteralAccess) { - // ClassLiteralAccess classLiteralAccess = (ClassLiteralAccess) - // defaultValue; - // final int classInfoIndex = - // constantPool.literalIndex(classLiteralAccess - // .targetType.signature()); - // contents[contentsOffset++] = (byte) (classInfoIndex >> 8); - // contents[contentsOffset++] = (byte) classInfoIndex; - // } else { - // contentsOffset = attributeOffset; - // } } } else { throw new MissingImplementationException( diff --git a/tests/bugs187/474165/B.java b/tests/bugs187/474165/B.java new file mode 100644 index 000000000..7b1bb1950 --- /dev/null +++ b/tests/bugs187/474165/B.java @@ -0,0 +1,20 @@ +// HasMethod with anno value matching + +@interface I { + Class i(); +} +aspect A { + declare parents: hasmethod(@I(i=String.class) * *(..)) implements java.io.Serializable; +} + +public class B { +@I(i=String.class) public void m() {} + public static void main(String []argv) { + B b = new B(); + if (!(b instanceof java.io.Serializable)) throw new IllegalStateException(""); + } +} +class C { +@I(i=Integer.class) public void m() {} +} + diff --git a/tests/src/org/aspectj/systemtest/ajc187/Ajc187Tests.java b/tests/src/org/aspectj/systemtest/ajc187/Ajc187Tests.java index 148317933..4907eeafe 100644 --- a/tests/src/org/aspectj/systemtest/ajc187/Ajc187Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc187/Ajc187Tests.java @@ -24,6 +24,10 @@ import org.aspectj.testing.XMLBasedAjcTestCase; */ public class Ajc187Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + public void testAnnoConversion_474165() throws Exception { + runTest("anno conversion"); + } + public void testLambda_470633() throws Exception { runTest("lambda"); } diff --git a/tests/src/org/aspectj/systemtest/ajc187/ajc187.xml b/tests/src/org/aspectj/systemtest/ajc187/ajc187.xml index 0413c55ef..ccf87e34f 100644 --- a/tests/src/org/aspectj/systemtest/ajc187/ajc187.xml +++ b/tests/src/org/aspectj/systemtest/ajc187/ajc187.xml @@ -19,4 +19,11 @@ + + + + + + +