Bug 66493 - Could not run ant.bat on old Java with new "java.security.manager" parameter
Summary: Could not run ant.bat on old Java with new "java.security.manager" parameter
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: Core (show other bugs)
Version: 1.10.13
Hardware: PC All
: P2 major (vote)
Target Milestone: 1.10.14
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-27 11:40 UTC by Yury
Modified: 2023-08-15 14:00 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yury 2023-02-27 11:40:08 UTC
Did not see any open bug like this, but I just cannot run ant.bat script on old java (8 or 11, for example), because of:
set "ANT_OPTS=%ANT_OPTS% -Djava.security.manager=allow"
This is what I got on "ant.bat -v" execution:
ANT_OPTS is set to  -Djava.security.manager=allow
Error occurred during initialization of VM
java.lang.Error: Could not create SecurityManager
at java.lang.System.initPhase3(java.base@11.0.13/System.java:2061)
Caused by: java.lang.ClassNotFoundException: allow
at jdk.internal.loader.BuiltinClassLoader.loadClass(java.base@11.0.13/BuiltinClassLoader.java:581)
at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(java.base@11.0.13/ClassLoaders.java:178)
at java.lang.ClassLoader.loadClass(java.base@11.0.13/ClassLoader.java:521)
at java.lang.Class.forName0(java.base@11.0.13/Native Method)
at java.lang.Class.forName(java.base@11.0.13/Class.java:398)
at java.lang.System.initPhase3(java.base@11.0.13/System.java:2046)
Comment 1 Jaikiran Pai 2023-02-27 12:15:48 UTC
Thank you for reporting this. Although we tested this change before this release, I was still nervous that this would lead to issues like these. We now have 3 separate issues (including this change) that been reported because of our usage of "allow". I'll revisit this change shortly and address in a subsequent release.
Comment 2 Catie 2023-03-30 16:38:48 UTC
I've just run up against this as well in a Java 7 app for a client. I'm going to recommend downgrading to 10.12, but I'm curious if there's any straightforward way to update either the build script or environment to work around this error for 10.13. Any thoughts from someone with more ant experience would be appreciated!
Comment 3 Catie 2023-03-30 16:41:15 UTC
Also, this bug report and the fact that Ant dumps ANT_OPTS on failure saved my whole afternoon, so many many thanks!
Comment 4 Yury 2023-05-10 07:56:32 UTC
Good day!
Any plans to fix it?
Comment 5 Yury 2023-06-16 07:07:52 UTC
Kind reminder.
Comment 6 Jaikiran Pai 2023-08-12 06:40:59 UTC
Sorry this took a while to get fixed. I've now reverted the SecurityManager related changes that were introduced in Ant 1.10.13. Ant will no longer use/support Java SecurityManager when Ant is used in Java 18+ versions. This should get us past all these issues.

It would be very helpful if you could try out our nightly build which contains these fixes and see if it helps you with this issue https://ci-builds.apache.org/job/Ant/job/Ant_Nightly/lastSuccessfulBuild/artifact/distribution/
Comment 7 Yury 2023-08-15 04:52:09 UTC
Good day!
Now everything looks good.
By the way, this is the "ant -version" output:
Apache Ant(TM) version 1.10.5 compiled on July 10 2018
Is it because it not fully prepared yet?
Comment 8 Jaikiran Pai 2023-08-15 14:00:03 UTC
Hello Yury, thank you very much for trying the nightly build and reporting back. It's good to hear that the build works with this version.



> By the way, this is the "ant -version" output:
> Apache Ant(TM) version 1.10.5 compiled on July 10 2018
> Is it because it not fully prepared yet?

ant -version will always use whatever ANT_HOME environment variable is set to. What I mean is if ANT_HOME is set to point to a 1.9.14 installation (for example) and you use the "ant" command shipped in 1.10.13 of Ant installation like below, then it will output the version as 1.9.14 (and not 1.10.13). So I think you have ANT_HOME set to 1.10.5 installation, when you ran ant -version command.

echo $ANT_HOME
/home/me/ant/apache-ant-1.9.14/

/home/me/ant/apache-ant-1.10.13/bin/ant -version
Apache Ant(TM) version 1.9.14 compiled on March 12 2019