]> source.dussan.org Git - aspectj.git/commitdiff
AjcTestCase: Improve forked JVM parameter handling
authorAlexander Kriegisch <Alexander@Kriegisch.name>
Wed, 6 Mar 2024 15:48:29 +0000 (16:48 +0100)
committerAlexander Kriegisch <Alexander@Kriegisch.name>
Tue, 12 Mar 2024 07:21:38 +0000 (08:21 +0100)
- Recognise more "fork-worthy" JVM parameters
- Pass on program arguments to program in forked JVM

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java

index 11b90c3b730ce6833c96118983bcc6b5bc367393..b76fe4ee01386a6da95921d99e225eb4748383d7 100644 (file)
@@ -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