diff --git a/WHATSNEW b/WHATSNEW
index 3e4e90ba0..da25374ec 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -50,6 +50,12 @@ Other changes:
* added a new filter that can perform non-ASCII
to Unicode-escape conversions.
+ * defaults to the "forking" compiler on JDK 9+ as the
+ implementation class of rmic is not exported by its containing
+ module and thus not accessible to Ant without applying -XaddExports
+ magic.
+ Bugzilla Report 59860
+
Changes from Ant 1.9.6 TO Ant 1.9.7
===================================
diff --git a/manual/Tasks/rmic.html b/manual/Tasks/rmic.html
index b644c68cd..12b30c51e 100644
--- a/manual/Tasks/rmic.html
+++ b/manual/Tasks/rmic.html
@@ -52,11 +52,13 @@ with the "build.rmic" property, the compiler
attribute. or a nested element.
Here are the choices:
- - default -the default compiler (kaffe or sun) for the platform.
-
- sun (the standard compiler of the JDK)
+ - default -the default compiler (kaffe, sun or forking) for the platform.
+
- sun (the standard compiler of the JDK < JDK 9)
- kaffe (the standard compiler of Kaffe)
- weblogic
- - forking - the sun compiler forked into a separate process (since Apache Ant 1.7)
+ - forking - the sun compiler forked into a separate process (since
+ Apache Ant 1.7). Starting with Ant 1.9.8 this is the default when
+ running on JDK 9+.
- xnew - the sun compiler forked into a separate process,
with the -Xnew option (since Ant 1.7).
This is the most reliable way to use -Xnew
diff --git a/src/etc/testcases/taskdefs/rmic/rmic.xml b/src/etc/testcases/taskdefs/rmic/rmic.xml
index 944cdcd6b..4670f43f7 100644
--- a/src/etc/testcases/taskdefs/rmic/rmic.xml
+++ b/src/etc/testcases/taskdefs/rmic/rmic.xml
@@ -200,7 +200,17 @@
-
+
+
+
+
+
+
+
+
+
+
+
@@ -263,24 +273,24 @@
-
+
-
+
-
+
-
+
@@ -322,7 +332,7 @@
-
+
@@ -330,12 +340,12 @@
-
+
@@ -389,14 +399,14 @@
-
+
-
+
@@ -429,14 +439,14 @@
This test stamps on the XML parser settings on java6, so it is disabled.
-->
-
+
-
+
diff --git a/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java b/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java
index 4a2708c78..a604144ad 100644
--- a/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java
+++ b/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java
@@ -22,6 +22,7 @@ import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.util.ClasspathUtils;
+import org.apache.tools.ant.util.JavaEnvUtils;
/**
* Creates the necessary rmic adapter, given basic criteria.
@@ -95,9 +96,13 @@ public final class RmicAdapterFactory {
throws BuildException {
//handle default specially by choosing the sun or kaffe compiler
if (DEFAULT_COMPILER.equalsIgnoreCase(rmicType) || rmicType.length() == 0) {
- rmicType = KaffeRmic.isAvailable()
- ? KaffeRmic.COMPILER_NAME
- : SunRmic.COMPILER_NAME;
+ if (KaffeRmic.isAvailable()) {
+ rmicType = KaffeRmic.COMPILER_NAME;
+ } else if (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) {
+ rmicType = ForkingSunRmic.COMPILER_NAME;
+ } else {
+ rmicType = SunRmic.COMPILER_NAME;
+ }
}
if (SunRmic.COMPILER_NAME.equalsIgnoreCase(rmicType)) {
return new SunRmic();
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 07cbd3062..1b5e67dad 100644
--- a/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java
+++ b/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java
@@ -27,6 +27,7 @@ import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.LogOutputStream;
import org.apache.tools.ant.types.Commandline;
+import org.apache.tools.ant.util.JavaEnvUtils;
/**
* The implementation of the rmic for SUN's JDK.
@@ -54,6 +55,9 @@ public class SunRmic extends DefaultRmicAdapter {
+ "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: ";
@@ -84,6 +88,10 @@ public class SunRmic extends DefaultRmicAdapter {
(new Object[] {cmd.getArguments()}));
return ok.booleanValue();
} catch (ClassNotFoundException ex) {
+ if (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) {
+ throw new BuildException(ERROR_NO_RMIC_ON_CLASSPATH_JAVA_9,
+ getRmic().getLocation());
+ }
throw new BuildException(ERROR_NO_RMIC_ON_CLASSPATH,
getRmic().getLocation());
} catch (Exception ex) {
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java
index c9d251469..e0e2d9a1e 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java
@@ -137,7 +137,7 @@ public class RmicAdvancedTest {
* test weblogic
*/
@Test
- @Ignore("WLRmin tests don't work")
+ @Ignore("WLRmic tests don't work")
public void XtestWlrmic() throws Exception {
buildRule.executeTarget("testWlrmic");
}
@@ -146,7 +146,7 @@ public class RmicAdvancedTest {
* test weblogic's stripping of -J args
*/
@Test
- @Ignore("WLRmin tests don't work")
+ @Ignore("WLRmic tests don't work")
public void XtestWlrmicJArg() throws Exception {
buildRule.executeTarget("testWlrmicJArg");
}
@@ -155,8 +155,7 @@ public class RmicAdvancedTest {
* test the forking compiler
*/
@Test
- @Ignore("WLRmin tests don't work")
- public void NotestForking() throws Exception {
+ public void testForking() throws Exception {
buildRule.executeTarget("testForking");
}