]> source.dussan.org Git - aspectj.git/commitdiff
Adjust 1.6.1 'testRunningBrokenCode_pr102733*' tests ECJ Java 22
authorAlexander Kriegisch <Alexander@Kriegisch.name>
Fri, 22 Mar 2024 17:25:56 +0000 (18:25 +0100)
committerAlexander Kriegisch <Alexander@Kriegisch.name>
Sat, 23 Mar 2024 19:22:39 +0000 (20:22 +0100)
Initially, these tests made sure that an old AJC bug causing
incompatibility to ECJ when using `-proceedOnError` was fixed and there
were no regressions. See also:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=102733

Now with the Java 22 changes for JEP 463 "Implicitly Declared Classes
and Instance Main Methods (Second Preview)" in JDT Core, source code is
parsed into a significantly different AST structure than before, even
when using compiler targets < 22. See also https://openjdk.org/jeps/463.

One test has been temporarily adjusted to the byte code created by
ECJ/AJC now.

TODO: Revert/adjust after this upstream bug has been
fixed:
https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2205
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
tests/bugs161/pr102733/C3.java [new file with mode: 0644]
tests/bugs161/pr102733/Invoker.java
tests/bugs161/pr102733/Invoker3.java [new file with mode: 0644]
tests/src/test/java/org/aspectj/systemtest/ajc161/Ajc161Tests.java
tests/src/test/resources/org/aspectj/systemtest/ajc161/ajc161.xml

diff --git a/tests/bugs161/pr102733/C3.java b/tests/bugs161/pr102733/C3.java
new file mode 100644 (file)
index 0000000..4f8ed16
--- /dev/null
@@ -0,0 +1,6 @@
+
+public class C3 {
+  public static void main(String[] argv) {}
+
+  blahblahpackage pack;
+}
index bfa162de5c7667b0eaca3dd8b113b0ef2781ab25..bc84365cd850ee5237cefd29ede8f53ece3a4867 100644 (file)
@@ -1,14 +1,15 @@
-import java.lang.reflect.Method;
-
 public class Invoker {
-       public static void main(String[] args) throws Throwable {
-               try {
-                       C.main(null);
-               } catch (Throwable t) {
-                       boolean failedCorrectly = t.toString().indexOf("Unresolved compilation")!=-1;
-                       if (failedCorrectly) return;
-                       throw t;
-               }
-               throw new RuntimeException("Call to main should have failed!");
-       }
-}
\ No newline at end of file
+  public static void main(String[] args) throws Throwable {
+    try {
+      new C();
+    }
+    catch (Throwable t) {
+      boolean failedCorrectly =
+        t.toString().contains("Unresolved compilation problem") &&
+          t.toString().contains("The method main cannot be declared static");
+      if (failedCorrectly)
+        return;
+      throw new RuntimeException("Constructor call should have failed!", t);
+    }
+  }
+}
diff --git a/tests/bugs161/pr102733/Invoker3.java b/tests/bugs161/pr102733/Invoker3.java
new file mode 100644 (file)
index 0000000..e7a0d46
--- /dev/null
@@ -0,0 +1,24 @@
+public class Invoker3 {
+  public static void main(String[] args) throws Throwable {
+    try {
+      C3.main(null);
+    }
+    catch (Throwable t) {
+      boolean failedCorrectly = t.toString().indexOf("Unresolved compilation") != -1;
+      if (failedCorrectly)
+        return;
+      throw new RuntimeException("Call to main should have failed!", t);
+    }
+    try {
+      new C3();
+    }
+    catch (Throwable t) {
+      boolean failedCorrectly =
+        t.toString().contains("Unresolved compilation problem") &&
+          t.toString().contains("blahblahpackage cannot be resolved to a type");
+      if (failedCorrectly)
+        return;
+      throw new RuntimeException("Constructor call should have failed!", t);
+    }
+  }
+}
index 5822a3f7ce8f56bd8aa1ed8470e9d88027aa7ba3..11f24c2b17f280ac00200a9aeb4c2a9475e5c8e6 100644 (file)
@@ -54,12 +54,18 @@ public class Ajc161Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
                runTest("ataspectj deow - 2");
        }
 
