ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject [4/5] ant git commit: fail early if javah is used with java 10+
Date Sat, 09 Dec 2017 19:08:31 GMT
fail early if javah is used with java 10+


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

Branch: refs/heads/master
Commit: 79e9d104350c4c3db04ccb7d53a6a9a1544d17fa
Parents: 8191d7e
Author: Stefan Bodewig <bodewig@apache.org>
Authored: Sat Dec 9 20:03:15 2017 +0100
Committer: Stefan Bodewig <bodewig@apache.org>
Committed: Sat Dec 9 20:03:15 2017 +0100

----------------------------------------------------------------------
 WHATSNEW                                            |  3 +++
 manual/Tasks/javah.html                             |  3 ++-
 .../optional/javah/JavahAdapterFactory.java         |  4 ++++
 src/tests/antunit/taskdefs/optional/javah-test.xml  | 16 ++++++++++++----
 .../tools/ant/taskdefs/optional/JavahTest.java      |  4 ++++
 5 files changed, 25 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/79e9d104/WHATSNEW
----------------------------------------------------------------------
diff --git a/WHATSNEW b/WHATSNEW
index 0f5e9bf..e855833 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -52,6 +52,9 @@ Other changes:
 
  * added "javac10+" as new supported value for javac's compiler attribute.
 
+ * javah has been removed from Java 10. The task will now throw an
+   exception if you try to use it while running Java 10 or newer.
+
 Changes from Ant 1.9.8 TO Ant 1.9.9
 ===================================
 

http://git-wip-us.apache.org/repos/asf/ant/blob/79e9d104/manual/Tasks/javah.html
----------------------------------------------------------------------
diff --git a/manual/Tasks/javah.html b/manual/Tasks/javah.html
index 4d3979b..d1daa7c 100644
--- a/manual/Tasks/javah.html
+++ b/manual/Tasks/javah.html
@@ -39,7 +39,8 @@ systems are used.</p>
   generate the native header files with a single step.</p>
 
 <p><b>Note</b> the <code>javah</code> has been deprecated as
of Java 9
-  and is scheduled to be removed with Java 10.</p>
+  and removed as of Java 10. Trying to use it with Java10 will
+  fail.</p>
 
 <p>It is possible to use different compilers. This can be selected
 with the <code>implementation</code> attribute or a nested element.  <a

http://git-wip-us.apache.org/repos/asf/ant/blob/79e9d104/src/main/org/apache/tools/ant/taskdefs/optional/javah/JavahAdapterFactory.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/javah/JavahAdapterFactory.java
b/src/main/org/apache/tools/ant/taskdefs/optional/javah/JavahAdapterFactory.java
index cc4419c..d40e595 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/javah/JavahAdapterFactory.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/javah/JavahAdapterFactory.java
@@ -89,6 +89,10 @@ public class JavahAdapterFactory {
         } else if ((JavaEnvUtils.isGij() && choice == null)
             || Gcjh.IMPLEMENTATION_NAME.equals(choice)) {
             return new Gcjh();
+        } else if (JavaEnvUtils.isAtLeastJavaVersion("10") &&
+                   (choice == null || ForkingJavah.IMPLEMENTATION_NAME.equals(choice))) {
+            throw new BuildException("javah does not exist under Java 10 and higher,"
+                + " use the javac task with nativeHeaderDir instead");
         } else if ((JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)
                     && choice == null)
                    || ForkingJavah.IMPLEMENTATION_NAME.equals(choice)) {

http://git-wip-us.apache.org/repos/asf/ant/blob/79e9d104/src/tests/antunit/taskdefs/optional/javah-test.xml
----------------------------------------------------------------------
diff --git a/src/tests/antunit/taskdefs/optional/javah-test.xml b/src/tests/antunit/taskdefs/optional/javah-test.xml
index 884523d..82d91c8 100644
--- a/src/tests/antunit/taskdefs/optional/javah-test.xml
+++ b/src/tests/antunit/taskdefs/optional/javah-test.xml
@@ -101,12 +101,12 @@ public class Foo {
     </presetdef>
   </target>
 
-  <target name="testSimpleCompile" depends="-setupForRealJavahTests">
+  <target name="testSimpleCompile" depends="-setupForRealJavahTests" unless="jdk10+">
     <javah-single/>
     <au:assertFileExists file="${output}/org_example_Foo.h"/>
   </target>
 
-  <target name="testCompileUsingFileset" depends="-setupForRealJavahTests">
+  <target name="testCompileUsingFileset" depends="-setupForRealJavahTests" unless="jdk10+">
     <javah-fileset/>
     <au:assertFileExists file="${output}/org_example_Foo.h"/>
   </target>
@@ -123,13 +123,21 @@ public class Foo {
     <au:assertFileExists file="${output}/org_example_Foo.h"/>
   </target>
 
-  <target name="testSimpleCompileForking" depends="-setupForRealJavahTests">
+  <target name="testSimpleCompileForking" depends="-setupForRealJavahTests" unless="jdk10+">
     <javah-single implementation="forking"/>
     <au:assertFileExists file="${output}/org_example_Foo.h"/>
   </target>
 
-  <target name="testCompileUsingFilesetForking" depends="-setupForRealJavahTests">
+  <target name="testCompileUsingFilesetForking" depends="-setupForRealJavahTests" unless="jdk10+">
     <javah-fileset implementation="forking"/>
     <au:assertFileExists file="${output}/org_example_Foo.h"/>
   </target>
+
+  <target name="testSimpleCompileFailsOnJava10+" depends="-setupForRealJavahTests"
+          if="jdk10+">
+    <au:expectfailure>
+      <javah-single/>
+    </au:expectfailure>
+  </target>
+
 </project>

http://git-wip-us.apache.org/repos/asf/ant/blob/79e9d104/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java
index 40472de..91f7b32 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java
@@ -18,6 +18,8 @@
 package org.apache.tools.ant.taskdefs.optional;
 
 import org.apache.tools.ant.BuildFileRule;
+import org.apache.tools.ant.util.JavaEnvUtils;
+import org.junit.Assume;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
@@ -47,6 +49,7 @@ public class JavahTest {
 
     @Test
     public void testSimpleCompile() {
+        Assume.assumeFalse(JavaEnvUtils.isAtLeastJavaVersion("10"));
         buildRule.executeTarget("simple-compile");
         assertTrue(new File(buildRule.getProject().getProperty("output"), "org_example_Foo.h")
                 .exists());
@@ -54,6 +57,7 @@ public class JavahTest {
 
     @Test
     public void testCompileFileset() {
+        Assume.assumeFalse(JavaEnvUtils.isAtLeastJavaVersion("10"));
         buildRule.executeTarget("test-fileset");
         assertTrue(new File(buildRule.getProject().getProperty("output"), "org_example_Foo.h").exists());
     }


Mime
View raw message