System.exit() is used incorrectly in antlr.Tool
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Jimmy_Wan
Posted On:   Friday, October 11, 2002 01:21 PM

antlr.Tool does not return a valid return code when an error has occurred. i.e. it always returns 0: Before suggested changes (in bold) public static void main(String[] args) { System.err.println(""ANTLR Parser Generator Version ""+ Tool.version+"" 1989-2000 jGuru.com""); try { if ( args.length==0 ) { help(); } Tool theTool = new Tool(); theTool.doEverything(args); theTool = null; } catch (Exception e) { System.err.println(System.getProperty(""line.separator"")+ System.getProperty(""line.separator"")); System.err.println(""#$%%*&@#    More>>

antlr.Tool does not return a valid return code when an error has occurred. i.e. it always returns 0:



Before suggested changes (in bold)
			
public static void main(String[] args) {
System.err.println(""ANTLR Parser Generator Version ""+
Tool.version+"" 1989-2000 jGuru.com"");
try {
if ( args.length==0 ) {
help();
}
Tool theTool = new Tool();
theTool.doEverything(args);
theTool = null;
}
catch (Exception e) {
System.err.println(System.getProperty(""line.separator"")+
System.getProperty(""line.separator""));
System.err.println(""#$%%*&@# internal error: ""+e.toString());
System.err.println(""[complain to nearest government official"");
System.err.println("" or send hate-mail to parrt@jguru.com;"");
System.err.println("" please send stack trace with report.]""+
System.getProperty(""line.separator""));
e.printStackTrace();
}
			
				
System.exit(0);
			
}



After suggested changes (in bold)
			
public static void main(String[] args) {
System.err.println(""ANTLR Parser Generator Version ""+
Tool.version+"" 1989-2000 jGuru.com"");
try {
if ( args.length==0 ) {
help();
}
Tool theTool = new Tool();
theTool.doEverything(args);
theTool = null;
			
				
System.exit(0);
			
}
catch (Exception e) {
System.err.println(System.getProperty(""line.separator"")+
System.getProperty(""line.separator""));
System.err.println(""#$%%*&@# internal error: ""+e.toString());
System.err.println(""[complain to nearest government official"");
System.err.println("" or send hate-mail to parrt@jguru.com;"");
System.err.println("" please send stack trace with report.]""+
System.getProperty(""line.separator""));
e.printStackTrace();
			
				
System.exit(-1);
			
}
			
				
// Remove
// System.exit(0);
			
}
   <<Less

Re: System.exit() is used incorrectly in antlr.Tool

Posted By:   Jimmy_Wan  
Posted On:   Wednesday, October 23, 2002 05:12 PM

Not sure if this is readily obvious or not, but this bug causes exceptions to be silently ignored when invoking antlr via Ant.
About | Sitemap | Contact