summaryrefslogtreecommitdiff
path: root/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java')
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java40
1 files changed, 18 insertions, 22 deletions
diff --git a/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java b/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java
index 7281252aa..4af9c72aa 100644
--- a/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java
+++ b/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java
@@ -51,13 +51,10 @@ public class SunRmic extends DefaultRmicAdapter {
*/
public static final String RMIC_EXECUTABLE = "rmic";
/** Error message to use with the sun rmic is not the classpath. */
- public static final String ERROR_NO_RMIC_ON_CLASSPATH = "Cannot use SUN rmic, as it is not "
- + "available. A common solution is to "
- + "set the environment variable "
- + "JAVA_HOME";
- public static final String ERROR_NO_RMIC_ON_CLASSPATH_JAVA_9 = "Cannot use SUN rmic, as it is not "
- + "available. The class we try to use is part of the jdk.rmic module which may not be. "
- + "Please use the 'forking' compiler for JDK 9+";
+ public static final String ERROR_NO_RMIC_ON_CLASSPATH =
+ "Cannot use SUN rmic, as it is not available. A common solution is to set the environment variable JAVA_HOME";
+ public static final String ERROR_NO_RMIC_ON_CLASSPATH_JAVA_9 =
+ "Cannot use SUN rmic, as it is not available. The class we try to use is part of the jdk.rmic module which may not be. Please use the 'forking' compiler for JDK 9+";
/** Error message to use when there is an error starting the sun rmic compiler */
public static final String ERROR_RMIC_FAILED = "Error starting SUN rmic: ";
@@ -66,29 +63,28 @@ public class SunRmic extends DefaultRmicAdapter {
* @return true if the compilation succeeded
* @throws BuildException on error
*/
+ @Override
public boolean execute() throws BuildException {
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);
+ LogOutputStream logstr =
+ new LogOutputStream(getRmic(), Project.MSG_WARN);
boolean success = false;
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"});
+ Class<?> c = Class.forName(RMIC_CLASSNAME);
+ Constructor<?> cons =
+ c.getConstructor(OutputStream.class, String.class);
+ Object rmic = cons.newInstance(logstr, "rmic");
- Method doRmic = c.getMethod("compile",
- new Class [] {String[].class});
- Boolean ok =
- (Boolean) doRmic.invoke(rmic,
- (new Object[] {cmd.getArguments()}));
+ Method doRmic = c.getMethod("compile", String[].class);
+ boolean ok = Boolean.TRUE
+ .equals(doRmic.invoke(rmic, (Object) cmd.getArguments()));
success = true;
- return ok.booleanValue();
+ return ok;
} catch (ClassNotFoundException ex) {
if (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) {
throw new BuildException(ERROR_NO_RMIC_ON_CLASSPATH_JAVA_9,
@@ -99,10 +95,9 @@ public class SunRmic extends DefaultRmicAdapter {
} catch (Exception ex) {
if (ex instanceof BuildException) {
throw (BuildException) ex;
- } else {
- throw new BuildException(ERROR_RMIC_FAILED,
- ex, getRmic().getLocation());
}
+ throw new BuildException(ERROR_RMIC_FAILED,
+ ex, getRmic().getLocation());
} finally {
try {
logstr.close();
@@ -122,6 +117,7 @@ public class SunRmic extends DefaultRmicAdapter {
* @param compilerArgs the original compiler arguments
* @return the filtered set.
*/
+ @Override
protected String[] preprocessCompilerArgs(String[] compilerArgs) {
return filterJvmCompilerArgs(compilerArgs);
}