diff options
author | Alexander Kriegisch <Alexander@Kriegisch.name> | 2023-10-01 13:46:30 +0700 |
---|---|---|
committer | Alexander Kriegisch <Alexander@Kriegisch.name> | 2023-10-01 14:07:33 +0700 |
commit | 73b36b1a2532cc33e746c3ccf751713d875897f1 (patch) | |
tree | 9fe49973b7e073b815b17c81004fe8fe36b01a3f /testing | |
parent | 3e81ed505a8c74c073197ef9c8368b7e9f6dc02f (diff) | |
download | aspectj-73b36b1a2532cc33e746c3ccf751713d875897f1.tar.gz aspectj-73b36b1a2532cc33e746c3ccf751713d875897f1.zip |
AntSpec: Improve filter for warning "Archived non-system classes are disabled"
In JDK 21, the prefix has changed once again, no longer being a JVM
specifier like "OpenJDK 64-Bit Server VM" or "Java HotSpot(TM) 64-Bit
Server VM" but rather something like "[0.016s][warning][cds]".
Even worse, before J21, the warning appears on stdErr, but in J21+, it
appears on stdOut.
Fixes LTWTests.testJ14LTWWithXML, which started failing on Java 21.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'testing')
-rw-r--r-- | testing/src/test/java/org/aspectj/testing/AntSpec.java | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/testing/src/test/java/org/aspectj/testing/AntSpec.java b/testing/src/test/java/org/aspectj/testing/AntSpec.java index 9d239d61b..07f2f10ff 100644 --- a/testing/src/test/java/org/aspectj/testing/AntSpec.java +++ b/testing/src/test/java/org/aspectj/testing/AntSpec.java @@ -212,9 +212,19 @@ public class AntSpec implements ITestStep { AjcTestCase.fail(failMessage + "error when invoking target :" + t.toString()); } + // J12: Line can start with e.g. "OpenJDK 64-Bit Server VM" or "Java HotSpot(TM) 64-Bit Server VM". + // J21: Line can start with e.g. "[0.016s][warning][cds]". + // Therefore, we have to match a substring instead of a whole line. + // Even worse, before J21, the warning appears on stdErr, but in J21+, it appears on stdOut. + final String regexArchivedNonSystemClasses = "[^\n]+( warning:|\\[warning]\\[cds]) " + + "Archived non-system classes are disabled because the java.system.class.loader property is specified " + + ".*org.aspectj.weaver.loadtime.WeavingURLClassLoader[^\n]+\n?"; + /* See if stdout/stderr matches test specification */ if (m_stdOutSpec != null) { - m_stdOutSpec.matchAgainst(stdout.toString()); + String stdout2 = stdout.toString(); + stdout2 = stdout2.replaceAll(regexArchivedNonSystemClasses, ""); + m_stdOutSpec.matchAgainst(stdout2); } if (m_stdErrSpec != null) { String stderr2 = stderr.toString(); @@ -236,9 +246,7 @@ public class AntSpec implements ITestStep { stderr2 = stderr2.replaceAll("WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations\n",""); stderr2 = stderr2.replaceAll("WARNING: All illegal access operations will be denied in a future release\n",""); } - // J12: Line can start with e.g."OpenJDK 64-Bit Server VM" or "Java HotSpot(TM) 64-Bit Server VM". Therefore, - // we have to match a substring instead of a whole line - stderr2 = stderr2.replaceAll("[^\n]+ warning: Archived non-system classes are disabled because the java.system.class.loader property is specified .*org.aspectj.weaver.loadtime.WeavingURLClassLoader[^\n]+\n?",""); + stderr2 = stderr2.replaceAll(regexArchivedNonSystemClasses, ""); m_stdErrSpec.matchAgainst(stderr2); } } |