]> source.dussan.org Git - aspectj.git/commitdiff
266165: if(enabled) where enabled is constant boolean is optimized
authoraclement <aclement>
Wed, 25 Feb 2009 20:11:16 +0000 (20:11 +0000)
committeraclement <aclement>
Wed, 25 Feb 2009 20:11:16 +0000 (20:11 +0000)
tests/bugs164/pr266165/AlwaysWeave.java [new file with mode: 0644]
tests/bugs164/pr266165/AlwaysWeave2.java [new file with mode: 0644]
tests/bugs164/pr266165/NeverWeave.java [new file with mode: 0644]
tests/bugs164/pr266165/NeverWeave2.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc164/Ajc164Tests.java
tests/src/org/aspectj/systemtest/ajc164/ajc164.xml

diff --git a/tests/bugs164/pr266165/AlwaysWeave.java b/tests/bugs164/pr266165/AlwaysWeave.java
new file mode 100644 (file)
index 0000000..2e8ba65
--- /dev/null
@@ -0,0 +1,11 @@
+aspect A {
+
+  public static final boolean enabled = true;
+
+  before(): execution(* AlwaysWeave.*(..)) && if(enabled) {}
+
+}
+
+public class AlwaysWeave {
+  public void foo() {}
+}
diff --git a/tests/bugs164/pr266165/AlwaysWeave2.java b/tests/bugs164/pr266165/AlwaysWeave2.java
new file mode 100644 (file)
index 0000000..3c158f5
--- /dev/null
@@ -0,0 +1,10 @@
+aspect A {
+
+
+  before(): execution(* AlwaysWeave2.*(..)) && if(true) {}
+
+}
+
+public class AlwaysWeave2 {
+  public void foo() {}
+}
diff --git a/tests/bugs164/pr266165/NeverWeave.java b/tests/bugs164/pr266165/NeverWeave.java
new file mode 100644 (file)
index 0000000..85f5bbc
--- /dev/null
@@ -0,0 +1,11 @@
+aspect A {
+
+  public static final boolean enabled = false;
+
+  before(): execution(* NeverWeave.*(..)) && if(enabled) {}
+
+}
+
+public class NeverWeave {
+  public void foo() {}
+}
diff --git a/tests/bugs164/pr266165/NeverWeave2.java b/tests/bugs164/pr266165/NeverWeave2.java
new file mode 100644 (file)
index 0000000..4b77a1b
--- /dev/null
@@ -0,0 +1,9 @@
+aspect A {
+
+  before(): execution(* NeverWeave2.*(..)) && if(false) {}
+
+}
+
+public class NeverWeave2 {
+  public void foo() {}
+}
index 6e6542370c30f10c56d2c75843a75c4e70c1fe2b..674700f6d4438cd03ff114d30401fc3c86b1d76f 100644 (file)
@@ -32,6 +32,22 @@ import org.aspectj.testing.XMLBasedAjcTestCase;
 
 public class Ajc164Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
 
+       public void testOptimizingIf_pr266165_1() {
+               runTest("optimizing if for constant reference - 1");
+       }
+
+       public void testOptimizingIf_pr266165_2() {
+               runTest("optimizing if for constant reference - 2");
+       }
+
+       public void testOptimizingIf_pr266165_3() {
+               runTest("optimizing if for constant reference - 3");
+       }
+
+       public void testOptimizingIf_pr266165_4() {
+               runTest("optimizing if for constant reference - 4");
+       }
+
        // public void testAnnoInherited_pr265695() {
        // runTest("anno inherited");
        // }
index c2a62e69fdc0da1c2f5a195828ea646ef28bbda1..29bb149d824bbd7f525764e8265461373baeb5c3 100644 (file)
@@ -1,6 +1,26 @@
 <!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]>
 
 <suite>
+   
+   <ajc-test dir="bugs164/pr266165" title="optimizing if for constant reference - 1">
+     <compile files="NeverWeave.java" options="-1.5 -Xlint:ignore -showWeaveInfo"/>
+   </ajc-test>
+   
+   <ajc-test dir="bugs164/pr266165" title="optimizing if for constant reference - 2">
+     <compile files="AlwaysWeave.java" options="-1.5 -showWeaveInfo">
+       <message kind="weave" text="Join point"/>
+     </compile>
+   </ajc-test>
+   
+   <ajc-test dir="bugs164/pr266165" title="optimizing if for constant reference - 3">
+     <compile files="NeverWeave2.java" options="-1.5 -Xlint:ignore -showWeaveInfo"/>
+   </ajc-test>
+   
+   <ajc-test dir="bugs164/pr266165" title="optimizing if for constant reference - 4">
+     <compile files="AlwaysWeave2.java" options="-1.5 -showWeaveInfo">
+       <message kind="weave" text="Join point"/>
+     </compile>
+   </ajc-test>
 
    <ajc-test dir="bugs164/pr265695" title="anno inherited">
      <compile files="Asp.aj" options="-showWeaveInfo -1.5">