From dcc2fd168c30a6d4293f3ceade2e95d822e67e36 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Fri, 22 Mar 2024 18:25:56 +0100 Subject: [PATCH] Adjust 1.6.1 'testRunningBrokenCode_pr102733*' tests ECJ Java 22 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 --- tests/bugs161/pr102733/C3.java | 6 + tests/bugs161/pr102733/Invoker.java | 27 ++--- tests/bugs161/pr102733/Invoker3.java | 24 ++++ .../systemtest/ajc161/Ajc161Tests.java | 10 +- .../org/aspectj/systemtest/ajc161/ajc161.xml | 105 ++++++++++-------- 5 files changed, 110 insertions(+), 62 deletions(-) create mode 100644 tests/bugs161/pr102733/C3.java create mode 100644 tests/bugs161/pr102733/Invoker3.java diff --git a/tests/bugs161/pr102733/C3.java b/tests/bugs161/pr102733/C3.java new file mode 100644 index 000000000..4f8ed164d --- /dev/null +++ b/tests/bugs161/pr102733/C3.java @@ -0,0 +1,6 @@ + +public class C3 { + public static void main(String[] argv) {} + + blahblahpackage pack; +} diff --git a/tests/bugs161/pr102733/Invoker.java b/tests/bugs161/pr102733/Invoker.java index bfa162de5..bc84365cd 100644 --- a/tests/bugs161/pr102733/Invoker.java +++ b/tests/bugs161/pr102733/Invoker.java @@ -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 index 000000000..e7a0d461e --- /dev/null +++ b/tests/bugs161/pr102733/Invoker3.java @@ -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); + } + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc161/Ajc161Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc161/Ajc161Tests.java index 5822a3f7c..11f24c2b1 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc161/Ajc161Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc161/Ajc161Tests.java @@ -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() { diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc161/ajc161.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc161/ajc161.xml index abc3e058e..8a1798b8b 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc161/ajc161.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc161/ajc161.xml @@ -11,17 +11,17 @@ - + - + - + @@ -35,65 +35,76 @@ - + - + - + - + - + - + - - + + + + + + - + - + + + + + + + + - + - + - + @@ -106,7 +117,7 @@ - + @@ -123,7 +134,7 @@ - + @@ -139,24 +150,24 @@ - + - + - + - + @@ -172,7 +183,7 @@ - + @@ -196,12 +207,12 @@ - + - + @@ -219,7 +230,7 @@ - + @@ -236,8 +247,8 @@ - - + + @@ -255,7 +266,7 @@ - + @@ -264,14 +275,14 @@ - - + + - - + + @@ -281,21 +292,21 @@ - + - - + + - - + + - - + + @@ -304,18 +315,18 @@ - - + + - + - - - + + + - \ No newline at end of file + -- 2.39.5