]> source.dussan.org Git - aspectj.git/commitdiff
537825: Remove FINAL for cflow related class elements for Java 9+
authorAndy Clement <aclement@pivotal.io>
Sat, 25 Aug 2018 00:49:44 +0000 (17:49 -0700)
committerAndy Clement <aclement@pivotal.io>
Sat, 25 Aug 2018 00:57:36 +0000 (17:57 -0700)
org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java
org.aspectj.matcher/src/org/aspectj/weaver/patterns/CflowPointcut.java
org.aspectj.matcher/src/org/aspectj/weaver/patterns/PerCflow.java
tests/src/org/aspectj/systemtest/ajc192/Ajc192Tests.java
tests/src/org/aspectj/systemtest/ajc192/ajc192.xml
tests/src/org/aspectj/systemtest/apt/AptTests.java

index 1870eb5019726c302826da60302c100e028d20d6..b8e3043c5dadf51c5dc4f09c94894b3e50a4f538 100644 (file)
@@ -9,13 +9,10 @@
  * Contributors: 
  *     PARC     initial implementation 
  * ******************************************************************/
-
 package org.aspectj.weaver;
 
 import java.lang.reflect.Modifier;
 
-//import org.aspectj.weaver.ResolvedType.Name;
-
 /**
  * The AjcMemberMaker is responsible for creating the representations of methods/fields/etc that are placed in both aspects and
  * affected target types. It uses the NameMangler class to create the actual names that will be used.
@@ -69,7 +66,7 @@ public class AjcMemberMaker {
        }
 
        public static ResolvedMember perCflowField(UnresolvedType declaringType) {
-               return new ResolvedMemberImpl(Member.FIELD, declaringType, PUBLIC_STATIC_FINAL, NameMangler.PERCFLOW_FIELD_NAME,
+               return new ResolvedMemberImpl(Member.FIELD, declaringType, PUBLIC_STATIC, NameMangler.PERCFLOW_FIELD_NAME,
                                CFLOW_STACK_TYPE.getSignature());
        }
 
index ed66dc0d535c1f4b7acdb805d630965a634158f1..a83236e5cdd5ca047bc8bc81af1540669fd41434 100644 (file)
@@ -64,9 +64,6 @@ public class CflowPointcut extends Pointcut {
                pointcutKind = CFLOW;
        }
 
-       /**
-        * @return Returns true is this is a cflowbelow pointcut
-        */
        public boolean isCflowBelow() {
                return isBelow;
        }
