Browse Source

Merge branch '1.9.x'

master
Stefan Bodewig 7 years ago
parent
commit
1c5a92fb1f
7 changed files with 43 additions and 7 deletions
  1. +3
    -0
      WHATSNEW
  2. +2
    -1
      manual/Tasks/javah.html
  3. +5
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/javah/JavahAdapterFactory.java
  4. +6
    -2
      src/main/org/apache/tools/ant/util/JavaEnvUtils.java
  5. +12
    -4
      src/tests/antunit/taskdefs/optional/javah-test.xml
  6. +4
    -0
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java
  7. +11
    -0
      src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java

+ 3
- 0
WHATSNEW View File

@@ -75,6 +75,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.10.0 TO Ant 1.10.1
=====================================



+ 2
- 1
manual/Tasks/javah.html View File

@@ -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


+ 5
- 0
src/main/org/apache/tools/ant/taskdefs/optional/javah/JavahAdapterFactory.java View File

@@ -90,6 +90,11 @@ public class JavahAdapterFactory {
|| Gcjh.IMPLEMENTATION_NAME.equals(choice)) {
return new Gcjh();
}
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");
}
if (ForkingJavah.IMPLEMENTATION_NAME.equals(choice)) {
return new ForkingJavah();
}


+ 6
- 2
src/main/org/apache/tools/ant/util/JavaEnvUtils.java View File

@@ -187,8 +187,12 @@ public final class JavaEnvUtils {
javaVersionNumber = VERSION_9;
// at least Java9 and this should properly support the purely numeric version property
String v = System.getProperty("java.specification.version");
javaVersionNumber = Integer.parseInt(v) * 10;
javaVersion = v;
DeweyDecimal pv = new DeweyDecimal(v);
javaVersionNumber = pv.get(0) * 10;
if (pv.getSize() > 1) {
javaVersionNumber += pv.get(1);
}
javaVersion = pv.toString();
} catch (Throwable t) {
// swallow as we've hit the max class version that
// we have


+ 12
- 4
src/tests/antunit/taskdefs/optional/javah-test.xml View File

@@ -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>

+ 4
- 0
src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java View File

@@ -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());
}


+ 11
- 0
src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java View File

@@ -143,4 +143,15 @@ public class JavaEnvUtilsTest {
assertTrue("JAVA_1_9 is not considered equal to JAVA_9",
JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_9));
}

@Test
public void java10IsDetectedProperly() {
assumeTrue("10".equals(System.getProperty("java.specification.version")));
assertEquals("10", JavaEnvUtils.getJavaVersion());
assertEquals(100, JavaEnvUtils.getJavaVersionNumber());
assertEquals(new DeweyDecimal("10"), JavaEnvUtils.getParsedJavaVersion());
assertTrue(JavaEnvUtils.isJavaVersion("10"));
assertTrue(JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9));
}

}

Loading…
Cancel
Save