]> source.dussan.org Git - aspectj.git/commitdiff
Fix 541325 - Support is(AbstractType)
authorAndy Clement <aclement@pivotal.io>
Mon, 19 Nov 2018 17:15:58 +0000 (09:15 -0800)
committerAndy Clement <aclement@pivotal.io>
Mon, 19 Nov 2018 17:15:58 +0000 (09:15 -0800)
org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternParser.java
org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypeCategoryTypePattern.java
tests/bugs193/isAbstractType/Code.java [new file with mode: 0644]
tests/bugs193/isAbstractType/Code2.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc193/Ajc193Tests.java
tests/src/org/aspectj/systemtest/ajc193/ajc193.xml

index 106376aada0a94afeee16d81d8e92dc12147ad68..f3bf0883358c1b3348f84bead6e22dc6e7725a30 100644 (file)
@@ -1066,6 +1066,8 @@ public class PatternParser {
                                typeIsPattern = new TypeCategoryTypePattern(TypeCategoryTypePattern.ANNOTATION);
                        } else if (category.equals("FinalType")) {
                                typeIsPattern = new TypeCategoryTypePattern(TypeCategoryTypePattern.FINAL);
+                       } else if (category.equals("AbstractType")) {
+                               typeIsPattern = new TypeCategoryTypePattern(TypeCategoryTypePattern.ABSTRACT);
                        }
                }
                if (typeIsPattern == null) {
index 72efea400addbbb6d6d95b5698ce30326898dd56..80ffc75561f0fb978c1f0bae633512abead86685 100644 (file)
@@ -42,6 +42,7 @@ public class TypeCategoryTypePattern extends TypePattern {
        public static final int ENUM = 6;
        public static final int ANNOTATION = 7;
        public static final int FINAL = 8;
+       public static final int ABSTRACT = 9;
 
        private int category;
 
@@ -136,6 +137,8 @@ public class TypeCategoryTypePattern extends TypePattern {
                        return type.isAnnotation();
                case FINAL:
                        return Modifier.isFinal(type.getModifiers());
+               case ABSTRACT:
+                       return Modifier.isAbstract(type.getModifiers());
                }
                return false;
        }
diff --git a/tests/bugs193/isAbstractType/Code.java b/tests/bugs193/isAbstractType/Code.java
new file mode 100644 (file)
index 0000000..03790c6
--- /dev/null
@@ -0,0 +1,24 @@
+public class Code {
+  public static void main(String[] argv) {
+    new Code().run();
+  }
+
+  public void run() {
+    new Code3().run();
+  }
+}
+
+abstract class Code2 {
+  public void run() {
+  }
+}
+
+class Code3 extends Code2 {
+}
+
+aspect X {
+  before(): execution(* (!is(AbstractType)).run(..)) {
+    System.out.println(thisJoinPointStaticPart);
+  }
+}
+
diff --git a/tests/bugs193/isAbstractType/Code2.java b/tests/bugs193/isAbstractType/Code2.java
new file mode 100644 (file)
index 0000000..65d8d0d
--- /dev/null
@@ -0,0 +1,24 @@
+public class Code2 {
+  public static void main(String[] argv) {
+    new Code2().run();
+  }
+
+  public void run() {
+    new Helper2().run();
+  }
+}
+
+abstract class Helper {
+  public void run() {
+  }
+}
+
+class Helper2 extends Helper {
+}
+
+aspect X {
+  before(): execution(* (is(AbstractType)).run(..)) {
+    System.out.println(thisJoinPointStaticPart);
+  }
+}
+
index c813de6f380cdf378f22d645a47f051fe59ca45e..c3849c4f0a8ab53067ee38cc0711abaff0550584 100644 (file)
@@ -22,6 +22,14 @@ import junit.framework.Test;
  */
 public class Ajc193Tests extends XMLBasedAjcTestCaseForJava10OrLater {
 
+       public void testIsAbstractType() {
+               runTest("is abstract");
+       }
+
+       public void testIsAbstractType2() {
+               runTest("is abstract - 2");
+       }
+       
        // ---
 
        public static Test suite() {
index b214fe51ff37880e3c19491f5648662de0e5a0d4..3f876abadc3cfe944aaf0d398fe945e73837f147 100644 (file)
@@ -2,6 +2,25 @@
 
 <suite>
 
+
+       <ajc-test dir="bugs193/isAbstractType" title="is abstract">
+       <compile files="Code.java" options="-1.8"/>
+       <run class="Code">
+         <stdout>
+         <line text="execution(void Code.run())"/>
+         </stdout>
+       </run>
+       </ajc-test>
+       
+       <ajc-test dir="bugs193/isAbstractType" title="is abstract - 2">
+       <compile files="Code2.java" options="-1.8"/>
+       <run class="Code2">
+         <stdout>
+         <line text="execution(void Helper.run())"/>
+         </stdout>
+       </run>
+       </ajc-test>
+
 <!-- 
   <ajc-test dir="bugs191/var" title="var 3">
     <compile files="Code3.java" options="-10">