@@ -230,8 +227,8 @@ public class CflowPointcut extends Pointcut {
                        } else {
 
                                // Create a counter field in the aspect
-                               localCflowField = new ResolvedMemberImpl(Member.FIELD, concreteAspect, Modifier.STATIC | Modifier.PUBLIC
-                                               | Modifier.FINAL, NameMangler.cflowCounter(xcut), UnresolvedType.forName(NameMangler.CFLOW_COUNTER_TYPE)
+                               localCflowField = new ResolvedMemberImpl(Member.FIELD, concreteAspect, Modifier.STATIC | Modifier.PUBLIC,
+                                               NameMangler.cflowCounter(xcut), UnresolvedType.forName(NameMangler.CFLOW_COUNTER_TYPE)
                                                .getSignature());
 
                                // Create type munger to add field to the aspect
@@ -294,8 +291,8 @@ public class CflowPointcut extends Pointcut {
                                localCflowField = (ResolvedMember) field;
                        } else {
 
-                               localCflowField = new ResolvedMemberImpl(Member.FIELD, concreteAspect, Modifier.STATIC | Modifier.PUBLIC
-                                               | Modifier.FINAL, NameMangler.cflowStack(xcut), UnresolvedType.forName(NameMangler.CFLOW_STACK_TYPE)
+                               localCflowField = new ResolvedMemberImpl(Member.FIELD, concreteAspect, Modifier.STATIC | Modifier.PUBLIC,
+                                               NameMangler.cflowStack(xcut), UnresolvedType.forName(NameMangler.CFLOW_STACK_TYPE)
                                                .getSignature());
                                // System.out.println("adding field to: " + inAspect + " field "
                                // + cflowField);
index 901c494a6d0cba721528b2598cbdcfac782fa554..1ad834e060ed7dc8d83cb77bd3a90440a75bade9 100644 (file)
@@ -88,7 +88,7 @@ public class PerCflow extends PerClause {
                        return ret;
                }
 
-               Member cflowStackField = new ResolvedMemberImpl(Member.FIELD, inAspect, Modifier.STATIC | Modifier.PUBLIC | Modifier.FINAL,
+               Member cflowStackField = new ResolvedMemberImpl(Member.FIELD, inAspect, Modifier.PUBLIC | Modifier.STATIC,
                                UnresolvedType.forName(NameMangler.CFLOW_STACK_TYPE), NameMangler.PERCFLOW_FIELD_NAME, UnresolvedType.NONE);
 
                World world = inAspect.getWorld();
index 989d74b2dcd12f4cd4aa4481d1bc23a96327f3db..0629294dbdd802db6495574a8c69fd8cd713d672 100644 (file)
@@ -21,6 +21,18 @@ import junit.framework.Test;
  */
 public class Ajc192Tests extends XMLBasedAjcTestCase {
 
+       public void testCflowFinal() {
+               runTest("no final on cflow elements");
+       }
+       
+       public void testAroundAdvice_AnnoStyle() {
+               runTest("around advice");
+       }
+
+       public void testAroundAdvice_CodeStyle() {
+               runTest("around advice - 2");
+       }
+
        public void testPTW_nonPrivileged() {
                runTest("ptw");
        }
index 13e0ae9c1021578760546f4b9e29f80e10fdb53c..5eb7fcbbb630a5eac13e084caf0b3d60bbd1ed66 100644 (file)
@@ -2,6 +2,43 @@
 
 <suite>
 
+  <ajc-test dir="bugs192/537825" title="no final on cflow elements">
+    <compile files="Code.java" options="-9">
+    </compile>
+    <run class="Code">
+    <stdout>
+    <line text="call(void B.methodB())"/>
+    <line text="staticinitialization(B.&lt;clinit&gt;)"/>
+    <line text="execution(void B.methodB())"/>
+    <line text="call(void C.methodC())"/>
+    <line text="staticinitialization(C.&lt;clinit&gt;)"/>
+    <line text="execution(void C.methodC())"/>
+    <line text="call(void D.methodD())"/>
+    <line text="staticinitialization(D.&lt;clinit&gt;)"/>
+    <line text="execution(void D.methodD())"/>
+    <line text="get(PrintStream java.lang.System.out)"/>
+    <line text="call(void java.io.PrintStream.println(int))"/>
+    <line text="3"/>
+    </stdout>
+    </run>
+  </ajc-test>
+  
+  <ajc-test dir="bugs192/535156" title="around advice">
+    <compile files="DemoApp.java" options="-8 -showWeaveInfo">
+    <message kind="weave" text="Join point 'method-call(void DemoApp.say())' in Type 'DemoApp' (DemoApp.java:6) advised by around advice from 'X' (DemoApp.java:14)"/>
+       </compile>
+       <run class="DemoApp">
+       </run>
+  </ajc-test>
+  
+  <ajc-test dir="bugs192/535156" title="around advice - 2">
+    <compile files="DemoApp2.java" options="-8 -showWeaveInfo">
+    <message kind="weave" text="Join point 'method-call(void DemoApp2.say())' in Type 'DemoApp2' (DemoApp2.java:6) advised by around advice from 'X' (DemoApp2.java:13)"/>
+       </compile>
+       <run class="DemoApp2">
+       </run>
+  </ajc-test>
+  
   <ajc-test dir="bugs192/ptw" title="ptw">
     <compile files="a/b/c/Code.java a/b/d/Foo.java" options="-8">
        </compile>
index bf9c539169f4451b2cde92b1147d3524efdebe4c..14de6b12fba0265d4ea1a7e51bb59b71dccfddde 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2014 Contributors
+ * Copyright (c) 2014,2018 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
  *******************************************************************************/
 package org.aspectj.systemtest.apt;
 
-import junit.framework.Test;
-import org.aspectj.apache.bcel.classfile.Method;
+import java.io.File;
+
 import org.aspectj.testing.XMLBasedAjcTestCase;
 import org.aspectj.util.LangUtil;
 
-import java.io.File;
+import junit.framework.Test;
 
 /**
  * Annotation processing tool tests.