ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject ant git commit: rmic doesn't allow -Xnew on JDK9
Date Sat, 30 Jul 2016 10:05:55 GMT
Repository: ant
Updated Branches:
  refs/heads/1.9.x 8d3744ee7 -> e74054fbb


rmic doesn't allow -Xnew on JDK9

https://bz.apache.org/bugzilla/show_bug.cgi?id=59906


Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/e74054fb
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/e74054fb
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/e74054fb

Branch: refs/heads/1.9.x
Commit: e74054fbbd641da7863b3a6768f82e17406b6015
Parents: 8d3744e
Author: Stefan Bodewig <bodewig@apache.org>
Authored: Sat Jul 30 12:04:57 2016 +0200
Committer: Stefan Bodewig <bodewig@apache.org>
Committed: Sat Jul 30 12:04:57 2016 +0200

----------------------------------------------------------------------
 WHATSNEW                                        |  4 ++++
 manual/Tasks/rmic.html                          |  4 +++-
 .../ant/taskdefs/rmic/DefaultRmicAdapter.java   | 14 +++++++++++
 .../tools/ant/taskdefs/RmicAdvancedTest.java    | 25 ++++++++++++++++----
 4 files changed, 42 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/e74054fb/WHATSNEW
----------------------------------------------------------------------
diff --git a/WHATSNEW b/WHATSNEW
index 5b9887b..869c804 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -12,6 +12,10 @@ Changes that could break older environments:
  * The ant.java.version property will now hold the value "9" rather
    than "1.9" if running on Java 9.
 
+ * <rmic> will no longer allow the -Xnew option (or xmic compiler) to
+   be used when running on Java 9 since this option has been removed.
+   Bugzilla Report 59906
+
 Fixed bugs:
 -----------
 

http://git-wip-us.apache.org/repos/asf/ant/blob/e74054fb/manual/Tasks/rmic.html
----------------------------------------------------------------------
diff --git a/manual/Tasks/rmic.html b/manual/Tasks/rmic.html
index 12b30c5..3c7a6d6 100644
--- a/manual/Tasks/rmic.html
+++ b/manual/Tasks/rmic.html
@@ -61,7 +61,9 @@ attribute. or a nested element.
     running on JDK 9+.</li>
   <li>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</li>
+    This is the most reliable way to use -Xnew.
+    <br></br>JDK9 has removed support for -Xnew and starting with Ant
+    1.9.8 this option will be rejected by ant when running on JDK9.</li>
     <li> "" (empty string). This has the same behaviour as not setting the compiler
attribute.
     First the value of <tt>build.rmic</tt> is used if defined, and if not, the
default
     for the platform is chosen. If build.rmic is set to this, you get the default.

http://git-wip-us.apache.org/repos/asf/ant/blob/e74054fb/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java b/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java
index bb2cfaa..d4483d9 100644
--- a/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java
+++ b/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java
@@ -24,11 +24,13 @@ import java.util.List;
 import java.util.Random;
 import java.util.Vector;
 
+import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.taskdefs.Rmic;
 import org.apache.tools.ant.types.Commandline;
 import org.apache.tools.ant.types.Path;
 import org.apache.tools.ant.util.FileNameMapper;
+import org.apache.tools.ant.util.JavaEnvUtils;
 import org.apache.tools.ant.util.StringUtils;
 
 /**
@@ -248,6 +250,8 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
         compilerArgs = preprocessCompilerArgs(compilerArgs);
         cmd.addArguments(compilerArgs);
 
+        verifyArguments(cmd);
+
         logAndAddFilesToCompile(cmd);
         return cmd;
      }
@@ -349,6 +353,16 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
         attributes.log(niceSourceList.toString(), Project.MSG_VERBOSE);
     }
 
+    private void verifyArguments(Commandline cmd) {
+        if (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) {
+            for (String arg : cmd.getArguments()) {
+                if ("-Xnew".equals(arg)) {
+                    throw new BuildException("JDK9 has removed support for -Xnew");
+                }
+            }
+        }
+    }
+
     /**
      * Mapper that may return up to two file names.
      *

http://git-wip-us.apache.org/repos/asf/ant/blob/e74054fb/src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java
----------------------------------------------------------------------
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 e0e2d9a..3753b68 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java
@@ -24,11 +24,13 @@ import org.apache.tools.ant.BuildFileRule;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.taskdefs.rmic.RmicAdapterFactory;
 import org.apache.tools.ant.taskdefs.rmic.DefaultRmicAdapter;
+import org.apache.tools.ant.util.JavaEnvUtils;
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
 /**
@@ -352,6 +354,7 @@ public class RmicAdvancedTest {
      */
     @Test
     public void testXnew() throws Exception {
+        // skipped via unless attribute for JDK > 6
         buildRule.executeTarget("testXnew");
     }
 
@@ -362,6 +365,7 @@ public class RmicAdvancedTest {
      */
     @Test
     public void testXnewDest() throws Exception {
+        // skipped via unless attribute for JDK > 6
         buildRule.executeTarget("testXnewDest");
     }
 
@@ -372,7 +376,7 @@ public class RmicAdvancedTest {
      */
     @Test
     public void testXnewForked() throws Exception {
-        buildRule.executeTarget("testXnewForked");
+        xnewTest("testXnewForked");
     }
 
     /**
@@ -382,7 +386,7 @@ public class RmicAdvancedTest {
      */
     @Test
     public void testXnewForkedDest() throws Exception {
-        buildRule.executeTarget("testXnewForkedDest");
+        xnewTest("testXnewForkedDest");
     }
 
     /**
@@ -392,7 +396,7 @@ public class RmicAdvancedTest {
      */
     @Test
     public void testXnewCompiler() throws Exception {
-        buildRule.executeTarget("testXnewCompiler");
+        xnewTest("testXnewCompiler");
     }
 
     /**
@@ -402,7 +406,7 @@ public class RmicAdvancedTest {
      */
     @Test
     public void testXnewCompilerDest() throws Exception {
-        buildRule.executeTarget("testXnewCompilerDest");
+        xnewTest("testXnewCompilerDest");
     }
 
     /**
@@ -445,6 +449,19 @@ public class RmicAdvancedTest {
         buildRule.executeTarget("testIIOPDest");
     }
 
+    private void xnewTest(String target) {
+        if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) {
+            buildRule.executeTarget(target);
+        } else {
+            try {
+                buildRule.executeTarget(target);
+                fail("Target should have thrown a BuildException");
+            } catch (BuildException ex) {
+                assertEquals("JDK9 has removed support for -Xnew", ex.getMessage());
+            }
+        }
+    }
+
     /**
      * this little bunny verifies that we can load stuff, and that
      * a failure to execute is turned into a fault


Mime
View raw message