Browse Source

Kaffe has a new RMIC compiler

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277196 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 20 years ago
parent
commit
cf2fcaff65
1 changed files with 34 additions and 13 deletions
  1. +34
    -13
      src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java

+ 34
- 13
src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java View File

@@ -29,7 +29,9 @@ import org.apache.tools.ant.types.Commandline;
* @since Ant 1.4 * @since Ant 1.4
*/ */
public class KaffeRmic extends DefaultRmicAdapter { public class KaffeRmic extends DefaultRmicAdapter {
public static final String RMIC_CLASSNAME = "kaffe.rmi.rmic.RMIC";
public static final String RMIC_CLASSNAME = "gnu.java.rmi.rmic.RMIC";
private static final String OLD_RMIC_CLASSNAME = "kaffe.rmi.rmic.RMIC";

/** /**
* the name of this adapter for users to select * the name of this adapter for users to select
*/ */
@@ -40,28 +42,34 @@ public class KaffeRmic extends DefaultRmicAdapter {
getRmic().log("Using Kaffe rmic", Project.MSG_VERBOSE); getRmic().log("Using Kaffe rmic", Project.MSG_VERBOSE);
Commandline cmd = setupRmicCommand(); Commandline cmd = setupRmicCommand();


try {
Class c = getRmicClass();
if (c == null) {
throw new BuildException("Cannot use Kaffe rmic, as it is not "
+ "available. Neither "
+ RMIC_CLASSNAME
+ " nor "
+ OLD_RMIC_CLASSNAME
+ " have been found. "
+ "A common solution is to "
+ "set the environment variable "
+ "JAVA_HOME or CLASSPATH.",
getRmic().getLocation());
}


Class c = Class.forName(RMIC_CLASSNAME);
try {
Constructor cons = c.getConstructor(new Class[] {String[].class}); Constructor cons = c.getConstructor(new Class[] {String[].class});
Object rmic = cons.newInstance(new Object[] {cmd.getArguments()}); Object rmic = cons.newInstance(new Object[] {cmd.getArguments()});
Method doRmic = c.getMethod("run", (Class[]) null); Method doRmic = c.getMethod("run", (Class[]) null);
Boolean ok = (Boolean) doRmic.invoke(rmic, (Object[]) null); Boolean ok = (Boolean) doRmic.invoke(rmic, (Object[]) null);


return ok.booleanValue(); return ok.booleanValue();
} catch (ClassNotFoundException ex) {
throw new BuildException("Cannot use Kaffe rmic, as it is not "
+ "available. A common solution is to "
+ "set the environment variable "
+ "JAVA_HOME or CLASSPATH.",
getRmic().getLocation());
} catch (BuildException ex) { } catch (BuildException ex) {
//rethrow //rethrow
throw ex; throw ex;
} catch (Exception ex) { } catch (Exception ex) {
//wrap //wrap
throw new BuildException("Error starting Kaffe rmic: ", throw new BuildException("Error starting Kaffe rmic: ",
ex, getRmic().getLocation());
ex, getRmic().getLocation());
} }
} }


@@ -70,11 +78,24 @@ public class KaffeRmic extends DefaultRmicAdapter {
* @return true if kaffe is on the current classpath * @return true if kaffe is on the current classpath
*/ */
public static boolean isAvailable() { public static boolean isAvailable() {
return getRmicClass() != null;
}

/**
* tries to load Kaffe RMIC and falls back to the older class name
* if necessary.
*
* @return null if neither class can get loaded.
*/
private static Class getRmicClass() {
try { try {
Class.forName(RMIC_CLASSNAME);
return true;
return Class.forName(RMIC_CLASSNAME);
} catch (ClassNotFoundException cnfe) { } catch (ClassNotFoundException cnfe) {
return false;
try {
return Class.forName(OLD_RMIC_CLASSNAME);
} catch (ClassNotFoundException cnfe2) {
}
} }
return null;
} }
} }

Loading…
Cancel
Save