]> source.dussan.org Git - aspectj.git/commitdiff
@DeclareAnnotation and guard to not use it in M3, doc update for M3
authoravasseur <avasseur>
Mon, 18 Jul 2005 09:26:20 +0000 (09:26 +0000)
committeravasseur <avasseur>
Mon, 18 Jul 2005 09:26:20 +0000 (09:26 +0000)
aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareAnnotation.java [new file with mode: 0644]
docs/adk15ProgGuideDB/ataspectj.xml
docs/adk15ProgGuideDB/ltw.xml
tests/java5/ataspectj/ataspectj/SingletonAspectBindingsTest.java
tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjSyntaxTests.java
weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java

diff --git a/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareAnnotation.java b/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareAnnotation.java
new file mode 100644 (file)
index 0000000..ffecb91
--- /dev/null
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://eclipse.org/legal/epl-v10.html 
+ * 
+ * Contributors:
+ *   Alexandre Vasseur         initial implementation
+ *******************************************************************************/
+package org.aspectj.lang.annotation;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+/**
+ * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
+public @interface DeclareAnnotation {
+
+    /**
+     * pointcut (type pattern for type, or method/ctor/field signature pattern)
+     */
+    public String value();
+    
+}
index 37e48de06c3cf1c47cbdbccdae9f77136ccc79bf..717d5edb95596ced19d0d24bc04a2f9eb2b0b400 100644 (file)
      }
          ]]></programlisting>
 
+        <para>
+            Note: Declare annotation is not available in AspectJ 1.5 M3 and syntax might change
+            when it will be available.
+        </para>
+
         <para>We also support annotation style declarations for declare warning and
      declare error - any corresponding warnings and errors will be emitted at
      weave time, not when the aspects containing the declarations are compiled.
index e822a5d20561d196bbd5da4037216905d4fff213..05aef43f6a50c224ffcfec49e5a21641bfcb8908 100644 (file)
                 auxiliary aspects where the pointcut definitions themselves can be
                 considered part of the configuration of the service.
             </para>
-            
+
+            <para>
+                Note: concrete-aspect is not available in AspectJ 1.5 M3.
+            </para>
+
             <para>
                 The aspects element may optionally contain one or more include and
                 exclude elements (by default, all defined aspects are used for weaving).
index d94d2af0a607b4c0d80687f0d5325eb55190e3a2..c141e95b2326f1dcfacef1d3151eb5f6587c80d9 100644 (file)
  *******************************************************************************/
 package ataspectj;
 
-import org.aspectj.lang.annotation.Before;
-import org.aspectj.lang.annotation.Aspect;
-import org.aspectj.lang.annotation.After;
-import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.*;
 import org.aspectj.lang.JoinPoint;
 import org.aspectj.lang.ProceedingJoinPoint;
 import junit.framework.TestCase;
 
-import java.io.File;
-import java.io.FileReader;
-
 /**
  * Test various advice and JoinPoint + binding, without pc ref
  *
index 8d38130214284a2efdbb509aceebad9fc9c769c6..0560e2fb5926c0f7c067f7e88798bf9e1382d566 100644 (file)
@@ -41,11 +41,11 @@ public class AtAjSyntaxTests extends XMLBasedAjcTestCase {
 
     public void testSingletonAspectBindings() {
         //Note AV: uncomment setReporting to get it in modules/tests folder
-        //org.aspectj.asm.AsmManager.setReporting("debug.txt",true,true,true,true);
+        org.aspectj.asm.AsmManager.setReporting("debug.txt",true,true,true,true);
         runTest("singletonAspectBindings");
         // same stuff with AJ
         //org.aspectj.asm.AsmManager.setReporting("debug-aj.txt",true,true,true,true);
-        runTest("singletonAspectBindings2");
+        //runTest("singletonAspectBindings2");
 
     }
 
index a7cc76df9d6170633409ab1840a577f54ca67ad9..7f752210a2defa440273175f57fb85160796e42c 100644 (file)
@@ -17,31 +17,18 @@ import java.util.Comparator;
 import java.util.Iterator;
 import java.util.List;
 
-import org.aspectj.apache.bcel.classfile.Attribute;
-import org.aspectj.apache.bcel.classfile.Field;
-import org.aspectj.apache.bcel.classfile.JavaClass;
-import org.aspectj.apache.bcel.classfile.LocalVariable;
-import org.aspectj.apache.bcel.classfile.LocalVariableTable;
-import org.aspectj.apache.bcel.classfile.Method;
+import org.aspectj.apache.bcel.classfile.*;
 import org.aspectj.apache.bcel.classfile.annotation.Annotation;
 import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePair;
 import org.aspectj.apache.bcel.classfile.annotation.RuntimeAnnotations;
 import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleAnnotations;
 import org.aspectj.apache.bcel.generic.Type;
+import org.aspectj.apache.bcel.Constants;
 import org.aspectj.bridge.IMessage;
 import org.aspectj.bridge.IMessageHandler;
 import org.aspectj.bridge.ISourceLocation;
 import org.aspectj.bridge.Message;
-import org.aspectj.weaver.Advice;
-import org.aspectj.weaver.AdviceKind;
-import org.aspectj.weaver.AjAttribute;
-import org.aspectj.weaver.AjcMemberMaker;
-import org.aspectj.weaver.IHasPosition;
-import org.aspectj.weaver.ISourceContext;
-import org.aspectj.weaver.NameMangler;
-import org.aspectj.weaver.ResolvedPointcutDefinition;
-import org.aspectj.weaver.ResolvedType;
-import org.aspectj.weaver.UnresolvedType;
+import org.aspectj.weaver.*;
 import org.aspectj.weaver.patterns.AndPointcut;
 import org.aspectj.weaver.patterns.DeclareErrorOrWarning;
 import org.aspectj.weaver.patterns.DeclarePrecedence;
@@ -171,7 +158,33 @@ public class AtAjAttributes {
      * @param msgHandler
      * @return list of AjAttributes
      */
-    public static List readAj5ClassAttributes(JavaClass javaClass, ResolvedType type, ISourceContext context, IMessageHandler msgHandler, boolean isCodeStyleAspect) {
+    public static List readAj5ClassAttributes(JavaClass javaClass, ReferenceType type, ISourceContext context, IMessageHandler msgHandler, boolean isCodeStyleAspect) {
+        //FIXME AV - 1.5 M3 feature limitation, kick after M3 ships
+        try {
+            Constant[] cpool = javaClass.getConstantPool().getConstantPool();
+            for (int i = 0; i < cpool.length; i++) {
+                Constant constant = cpool[i];
+                if (constant != null && constant.getTag() == Constants.CONSTANT_Utf8) {
+                    if (!javaClass.getClassName().startsWith("org.aspectj.lang.annotation")) {
+                        ConstantUtf8 constantUtf8 = (ConstantUtf8) constant;
+                        if ("Lorg/aspectj/lang/annotation/DeclareAnnotation;".equals(constantUtf8.getBytes())) {
+                            msgHandler.handleMessage(
+                                    new Message(
+                                            "Found @DeclareAnnotation while current release does not support it (see '" + type.getName() + "')",
+                                            IMessage.WARNING,
+                                            null,
+                                            type.getSourceLocation()
+                                    )
+                            );
+                        }
+                    }
+                }
+            }
+        } catch (Throwable t) {
+            ;
+        }
+
+
         AjAttributeStruct struct = new AjAttributeStruct(type, context, msgHandler);
         Attribute[] attributes = javaClass.getAttributes();
         boolean hasAtAspectAnnotation = false;