Hi, While stepping through the code for ANTLR task, following observation was made:
Whatever the value of fork flag, Execute.execute() is always used to invoke antlr.Tool class. According to my understanding, the Execute.execute() method invokes a external program, in this case it is the java program. This means that the antlr.Tool class will always be run outside of the ant VM, regardless of the fork attrib value. Is this correct? Is this the correct behavior for fork? (I guess not). I guess the reason for not invoking the antlr.Tool.main method directly through the code (i.e. using Execute even if fork is false) is that antlr.Tool calls System.exit() at multiple places and not just in its main(). Is this correct (or are there any other reasons?) I suggest: - Removing the fork attribute (as the implementation is inconsistent with what it promises to do, particularly for fork=false) or - At least documenting this behavior (saying forking will be done always). Which patch should I provide? One more suggestion: To avoid the situation like this (i.e. when classes running through ant tasks call System.exit()), why not have ant's own security manager with the permission for exitVM disabled? and catch the resulting SecurityException? (What impact will this have on other tools and IDEs which rely on or use ant?) Comments? With regards, Nikhil PS: 1. Many tasks support fork attribute; is there a guideline or something which says use Execute class when forking and use xyz when not forking? 2. What are the reasons ant needs its own class loader AntClassLoader? ----- Original Message ----- From: "Stefan Bodewig" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, January 31, 2001 8:50 PM Subject: Re: Problem with <antlr> task > NIkhil R. Deshpande <[EMAIL PROTECTED]> wrote: > > > Hi, > > > > When I put antlr.jar in %ANT_HOME%\lib directory and run > > ant, I get following exception: > > > > java.lang.NoClassDefFoundError: antlr/Tool > > > > but not if you use fork="no", right? > > > But if I put antlr.jar in CLASSPATH before running ant, then > > everything works ok. > > When forking of a separate VM, <antlr> doesn't specify a classpath at > all, thus using the setting for CLASSPATH from your environment which > is not altered by ant.bat.
