From: Alexander Kriegisch Date: Sun, 1 Oct 2023 06:46:30 +0000 (+0700) Subject: AntSpec: Improve filter for warning "Archived non-system classes are disabled" X-Git-Tag: V1_9_21_M1~10 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=73b36b1a2532cc33e746c3ccf751713d875897f1;p=aspectj.git 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 --- 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); } }