You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2021/02/18 02:03:38 UTC

[Bug 65148] New: AntLauncher terminates enclosing VM

https://bz.apache.org/bugzilla/show_bug.cgi?id=65148

            Bug ID: 65148
           Summary: AntLauncher terminates enclosing VM
           Product: Ant
           Version: 1.10.9
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: Core
          Assignee: notifications@ant.apache.org
          Reporter: jgsuess@gmail.com
  Target Milestone: ---

org.apache.tools.ant.launch.Launcher.main() is the recommended way to launch
ant from Java as per https://ant.apache.org/manual/running.html#viajava .
However,

org.apache.tools.ant.launch.Launcher.main()
calls System.exit(exitCode); (l.114)

This means that integrating this launcher will kill a VM on an error.

This issue cannot be addressed by subclassing as the constructor of Launcher is
private, not protected, and is called from main().

This means that any reuser either needs to spawn a VM, or copy the class into a
private namespace, shadow it or copy the dispatch method under a different name
to extend. None of these alternatives is appealing.

Please ensure that this reuse issue is fixed or deprecate the launcher if it 
is not intended for this purpose or cannot be used this way.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 65148] AntLauncher terminates enclosing VM

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65148

--- Comment #1 from Jaikiran Pai <ja...@apache.org> ---
I don't have historical knowledge about the
org.apache.tools.ant.launch.Launcher class. Looking at the example in the
manual, those examples launch the Launcher in a separate JVM (of its own),
either using the "java" command or using the "java" Ant task with fork = true.
I don't know if Launcher was intended to be used in embedded cases where you
use it from within another running Java program.

If it's not intended to be used from within another Java program, then I think
we can update the manual to make a note of this behaviour.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 65148] AntLauncher terminates enclosing VM

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65148

Stefan Bodewig <bo...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 65148] AntLauncher terminates enclosing VM

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65148

--- Comment #3 from Jaikiran Pai <ja...@apache.org> ---
Thank you for those details, Stefan.

> For an embedded usage of Ant I feel the class is doing to much anyway like spitting diagnostic messages to System streams, modifying system properties or creating custom classloaders.

Given all this, I think just updating the documentation to note that the
Launcher class exits the JVM it runs in, should be enough. I can do that
sometime this week.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 65148] AntLauncher terminates enclosing VM

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65148

--- Comment #2 from Stefan Bodewig <bo...@apache.org> ---
I'm afraid my memory of the introduction is rather blurry as well. Not killing
the process has not really been a design goal, we wanted to ensure the process
exit code actually reflected whether the build was successful. The Launcher
class is supposed to be used as the java process' main class.

For an embedded usage of Ant I feel the class is doing to much anyway like
spitting diagnostic messages to System streams, modifying system properties or
creating custom classloaders. I doubt ideas and other things that run Ant
embedded actually use Launcher - more likely they create a Project instance
(using ProjectHelper, quite possible a self-provided one) and execute targets
on it.

Of course we could add yet another command line argument to Launcher that
suppressed System.exit. And we can make the documentation more clear this class
is not really intended to be used for embedding Ant. The page is about "running
Ant" not embedding it, after all :-).

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 65148] AntLauncher terminates enclosing VM

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65148

Stefan Bodewig <bo...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |1.10.16

-- 
You are receiving this mail because:
You are the assignee for the bug.