+       public void testRunningBrokenCode_pr102733() {
+               // TODO: Revert, when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2205 is fixed
+               runTest("running broken code");
+       }
+
        public void testRunningBrokenCode_pr102733_2() {
                runTest("running broken code - 2");
        }
 
-       public void testRunningBrokenCode_pr102733() {
-               runTest("running broken code");
+       public void testRunningBrokenCode_pr102733_3() {
+               // TODO: Adjust as necessary, when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2205 is fixed
+               runTest("running broken code - 3");
        }
 
        public void testErrorOnNonabstractGenericAtAspectJAspect_pr168982() {
index abc3e058eb956d53bac3146806e3fc5039add23a..8a1798b8bcf0644a2ca7e1ce799bed8142fcef83 100644 (file)
        <ajc-test dir="bugs161/pr173978" title="lv table for around">
        <compile files="TestAroundAspect.java Test.java" options="-1.5"/>
     </ajc-test>
-    
+
        <ajc-test dir="bugs161/pr237419" title="generics ataround">
        <compile files="problem/aspect/AnyAspect.java problem/SpecificService.java problem/Specific.java problem/GenericService.java problem/Generic.java" options="-1.5"/>
        <run class="problem.SpecificService"/>
     </ajc-test>
-    
+
        <ajc-test dir="bugs161/pr203367" title="generic marker match">
        <compile files="CantMatchOnInterfaceIntroducedToGenericClass.java" options="-1.5"/>
        <run class="bug.CantMatchOnInterfaceIntroducedToGenericClass"/>
     </ajc-test>
-    
+
        <ajc-test dir="bugs161/pr198196" title="super itds - 2">
        <compile files="Marker.java Foo.java MarkerAspect2.java"/>
        <run class="Foo">
                </stdout>
        </run>
     </ajc-test>
-    
+
        <ajc-test dir="bugs161/pr198196" title="super itds - 3">
        <compile files="Marker.java Foo.java MarkerAspect1.java"/>
        <run class="Foo"/>
     </ajc-test>
-    
+
        <ajc-test dir="bugs161/pr198196" title="super itds - 4">
        <compile files="Marker.java Foo.java MarkerAspect3.java"/>
        <run class="Foo"/>
     </ajc-test>
-    
+
        <ajc-test dir="bugs161/pr134425" title="super itds">
        <compile files="Derived.java Base.java"/>
        <run class="pkg.Derived"/>
     </ajc-test>
-    
+
        <ajc-test dir="bugs161/pr237381" title="ataspectj deow - 1">
        <compile files="Deow1.java" options="-1.5">
          <message kind="warning" line="7" text="fromX"/>
          <message kind="warning" line="15" text="fromY"/>
        </compile>
     </ajc-test>
-    
+
        <ajc-test dir="bugs161/pr237381" title="ataspectj deow - 2">
        <compile files="Deow2.java" options="-1.5">
          <message kind="error" line="7" text="fromX"/>
          <message kind="error" line="15" text="fromY"/>
        </compile>
     </ajc-test>
-    
+
        <ajc-test dir="bugs161/pr102733" title="running broken code">
-       <compile files="Invoker.java C.java" options="-proceedOnError">
-         <message kind="error" line="2" text="Syntax error"/>
+       <compile files="C.java" options="-proceedOnError">
+         <message file="C.java" kind="error" line="1" text="Unnamed Classes and Instance Main Methods"/>
+         <message file="C.java" kind="error" line="2" text="blahblahpackage cannot be resolved to a type"/>
+         <message file="C.java" kind="error" line="2" text="Implicitly declared class must have a candidate main method"/>
+         <message file="C.java" kind="error" line="2" text="The method main cannot be declared static; static methods can only be declared in a static or top level type"/>
        </compile>
+       <compile files="Invoker.java"/>
        <run class="Invoker"/>
     </ajc-test>
-    
+
        <ajc-test dir="bugs161/pr102733" title="running broken code - 2">
        <compile files="Invoker2.java C2.java" options="-proceedOnError">
          <message kind="error" line="5"/>
        </compile>
        <run class="Invoker2"/>
     </ajc-test>
-    
+
+       <ajc-test dir="bugs161/pr102733" title="running broken code - 3">
+       <compile files="C3.java Invoker3.java" options="-proceedOnError">
+         <message file="C3.java" kind="error" line="5" text="blahblahpackage cannot be resolved to a type"/>
+       </compile>
+       <run class="Invoker3"/>
+    </ajc-test>
+
        <ajc-test dir="bugs161/pr168982" title="error on non-abstract generic ataspectj aspect">
        <compile files="TracingAspect2.java" options="-1.5">
          <message kind="error" line="9"/>
        </compile>
     </ajc-test>
-    
+
        <ajc-test dir="bugs161/pr234933" title="ignoring type level suppress">
        <compile files="Foobar.java" options="-1.5 -Xlint:error"/>
     </ajc-test>
-    
+
        <ajc-test dir="bugs161/pr223226" title="duplicate method signature - 2">
        <compile files="AspectX.java BInterface.java FooInterface.java AspectXMarker.java Foo.java Test.java" options="-1.5"/>
        <run class="Test"/>
     </ajc-test>
-    
+
        <ajc-test dir="bugs161/pr223226" title="duplicate method signature">
        <compile files="AspectX.java BInterface.java FooInterface.java AspectXMarker.java Foo.java Test.java" options="">
          <message kind="error" line="1"/>
        <ajc-test dir="bugs161/pr197719" title="protected methods and around advice - again - 2">
        <compile files="test/aspects/C1.java test/aspects/C3.java test/aspects/MyAnn.java test/aspects/MyAnnAspect.java test/aspects2/C2.java" options="-1.5 -showWeaveInfo">
          <message kind="weave" text="Join point 'method-call(void test.aspects.C1.aMethod())' in Type 'test.aspects.C1' (C1.java:12) "/>
-         
+
          <!-- first of these through accessor - so line number wrong and target wrong -->
          <message kind="weave" text="Join point 'method-call(void test.aspects2.C2.aMethod())' in Type 'test.aspects2.C2' (C2.java:1) "/><!-- was line 18 -->
          <message kind="weave" text="Join point 'method-call(void test.aspects2.C2.aMethod())' in Type 'test.aspects2.C2' (C2.java:8) "/>
        <run class="test.aspects.C3">
        </run>
     </ajc-test>
-    
+
        <ajc-test dir="bugs161/pr197719" title="protected methods and around advice - again">
        <compile files="A.java B.java X.java" options="-1.5"/>
        <run class="b.B">
        <compile files="A.java B.java C.java X.java" options="-1.5"/>
        <run class="a.C"/>
     </ajc-test>
-    
+
        <ajc-test dir="bugs161/pr174385" title="static strings in annotation pointcuts">
        <compile files="StaticFinalStringInPointcutAspect.java" options="-1.5"/>
        <run class="bug.StaticFinalStringInPointcutAspect"/>
     </ajc-test>
-    
+
     <ajc-test dir="bugs161/pr199130" title="complex bounds on generic aspect - 1">
        <compile files="Simple.java" options="-1.5"/>
        <run class="Simple">
        </run>
     </ajc-test>
-    
+
        <ajc-test dir="bugs161/pr199130" title="complex bounds on generic aspect - 2">
        <compile files="Complex.java" options="-1.5"/>
        <run class="Complex">
        </run>
     </ajc-test>
-    
+
        <ajc-test dir="bugs161/pr199130" title="complex bounds on generic aspect - 3">
        <compile files="Complex2.java" options="-1.5"/>
        <run class="Complex2">
        <ajc-test dir="bugs161/pr235829" title="crazy generics and inner types">
        <compile files="Main.java a/Adapter.java a/b/Adapter.java" options="-1.5"/>
        <run class="Main"/>
-    </ajc-test>    
+    </ajc-test>
 
     <ajc-test dir="bugs161/pr235597" title="annotation exposure and generics">
         <compile files="AnnotationTest1.java SomeAnnotation.java SomeAspect.java" options="-1.5"/>
           </stdout>
         </run>
     </ajc-test>
-    
+
 
     <ajc-test dir="bugs161/pr235204" title="incorrect call relationship">
         <compile files="RecursiveCatcher.java" options="-1.5 -emacssym"/>
     </ajc-test>
-    
+
     <ajc-test dir="bugs161/pr233838" title="itd precedence - 1">
         <compile files="Z.java" options="-1.5"/>
         <run class="Z">
           </stdout>
         </run>
     </ajc-test>
-    
+
 
     <ajc-test dir="bugs161/pr227401" title="getfield problem with generics">
         <compile files="Instrumentation.java Fails.java" options="-1.5"/>
             <line text="22"/>
           </stdout>
         </run>
-    </ajc-test> 
-    
+    </ajc-test>
+
     <ajc-test dir="bugs161/pr231478" title="generic abstract aspects">
         <compile files="Base.java Sub.java AbstractComponent.java AbstractWindow.java" options="-1.5"/>
     </ajc-test>
             <line text="set of NO field"/>
           </stderr>
         </run>
-    </ajc-test> 
+    </ajc-test>
 
     <ajc-test dir="bugs161/pr231187x" title="generics bounds decp">
         <compile files="Cement.java ConcreteClass.java SuperClass.java SuperClassAspect.aj WetCement.java Main.java" options="-1.5"/>
             <line text="ran!"/>
           </stdout>
         </run>
-    </ajc-test> 
-    
+    </ajc-test>
+
     <ajc-test dir="bugs161/pr231187x" title="generics bounds decp - 2">
         <compile files="Cement.java ConcreteClass.java SuperClass.java WetCement.java" options="-1.5">
           <message kind="error" text="The type WetCement is not a valid substitute for the bounded parameter"/>
         </compile>
-    </ajc-test> 
-    
+    </ajc-test>
+
     <ajc-test dir="bugs161/pr230134" title="ltw inherited cflow">
       <compile files="HW.java"/>
       <compile files="SimpleTracing.java Tracing.java HelloWorldTracing.java" outjar="foo.jar" options="-1.4"/>
            </stdout>
       </run>
     </ajc-test>
-    
+
     <ajc-test dir="bugs161/pr229910" title="around advice on field set">
         <compile files="Test.java" options="-1.5"/>
         <run class="Test"/>
-    </ajc-test> 
-    
+    </ajc-test>
+
     <ajc-test dir="bugs161/pr226567" title="pipeline compilation and generic return type">
         <compile files="BarAspect.aj Foo.java Bar.java" options="-1.5"/>
         <compile files="BarAspect.aj Bar.java Foo.java" options="-1.5"/>
-    </ajc-test> 
-    
+    </ajc-test>
+
     <ajc-test dir="bugs161/pr235505" title="privileged generic aspect">
         <compile files="A.java" options="-1.5"/>
-    </ajc-test> 
-    
+    </ajc-test>
+
     <ajc-test dir="bugs161/pr235505" title="privileged generic aspect - 2">
         <compile files="B.java" options="-1.5"/>
         <run class="B">
             <line text="Hello World"/>
           </stdout>
         </run>
-    </ajc-test> 
-    
+    </ajc-test>
+
     <ajc-test dir="bugs161/pr64222" title="parsing around advice no return">
         <compile files="C.java" options="-1.5">
           <message kind="error" line="6" text="to complete around advice declaration"/>
         </compile>
-    </ajc-test> 
+    </ajc-test>
 
     <ajc-test dir="bugs161/pr159268" title="before array name">
         <compile files="C.java" options="-1.5"/>
-    </ajc-test> 
-    
-    
+    </ajc-test>
+
+
 
-</suite>
\ No newline at end of file
+</suite>