From 512d3fc281d2e56227e487dbf8ccee28cb63e589 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Wed, 6 Mar 2024 16:48:29 +0100 Subject: [PATCH] AjcTestCase: Improve forked JVM parameter handling - Recognise more "fork-worthy" JVM parameters - Pass on program arguments to program in forked JVM Signed-off-by: Alexander Kriegisch --- .../java/org/aspectj/tools/ajc/AjcTestCase.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java index 11b90c3b7..b76fe4ee0 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java @@ -694,10 +694,10 @@ public abstract class AjcTestCase extends TestCase { else if ( vmargs != null && ( vmargs.contains("--enable-preview") || - vmargs.contains("--add-modules") || - vmargs.contains("--limit-modules") || - vmargs.contains("--add-reads") || - vmargs.contains("--add-exports") + vmargs.contains("--add-modules") || vmargs.contains("--limit-modules") || + vmargs.contains("--add-reads") || vmargs.contains("--add-exports") || vmargs.contains("--add-opens") || + vmargs.contains("-ea") || vmargs.contains("-enableassertions") || + vmargs.contains("-Xmx") ) ) { // If --add-modules supplied, need to fork the test @@ -708,7 +708,10 @@ public abstract class AjcTestCase extends TestCase { if (cp.indexOf("aspectjrt")==-1) { cp.append(pathSeparator).append(TestUtil.aspectjrtPath().getPath()); } - String command = LangUtil.getJavaExecutable().getAbsolutePath() + " " +vmargs+ (cp.length()==0?"":" -classpath " + cp) + " " + className ; + String command = LangUtil.getJavaExecutable().getAbsolutePath() + " " + + vmargs + + (cp.length() == 0 ? "" : " -classpath " + cp) + " " + + className + " " + String.join(" ", args); if (Ajc.verbose) System.out.println("\nCommand: '" + command + "'\n"); // Command is executed using ProcessBuilder to allow setting CWD for ajc sandbox compliance -- 2.39.5