From 63d5e3e893bd149245465de1610716930998dec8 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Wed, 23 Mar 2022 11:55:22 +0700 Subject: Fix more LTW tests Signed-off-by: Alexander Kriegisch --- .../src/test/java/org/aspectj/testing/RunSpec.java | 8 ++++-- .../org/aspectj/systemtest/ajc150/ltw/ltw.xml | 31 ++++++++++++++++++++-- .../org/aspectj/systemtest/ajc1612/ajc1612.xml | 2 +- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/testing/src/test/java/org/aspectj/testing/RunSpec.java b/testing/src/test/java/org/aspectj/testing/RunSpec.java index d687ae86b..534ed6374 100644 --- a/testing/src/test/java/org/aspectj/testing/RunSpec.java +++ b/testing/src/test/java/org/aspectj/testing/RunSpec.java @@ -22,7 +22,7 @@ import java.util.StringTokenizer; import org.aspectj.tools.ajc.AjcTestCase; import org.aspectj.util.FileUtil; -import static org.aspectj.util.LangUtil.is16VMOrGreater; +import static org.aspectj.util.LangUtil.is9VMOrGreater; /** * @author Adrian Colyer @@ -70,7 +70,11 @@ public class RunSpec implements ITestStep { // On Java 16+, LTW no longer works without this parameter. Add the argument here and not in AjcTestCase::run, // because even if 'useLTW' and 'useFullLTW' are not set, we might in the future have tests for weaver attachment // during runtime. See also docs/dist/doc/README-187.html. - vmargs += is16VMOrGreater() ? " --add-opens java.base/java.lang=ALL-UNNAMED" : ""; + // + // The reason for setting this parameter for Java 9+ instead of 16+ is that it helps to avoid the JVM printing + // unwanted illegal access warnings during weaving in 'useFullLTW' mode, either making existing tests fail or + // having to assert on the warning messages. + vmargs += is9VMOrGreater() ? " --add-opens java.base/java.lang=ALL-UNNAMED" : ""; AjcTestCase.RunResult rr = inTestCase.run(getClassToRun(), getModuleToRun(), args, vmargs, getClasspath(), getModulepath(), useLtw, "true".equalsIgnoreCase(usefullltw)); diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc150/ltw/ltw.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc150/ltw/ltw.xml index 975b35cd8..6e66e388e 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc150/ltw/ltw.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc150/ltw/ltw.xml @@ -221,7 +221,7 @@ - + @@ -229,6 +229,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -244,7 +271,7 @@ text="this affected type is not exposed to the weaver: TestITDMethod" /> + ltw="aop-abstractaspect.xml" usefullltw="true"> diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc1612/ajc1612.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc1612/ajc1612.xml index 11049dcf9..aade93bf6 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc1612/ajc1612.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc1612/ajc1612.xml @@ -13,7 +13,7 @@ - + -- cgit v1.2.3