From 79e9d104350c4c3db04ccb7d53a6a9a1544d17fa Mon Sep 17 00:00:00 2001
From: Stefan Bodewig
Date: Sat, 9 Dec 2017 20:03:15 +0100
Subject: [PATCH] fail early if javah is used with java 10+
---
WHATSNEW | 3 +++
manual/Tasks/javah.html | 3 ++-
.../optional/javah/JavahAdapterFactory.java | 4 ++++
.../antunit/taskdefs/optional/javah-test.xml | 16 ++++++++++++----
.../tools/ant/taskdefs/optional/JavahTest.java | 4 ++++
5 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/WHATSNEW b/WHATSNEW
index 0f5e9bf7b..e855833b6 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
===================================
diff --git a/manual/Tasks/javah.html b/manual/Tasks/javah.html
index 4d3979bd0..d1daa7c01 100644
--- a/manual/Tasks/javah.html
+++ b/manual/Tasks/javah.html
@@ -39,7 +39,8 @@ systems are used.
generate the native header files with a single step.
Note the javah
has been deprecated as of Java 9
- and is scheduled to be removed with Java 10.
+ and removed as of Java 10. Trying to use it with Java10 will
+ fail.
It is possible to use different compilers. This can be selected
with the implementation
attribute or a nested element.
-
+
-
+
@@ -123,13 +123,21 @@ public class Foo {
-
+
-
+
+
+
+
+
+
+
+
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 40472de2b..91f7b3278 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());
}