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 14:36:35 UTC

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

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 13e6e30  Pass -Djava.security.manager=allow while launching JUnit forked VM to allow JUnit triggered code to set security manager at runtime
     new 5086264  Revert "Pass -Djava.security.manager=allow while launching JUnit forked VM to allow JUnit triggered code to set security manager at runtime"
     new f3e3345  launch Ant project tests by passing java.security.manager=allow on Java 18

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:
 build.xml                                                      | 10 ++++++++++
 .../apache/tools/ant/taskdefs/optional/junit/JUnitTask.java    | 10 ----------
 2 files changed, 10 insertions(+), 10 deletions(-)

[ant] 01/02: Revert "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 5086264e00fb26b96915eb57d347a3473ca5ea85
Author: Jaikiran Pai <ja...@apache.org>
AuthorDate: Sun Nov 28 19:39:28 2021 +0530

    Revert "Pass -Djava.security.manager=allow while launching JUnit forked VM to allow JUnit triggered code to set security manager at runtime"
    
    This reverts commit 13e6e309585b18210b71d8ecc70af2a075804873.
---
 .../apache/tools/ant/taskdefs/optional/junit/JUnitTask.java    | 10 ----------
 1 file changed, 10 deletions(-)

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 02fc038..2f6b42e 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,7 +64,6 @@ 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;
@@ -1165,15 +1164,6 @@ 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) {

[ant] 02/02: launch Ant project tests by passing java.security.manager=allow on 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 f3e3345e8af2b117e79757690644a04bb584bf82
Author: Jaikiran Pai <ja...@apache.org>
AuthorDate: Sun Nov 28 19:53:20 2021 +0530

    launch Ant project tests by passing java.security.manager=allow on Java 18
---
 build.xml | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/build.xml b/build.xml
index cc184a3..8d401aa 100644
--- a/build.xml
+++ b/build.xml
@@ -1756,6 +1756,9 @@ ${antunit.reports}
         <javaversion atleast="9"/>
       </not>
     </condition>
+    <condition property="java.security.manager" value="allow">
+      <javaversion exactly="18"/>
+    </condition>
     <macrodef name="test-junit">
       <element name="junit-nested" implicit="true"/>
       <sequential>
@@ -1806,6 +1809,13 @@ ${antunit.reports}
           <syspropertyset>
             <propertyref name="sun.io.useCanonCaches"/>
           </syspropertyset>
+          <!-- Many JUnit tests, in the Ant project, launch Java programs through Ant's
+           java task, which internally calls System.setSecurityManager(). In Java 18
+           an explicit system property value needs to be set to prevent exception from
+           being thrown from that call -->
+          <syspropertyset>
+            <propertyref name="java.security.manager"/>
+          </syspropertyset>
           <classpath>
             <path refid="tests-runtime-classpath"/>
             <pathelement location="${junit.collector.dir}"/>