Skip to content

Commit

Permalink
AntSpec: Improve filter for warning "Archived non-system classes are …
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
kriegaex committed Oct 1, 2023
1 parent 3e81ed5 commit 73b36b1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions testing/src/test/java/org/aspectj/testing/AntSpec.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,19 @@ public void messageLogged(BuildEvent event) {
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();
Expand All @@ -236,9 +246,7 @@ public void messageLogged(BuildEvent event) {
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);
}
}
Expand Down

0 comments on commit 73b36b1

Please sign in to comment.