Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.javatest.lib
Class JavaCompileCommand

    java.lang.Object
      com.sun.javatest.Command
          com.sun.javatest.lib.JavaCompileCommand

    public class JavaCompileCommand

extends Command

Invoke a Java compiler via reflection. The compiler is assumed to have a constructor and compile method matching the following signature:

     public class COMPILER {
         public COMPILER(java.io.OutputStream out, String compilerName);
         public boolean compile(String[] args);
     }

or

     public class COMPILER {
         public COMPILER();
         public int compile(String[] args);
     }

or

     public class COMPILER {
        public static int compile(String[] args, PrintWriter out);
     }

This means the command is suitable for (but not limited to) the compiler javac suplied with JDK. (Note that this uses an internal API of javac which is not documented and is not guaranteed to exist in any specific release of JDK.)

Field Summary
`static boolean` | `defaultVerbose`

Constructor Summary
`JavaCompileCommand()`

Method Summary
`static void` | `main(java.lang.String[] args)` A stand-alone entry point for this command.
`Status` | `run(java.lang.String[] args, java.io.PrintWriter log, java.io.PrintWriter ref)` Invoke a specified compiler, or the default, javac.

Methods inherited from class com.sun.javatest.Command
`getClassLoader, setClassLoader`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### defaultVerbose

    public static boolean defaultVerbose

Constructor Detail

### JavaCompileCommand

    public JavaCompileCommand()

Method Detail

### main

    public static void main(java.lang.String[] args)

  A stand-alone entry point for this command. An instance of this command is created, and its `run` method invoked, passing in the command line args and `System.out` and `System.err` as the two streams.

  Parameters:
    `args` - command line arguments for this command.
  See Also:
    `run(java.lang.String[], java.io.PrintWriter, java.io.PrintWriter)`

### run

    public Status run(java.lang.String[] args,
                      java.io.PrintWriter log,
                      java.io.PrintWriter ref)

  Invoke a specified compiler, or the default, javac. If the first word in the `args` array is "-compiler" the second is interpreted as the class name for the compiler to be invoked, optionally preceded by a name for the compiler, separated from the class name by a colon. If no -compiler is specified, the default is `javac:com.sun.tools.javac.Main'. If -compiler is specified but no compiler name is given before the class name, the default name will be `java ' followed by the classname. For example, `-compiler Main' will result in the class name being `Main' and the compiler name being `java Main'. After determining the class and compiler name, an instance of the compiler class will be created, passing it a stream using the `ref` parameter, and the name of the compiler. Then the `compile' method will be invoked, passing it the remaining values of the `args' parameter. If the compile method returns true, the result will be a status of `passed'; if it returns `false', the result will be `failed'. If any problems arise, the result will be a status of `error'.

  Specified by:
    `run` in class `Command`
  Parameters:
    `args` - An optional specification for the compiler to be invoked, followed by arguments for the compiler's compile method.
    `log` - Not used.
    `ref` - Passed to the compiler that is invoked.
  Returns:
    `passed' if the compilation is successful; `failed' if the compiler is invoked and errors are found in the file(s) being compiler; or `error' if some more serios problem arose that prevented the compiler performing its task.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.