You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by ja...@apache.org on 2021/11/28 13:17:17 UTC

[ant] branch master updated (53fcbca -> 13e6e30)

This is an automated email from the ASF dual-hosted git repository.

jaikiran pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/ant.git.


    from 53fcbca  Merge pull request #172 from azotcsit/junitlauncher-extension
     new 0b028a2  Pass -Djava.security.manager=allow from *nix launcher script for Java 18
     new 13e6e30  Pass -Djava.security.manager=allow while launching JUnit forked VM to allow JUnit triggered code to set security manager at runtime

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/tools/ant/taskdefs/optional/junit/JUnitTask.java    | 10 ++++++++++
 src/script/ant                                                 |  6 ++++++
 2 files changed, 16 insertions(+)

[ant] 01/02: Pass -Djava.security.manager=allow from *nix launcher script for Java 18

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jaikiran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ant.git

commit 0b028a211ad5f816620f8a4107f7eef65a49785d
Author: Jaikiran Pai <ja...@apache.org>
AuthorDate: Sun Nov 28 18:41:17 2021 +0530

    Pass -Djava.security.manager=allow from *nix launcher script for Java 18
---
 src/script/ant | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/script/ant b/src/script/ant
index 81107b5..4095a72 100644
--- a/src/script/ant
+++ b/src/script/ant
@@ -368,6 +368,12 @@ else
     ant_sys_opts="-Djikes.class.path=\"$JIKESPATH\""
   fi
 fi
+# Run "java -XshowSettings:properties" and check the output for "java.specification.version" value
+JAVA_SPEC_VERSION=`"$JAVACMD" -XshowSettings:properties 2>&1 | grep "java.specification.version = " | tr -d '[:space:]'`
+if [ "$JAVA_SPEC_VERSION" == "java.specification.version=18" ]; then
+  # set security manager property to allow calls to System.setSecurityManager() at runtime
+  ANT_OPTS="$ANT_OPTS -Djava.security.manager=allow"
+fi
 ant_exec_command="exec \"\$JAVACMD\" $ANT_OPTS -classpath \"\$LOCALCLASSPATH\" -Dant.home=\"\$ANT_HOME\" -Dant.library.dir=\"\$ANT_LIB\" $ant_sys_opts org.apache.tools.ant.launch.Launcher $ANT_ARGS -cp \"\$CLASSPATH\""
 if $ant_exec_debug; then
   # using printf to avoid echo line continuation and escape interpretation confusion

[ant] 02/02: Pass -Djava.security.manager=allow while launching JUnit forked VM to allow JUnit triggered code to set security manager at runtime

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jaikiran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ant.git

commit 13e6e309585b18210b71d8ecc70af2a075804873
Author: Jaikiran Pai <ja...@apache.org>
AuthorDate: Sun Nov 28 18:44:52 2021 +0530

    Pass -Djava.security.manager=allow while launching JUnit forked VM to allow JUnit triggered code to set security manager at runtime
---
 .../apache/tools/ant/taskdefs/optional/junit/JUnitTask.java    | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
index 2f6b42e..02fc038 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
@@ -64,6 +64,7 @@ import org.apache.tools.ant.types.Path;
 import org.apache.tools.ant.types.Permissions;
 import org.apache.tools.ant.types.PropertySet;
 import org.apache.tools.ant.util.FileUtils;
+import org.apache.tools.ant.util.JavaEnvUtils;
 import org.apache.tools.ant.util.LoaderUtils;
 import org.apache.tools.ant.util.SplitClassLoader;
 import org.apache.tools.ant.util.StringUtils;
@@ -1164,6 +1165,15 @@ public class JUnitTask extends Task {
         } catch (final CloneNotSupportedException e) {
             throw new BuildException("This shouldn't happen", e, getLocation());
         }
+        // if Java 18, then we set -Djava.security.manager=allow so as to allow
+        // Ant code to internally set the security manager
+        if (JavaEnvUtils.isAtLeastJavaVersion("18")) {
+            log("Setting -Djava.security.manager=allow on forked JVM of JUnit task", Project.MSG_VERBOSE);
+            final Environment.Variable securityManagerSysProp = new Environment.Variable();
+            securityManagerSysProp.setKey("java.security.manager");
+            securityManagerSysProp.setValue("allow");
+            cmd.addSysproperty(securityManagerSysProp);
+        }
         if (casesFile == null) {
             cmd.createArgument().setValue(test.getName());
             if (test.getMethods() != null) {