harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r740696 - /harmony/enhanced/jdktools/trunk/modules/jdktools/src/main/java/org/apache/harmony/tools/javac/Main.java
Date Wed, 04 Feb 2009 10:58:35 GMT
Author: tellison
Date: Wed Feb  4 10:58:34 2009
New Revision: 740696

URL: http://svn.apache.org/viewvc?rev=740696&view=rev
Log:
Fix HARMONY-6079 ([jdktools] javac should exit with error code non-zero on compile errors)

Modified:
    harmony/enhanced/jdktools/trunk/modules/jdktools/src/main/java/org/apache/harmony/tools/javac/Main.java

Modified: harmony/enhanced/jdktools/trunk/modules/jdktools/src/main/java/org/apache/harmony/tools/javac/Main.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jdktools/src/main/java/org/apache/harmony/tools/javac/Main.java?rev=740696&r1=740695&r2=740696&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jdktools/src/main/java/org/apache/harmony/tools/javac/Main.java
(original)
+++ harmony/enhanced/jdktools/trunk/modules/jdktools/src/main/java/org/apache/harmony/tools/javac/Main.java
Wed Feb  4 10:58:34 2009
@@ -26,11 +26,17 @@
  */
 public final class Main {
 
+    // javac tool return codes
+    public static final int RC_SUCCESS = 0;
+    public static final int RC_COMPILE_ERROR = 1;
+    public static final int RC_USAGE_ERROR = 2;
+
     /*
      * Command-line tool invokes this method.
      */
     public static void main(String[] args) {
-        new Main().compile(args);
+        int rc = new Main().compile(args);
+        System.exit(rc);
     }
 
     /**
@@ -45,9 +51,9 @@
      * 
      * @param args
      *            the arguments passed through to the compiler
-     * @return true on compilation success, false on failure
+     * @return a return code as defined by this class
      */
-    public boolean compile(String[] args) {
+    public int compile(String[] args) {
 
         return compile(args,Util.getDefaultWriter(System.out), Util.getDefaultWriter(System.err));
     }
@@ -61,21 +67,22 @@
      *            get the output from System.out
      * @param err
      *            get the output from System.err
-     * @return true on compilation success, false on failure
+     * @return a return code as defined by this class
      */
-    public boolean compile(String[] args, PrintWriter out, PrintWriter err) {
+    public int compile(String[] args, PrintWriter out, PrintWriter err) {
 
         /* Give me something to do */
         if (args == null || args.length == 0) {
             new Compiler(out, err).printUsage();
-            return false;
+            return RC_USAGE_ERROR;
         }
 
         /* Add in the base class library code to compile against */
         String[] newArgs = addBootclasspath(args);
 
         /* Invoke the compiler */
-        return Compiler.main(newArgs, out, err);
+        boolean success = Compiler.main(newArgs, out, err);
+        return success ? RC_SUCCESS : RC_COMPILE_ERROR;
     }
 
     /*



Mime
View raw message