FileDocCategorySizeDatePackage
SunRmic.javaAPI DocApache Ant 1.703952Wed Dec 13 06:16:24 GMT 2006org.apache.tools.ant.taskdefs.rmic

SunRmic

public class SunRmic extends DefaultRmicAdapter
The implementation of the rmic for SUN's JDK.
since
Ant 1.4

Fields Summary
public static final String
RMIC_CLASSNAME
name of the class
public static final String
COMPILER_NAME
the name of this adapter for users to select
public static final String
RMIC_EXECUTABLE
name of the executable
public static final String
ERROR_NO_RMIC_ON_CLASSPATH
Error message to use with the sun rmic is not the classpath.
public static final String
ERROR_RMIC_FAILED
Error message to use when there is an error starting the sun rmic compiler
Constructors Summary
Methods Summary
public booleanexecute()
Run the rmic compiler.

return
true if the compilation succeeded
throws
BuildException on error


                       
         
        getRmic().log("Using SUN rmic compiler", Project.MSG_VERBOSE);
        Commandline cmd = setupRmicCommand();

        // Create an instance of the rmic, redirecting output to
        // the project log
        LogOutputStream logstr = new LogOutputStream(getRmic(),
                                                     Project.MSG_WARN);

        try {
            Class c = Class.forName(RMIC_CLASSNAME);
            Constructor cons
                = c.getConstructor(new Class[]  {OutputStream.class, String.class});
            Object rmic = cons.newInstance(new Object[] {logstr, "rmic"});

            Method doRmic = c.getMethod("compile",
                                        new Class [] {String[].class});
            Boolean ok =
                (Boolean) doRmic.invoke(rmic,
                                       (new Object[] {cmd.getArguments()}));
            return ok.booleanValue();
        } catch (ClassNotFoundException ex) {
            throw new BuildException(ERROR_NO_RMIC_ON_CLASSPATH,
                                     getRmic().getLocation());
        } catch (Exception ex) {
            if (ex instanceof BuildException) {
                throw (BuildException) ex;
            } else {
                throw new BuildException(ERROR_RMIC_FAILED,
                                         ex, getRmic().getLocation());
            }
        } finally {
            try {
                logstr.close();
            } catch (IOException e) {
                throw new BuildException(e);
            }
        }