You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2017/12/02 17:43:33 UTC

[08/10] ant git commit: Merge branch '1.9.x'

Merge branch '1.9.x'


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

Branch: refs/heads/master
Commit: 228e2e25e7f3330c2e1f7447c177330cc72efbf8
Parents: 866ce9f bd0759d
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sat Dec 2 18:40:09 2017 +0100
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sat Dec 2 18:40:16 2017 +0100

----------------------------------------------------------------------
 WHATSNEW                                        |   2 +
 build.xml                                       |   3 +
 manual/Tasks/conditions.html                    |  39 ++++
 manual/Tasks/javac.html                         |   9 +-
 src/main/org/apache/tools/ant/antlib.xml        |   2 +
 .../org/apache/tools/ant/taskdefs/Javac.java    |  19 +-
 .../compilers/CompilerAdapterFactory.java       |   3 +-
 .../compilers/DefaultCompilerAdapter.java       |  23 ++-
 .../ant/taskdefs/condition/JavaVersion.java     | 115 ++++++++++++
 .../tools/ant/types/conditions/antlib.xml       |   2 +
 .../org/apache/tools/ant/util/JavaEnvUtils.java | 180 +++++++++----------
 src/main/org/apache/tools/bzip2/BlockSort.java  |  46 ++---
 .../apache/tools/bzip2/CBZip2InputStream.java   |   7 +-
 src/tests/antunit/antunit-base.xml              |   3 +
 .../taskdefs/condition/javaversion-test.xml     |  40 +++++
 src/tests/antunit/taskdefs/javac-test.xml       |   9 +-
 .../tools/ant/AntClassLoaderDelegationTest.java |   4 +-
 .../org/apache/tools/ant/taskdefs/AntTest.java  |   2 +-
 .../apache/tools/ant/taskdefs/AntlibTest.java   |   3 +-
 .../tools/ant/taskdefs/AvailableTest.java       |   4 +-
 .../apache/tools/ant/taskdefs/CVSPassTest.java  |   2 +-
 .../apache/tools/ant/taskdefs/ChecksumTest.java |   2 +-
 .../org/apache/tools/ant/taskdefs/EchoTest.java |   4 +-
 .../apache/tools/ant/taskdefs/ManifestTest.java |   6 +-
 .../org/apache/tools/ant/taskdefs/MoveTest.java |   2 +-
 .../apache/tools/ant/taskdefs/MultiMapTest.java |   2 +-
 .../tools/ant/taskdefs/PathConvertTest.java     |   2 +-
 .../apache/tools/ant/taskdefs/RecorderTest.java |   2 +-
 .../apache/tools/ant/taskdefs/SubAntTest.java   |   6 +-
 .../apache/tools/ant/taskdefs/TouchTest.java    |   2 +-
 .../taskdefs/condition/ParserSupportsTest.java  |   2 +-
 31 files changed, 389 insertions(+), 158 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/228e2e25/WHATSNEW
----------------------------------------------------------------------
diff --cc WHATSNEW
index ce2cce5,79fb177..8ad85ef
--- a/WHATSNEW
+++ b/WHATSNEW
@@@ -69,10 -46,12 +69,12 @@@ Other changes
  
   * Bugzilla report 61718 - Jsch library dependency has now been
     upgraded to 0.1.54. Jsch is the library behind the sshexec 
 -   and scp Ant tasks.
 +   and scp Ant tasks.   
  
+  * Added a new <javaversion> condition.
+ 
 -Changes from Ant 1.9.8 TO Ant 1.9.9
 -===================================
 +Changes from Ant 1.10.0 TO Ant 1.10.1
 +=====================================
  
  Fixed bugs:
  -----------

http://git-wip-us.apache.org/repos/asf/ant/blob/228e2e25/build.xml
----------------------------------------------------------------------
diff --cc build.xml
index f7b2fbb,ffa86f1..7b8cf02
--- a/build.xml
+++ b/build.xml
@@@ -382,7 -375,13 +382,10 @@@
        </not>
      </condition>
      <property name="ignoresystemclasses" value="false"/>
 -    <available property="jdk1.6+" classname="java.net.CookieStore"/>
 -    <available property="jdk1.7+" classname="java.nio.file.FileSystem"/>
 -    <available property="jdk1.8+" classname="java.lang.reflect.Executable"/>
      <available property="jdk9+" classname="java.lang.module.ModuleDescriptor"/>
+     <condition property="jdk10+">
+       <javaversion atleast="10"/>
+     </condition>
      <available property="kaffe" classname="kaffe.util.NotImplemented"/>
      <available property="harmony"
                 classname="org.apache.harmony.luni.util.Base64"/>

http://git-wip-us.apache.org/repos/asf/ant/blob/228e2e25/manual/Tasks/conditions.html
----------------------------------------------------------------------
diff --cc manual/Tasks/conditions.html
index b1c1c31,35216cd..77c76a1
--- a/manual/Tasks/conditions.html
+++ b/manual/Tasks/conditions.html
@@@ -1095,5 -1090,44 +1095,44 @@@ is redundant and will be ignored.</p
    &lt;file file="${file}"/&gt;
  &lt;/resourceexists&gt;
  </pre></blockquote>
+ 
+ <h4><a name="javaversion">javaversion</a></h4>
+ 
+ <p>Tests the version of the JVM executing Ant.  <em>Since Ant
 -1.9.10</em></p>
++1.10.2</em></p>
+ 
+ <table border="1" cellpadding="2" cellspacing="0">
+   <tr>
+     <td width="12%" valign="top"><b>Attribute</b></td>
+     <td width="78%" valign="top"><b>Description</b></td>
+     <td width="10%" valign="top"><b>Required</b></td>
+   </tr>
+   <tr>
+     <td valign="top">atleast</td>
+     <td valign="top">The version that this JVM is at least.
+       The format is major.minor.point. Starting with Java9 really
+       only the major number is determined.</td>
+     <td valign="top" align="center">No</td>
+     <td valign="top" rowspan="2" align="center">One of these.</td>
+   </tr>
+   <tr>
+     <td valign="top">exactly</td>
+     <td valign="top">The version that this JVM is exactly.
+       The format is <tt>major.minor.point</tt>. Starting with Java9 really
+       only the major number is determined.</td>
+     <td valign="top" align="center">No</td>
+   </tr>
+ </table>
+ 
+   <p>
+     An example:
+   </p>
+ 
+ <blockquote><pre>
+ &lt;javaversion atleast=&quot;9&quot;/&gt;
+ </pre></blockquote>
+ 
+ <p>will evaluate to true if the current JVM is Java9 or above.</p>
+ 
  </body>
  </html>

http://git-wip-us.apache.org/repos/asf/ant/blob/228e2e25/manual/Tasks/javac.html
----------------------------------------------------------------------
diff --cc manual/Tasks/javac.html
index 68c6310,89ec054..3662402
--- a/manual/Tasks/javac.html
+++ b/manual/Tasks/javac.html
@@@ -78,9 -78,10 +78,10 @@@ attribute are:</a></p
        <code>javac1.5</code> and
        <code>javac1.6</code> and
        <code>javac1.7</code> (<em>since Ant 1.8.2</em>) and
-       <code>javac1.8</code> (<em>since Ant 1.8.3</em>) and</li>
-       <code>javac1.9</code> (<em>since Ant 1.9.5</em>) and</li>
-       <code>javac9</code> (<em>since Ant 1.9.8</em>) can be used as aliases.</li>
+       <code>javac1.8</code> (<em>since Ant 1.8.3</em>) and
+       <code>javac1.9</code> (<em>since Ant 1.9.5</em>) and
+       <code>javac9</code> (<em>since Ant 1.9.8</em>) and
 -      <code>javac10+</code> (<em>since Ant 1.9.10</em>) can be used as aliases.</li>
++      <code>javac10+</code> (<em>since Ant 1.10.2</em>) can be used as aliases.</li>
    <li><code>jikes</code> (the <a
      href="http://jikes.sourceforge.net/" target="_top">Jikes</a>
      compiler).</li>

http://git-wip-us.apache.org/repos/asf/ant/blob/228e2e25/src/main/org/apache/tools/ant/taskdefs/Javac.java
----------------------------------------------------------------------
diff --cc src/main/org/apache/tools/ant/taskdefs/Javac.java
index 0e97f0a,18e4941..fb8e2ed
--- a/src/main/org/apache/tools/ant/taskdefs/Javac.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Javac.java
@@@ -160,23 -163,21 +161,26 @@@ public class Javac extends MatchingTas
      private String assumedJavaVersion() {
          if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_4)) {
              return JAVAC14;
 -        } else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_5)) {
 +        }
 +        if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_5)) {
              return JAVAC15;
 -        } else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_6)) {
 +        }
 +        if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_6)) {
              return JAVAC16;
 -        } else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_7)) {
 +        }
 +        if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_7)) {
              return JAVAC17;
 -        } else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_8)) {
 +        }
 +        if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_8)) {
              return JAVAC18;
 -        } else if (JavaEnvUtils.isAtLeastJavaVersion("10")) {
 +        }
++        if (JavaEnvUtils.isAtLeastJavaVersion("10")) {
+             return JAVAC10_PLUS;
 -        } else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_9)) {
++        }
 +        if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_9)) {
              return JAVAC9;
 -        } else {
 -            return CLASSIC;
          }
 +        return CLASSIC;
      }
  
      /**

http://git-wip-us.apache.org/repos/asf/ant/blob/228e2e25/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java
----------------------------------------------------------------------
diff --cc src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java
index a1fe5c8,48d93ad..9cda7a4
--- a/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java
+++ b/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java
@@@ -96,59 -96,70 +96,60 @@@ public final class CompilerAdapterFacto
       * @since Ant 1.8.0
       */
      public static CompilerAdapter getCompiler(String compilerType, Task task,
 -                                              Path classpath)
 -        throws BuildException {
 -            if (compilerType.equalsIgnoreCase("jikes")) {
 -                return new Jikes();
 -            }
 -            if (compilerType.equalsIgnoreCase("extjavac")) {
 -                return new JavacExternal();
 -            }
 -            if (compilerType.equalsIgnoreCase("classic")
 -                || compilerType.equalsIgnoreCase("javac1.1")
 -                || compilerType.equalsIgnoreCase("javac1.2")) {
 -                task.log("This version of java does "
 -                                         + "not support the classic "
 -                                         + "compiler; upgrading to modern",
 -                                         Project.MSG_WARN);
 -                compilerType = "modern";
 -            }
 -            //on java<=1.3 the modern falls back to classic if it is not found
 -            //but on java>=1.4 we just bail out early
 -            if (compilerType.equalsIgnoreCase("modern")
 -                || compilerType.equalsIgnoreCase("javac1.3")
 -                || compilerType.equalsIgnoreCase("javac1.4")
 -                || compilerType.equalsIgnoreCase("javac1.5")
 -                || compilerType.equalsIgnoreCase("javac1.6")
 -                || compilerType.equalsIgnoreCase("javac1.7")
 -                || compilerType.equalsIgnoreCase("javac1.8")
 -                || compilerType.equalsIgnoreCase("javac1.9")
 -                || compilerType.equalsIgnoreCase("javac9")
 -                || compilerType.equalsIgnoreCase("javac10+")) {
 -                // does the modern compiler exist?
 -                if (doesModernCompilerExist()) {
 -                    return new Javac13();
 -                } else {
 -                    throw new BuildException("Unable to find a javac "
 -                                             + "compiler;\n"
 -                                             + MODERN_COMPILER
 -                                             + " is not on the "
 -                                             + "classpath.\n"
 -                                             + "Perhaps JAVA_HOME does not"
 -                                             + " point to the JDK.\n"
 -                            + "It is currently set to \""
 -                            + JavaEnvUtils.getJavaHome()
 -                            + "\"");
 -                }
 +        Path classpath) throws BuildException {
 +        if ("jikes".equalsIgnoreCase(compilerType)) {
 +            return new Jikes();
 +        }
 +        if ("extjavac".equalsIgnoreCase(compilerType)) {
 +            return new JavacExternal();
 +        }
 +        if ("classic".equalsIgnoreCase(compilerType)
 +            || "javac1.1".equalsIgnoreCase(compilerType)
 +            || "javac1.2".equalsIgnoreCase(compilerType)) {
 +            task.log(
 +                "This version of java does not support the classic compiler; upgrading to modern",
 +                Project.MSG_WARN);
 +            compilerType = "modern";
 +        }
 +        //on java<=1.3 the modern falls back to classic if it is not found
 +        //but on java>=1.4 we just bail out early
 +        if ("modern".equalsIgnoreCase(compilerType)
 +            || "javac1.3".equalsIgnoreCase(compilerType)
 +            || "javac1.4".equalsIgnoreCase(compilerType)
 +            || "javac1.5".equalsIgnoreCase(compilerType)
 +            || "javac1.6".equalsIgnoreCase(compilerType)
 +            || "javac1.7".equalsIgnoreCase(compilerType)
 +            || "javac1.8".equalsIgnoreCase(compilerType)
 +            || "javac1.9".equalsIgnoreCase(compilerType)
-             || "javac9".equalsIgnoreCase(compilerType)) {
++            || "javac9".equalsIgnoreCase(compilerType)
++            || "javac10+".equalsIgnoreCase(compilerType)) {
 +            // does the modern compiler exist?
 +            if (doesModernCompilerExist()) {
 +                return new Javac13();
              }
 +            throw new BuildException(
 +                "Unable to find a javac compiler;\n%s is not on the classpath.\nPerhaps JAVA_HOME does not point to the JDK.\nIt is currently set to \"%s\"",
 +                MODERN_COMPILER, JavaEnvUtils.getJavaHome());
 +        }
  
 -            if (compilerType.equalsIgnoreCase("jvc")
 -                || compilerType.equalsIgnoreCase("microsoft")) {
 -                return new Jvc();
 -            }
 -            if (compilerType.equalsIgnoreCase("kjc")) {
 -                return new Kjc();
 -            }
 -            if (compilerType.equalsIgnoreCase("gcj")) {
 -                return new Gcj();
 -            }
 -            if (compilerType.equalsIgnoreCase("sj")
 -                || compilerType.equalsIgnoreCase("symantec")) {
 -                return new Sj();
 -            }
 -            return resolveClassName(compilerType,
 -                                    // Memory-Leak in line below
 -                                task.getProject().createClassLoader(classpath));
 +        if ("jvc".equalsIgnoreCase(compilerType)
 +            || "microsoft".equalsIgnoreCase(compilerType)) {
 +            return new Jvc();
          }
 +        if ("kjc".equalsIgnoreCase(compilerType)) {
 +            return new Kjc();
 +        }
 +        if ("gcj".equalsIgnoreCase(compilerType)) {
 +            return new Gcj();
 +        }
 +        if ("sj".equalsIgnoreCase(compilerType)
 +            || "symantec".equalsIgnoreCase(compilerType)) {
 +            return new Sj();
 +        }
 +        return resolveClassName(compilerType,
 +            // Memory-Leak in line below
 +            task.getProject().createClassLoader(classpath));
 +    }
  
      /**
       * query for the Modern compiler existing

http://git-wip-us.apache.org/repos/asf/ant/blob/228e2e25/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
----------------------------------------------------------------------
diff --cc src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
index f33c4a5,350dbe5..62fb428
--- a/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
+++ b/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
@@@ -394,10 -395,10 +394,10 @@@ public abstract class DefaultCompilerAd
          if (!assumeJava13()) { // -source added with JDK 1.4
              final String t = attributes.getTarget();
              final String s = attributes.getSource();
-             if (release == null || !assumeJava19()) {
+             if (release == null || !assumeJava9Plus()) {
                  if (release != null) {
 -                    attributes.log("Support for javac --release has been added"
 -                                   + " in Java9 ignoring it");
 +                    attributes.log(
 +                        "Support for javac --release has been added in Java9 ignoring it");
                  }
                  if (s != null) {
                      cmd.createArgument().setValue("-source");
@@@ -715,6 -720,21 +715,21 @@@
      }
  
      /**
+      * Shall we assume JDK 9+ command line switches?
+      * @return true if JDK 9+
 -     * @since Ant 1.9.10
++     * @since Ant 1.10.2
+      */
+     protected boolean assumeJava9Plus() {
+         return "javac1.9".equals(attributes.getCompilerVersion())
+             || "javac9".equals(attributes.getCompilerVersion())
+             || "javac10+".equals(attributes.getCompilerVersion())
+             || (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9) &&
+                 ("classic".equals(attributes.getCompilerVersion())
+                  || "modern".equals(attributes.getCompilerVersion())
+                  || "extJavac".equals(attributes.getCompilerVersion())));
+     }
+ 
+     /**
       * Shall we assume command line switches for the given version of Java?
       * @since Ant 1.8.3
       */
@@@ -809,16 -829,17 +824,16 @@@
          if (t.startsWith("1.")) {
              t = t.substring(2);
          }
 -        return t.equals("1") || t.equals("2") || t.equals("3") || t.equals("4")
 -            || ((t.equals("5") || t.equals("6"))
 +        return "1".equals(t) || "2".equals(t) || "3".equals(t) || "4".equals(t)
 +            || (("5".equals(t) || "6".equals(t))
                  && !assumeJava15() && !assumeJava16())
 -            || (t.equals("7") && !assumeJava17())
 -            || (t.equals("8") && !assumeJava18())
 -            || (t.equals("9") && !assumeJava9Plus());
 +            || ("7".equals(t) && !assumeJava17())
 +            || ("8".equals(t) && !assumeJava18())
-             || ("9".equals(t) && !assumeJava9());
++            || ("9".equals(t) && !assumeJava9Plus());
      }
  
 -
      /**
 -     * Turn the task's attribute for -source into soemthing that is
 +     * Turn the task's attribute for -source into something that is
       * understood by all javac's after 1.4.
       *
       * <p>support for -source 1.1 and -source 1.2 has been added with

http://git-wip-us.apache.org/repos/asf/ant/blob/228e2e25/src/main/org/apache/tools/ant/taskdefs/condition/JavaVersion.java
----------------------------------------------------------------------
diff --cc src/main/org/apache/tools/ant/taskdefs/condition/JavaVersion.java
index 0000000,69a9290..3e37199
mode 000000,100644..100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/JavaVersion.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/JavaVersion.java
@@@ -1,0 -1,115 +1,115 @@@
+ /*
+  *  Licensed to the Apache Software Foundation (ASF) under one or more
+  *  contributor license agreements.  See the NOTICE file distributed with
+  *  this work for additional information regarding copyright ownership.
+  *  The ASF licenses this file to You under the Apache License, Version 2.0
+  *  (the "License"); you may not use this file except in compliance with
+  *  the License.  You may obtain a copy of the License at
+  *
+  *      http://www.apache.org/licenses/LICENSE-2.0
+  *
+  *  Unless required by applicable law or agreed to in writing, software
+  *  distributed under the License is distributed on an "AS IS" BASIS,
+  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  *  See the License for the specific language governing permissions and
+  *  limitations under the License.
+  *
+  */
+ package org.apache.tools.ant.taskdefs.condition;
+ 
+ import org.apache.tools.ant.BuildException;
+ import org.apache.tools.ant.util.DeweyDecimal;
+ import org.apache.tools.ant.util.JavaEnvUtils;
+ 
+ /**
+  * An Java version condition.
 - * @since Java 1.9.10
++ * @since Java 1.10.2
+  */
+ public class JavaVersion implements Condition {
+ 
+     private String atLeast = null;
+     private String exactly = null;
+ 
+     /**
+      * Evaluate the condition.
+      * @return true if the condition is true.
+      * @throws BuildException if an error occurs.
+      */
+     public boolean eval() throws BuildException {
+         validate();
+         DeweyDecimal actual = JavaEnvUtils.getParsedJavaVersion();
+         if (null != atLeast) {
+             return actual.isGreaterThanOrEqual(new DeweyDecimal(atLeast));
+         }
+         if (null != exactly) {
+             return actual.isEqual(new DeweyDecimal(exactly));
+         }
+         //default
+         return false;
+     }
+ 
+     private void validate() throws BuildException {
+         if (atLeast != null && exactly != null) {
+             throw new BuildException("Only one of atleast or exactly may be set.");
+         }
+         if (null == atLeast && null == exactly) {
+             throw new BuildException("One of atleast or exactly must be set.");
+         }
+         if (atLeast != null) {
+             try {
+                 // only created for side effect
+                 new DeweyDecimal(atLeast); //NOSONAR
+             } catch (NumberFormatException e) {
+                 throw new BuildException(
+                     "The 'atleast' attribute is not a Dewey Decimal eg 1.1.0 : "
+                     + atLeast);
+             }
+         } else {
+             try {
+                 // only created for side effect
+                 new DeweyDecimal(exactly); //NOSONAR
+             } catch (NumberFormatException e) {
+                 throw new BuildException(
+                     "The 'exactly' attribute is not a Dewey Decimal eg 1.1.0 : "
+                     + exactly);
+             }
+         }
+     }
+ 
+     /**
+      * Get the atleast attribute.
+      * @return the atleast attribute.
+      */
+     public String getAtLeast() {
+         return atLeast;
+     }
+ 
+     /**
+      * Set the atleast attribute.
+      * This is of the form major.minor.point.
+      * For example 1.7.0.
+      * @param atLeast the version to check against.
+      */
+     public void setAtLeast(String atLeast) {
+         this.atLeast = atLeast;
+     }
+ 
+     /**
+      * Get the exactly attribute.
+      * @return the exactly attribute.
+      */
+     public String getExactly() {
+         return exactly;
+     }
+ 
+     /**
+      * Set the exactly attribute.
+      * This is of the form major.minor.point.
+      * For example 1.7.0.
+      * @param exactly the version to check against.
+      */
+     public void setExactly(String exactly) {
+         this.exactly = exactly;
+     }
+ 
+ }

http://git-wip-us.apache.org/repos/asf/ant/blob/228e2e25/src/main/org/apache/tools/ant/util/JavaEnvUtils.java
----------------------------------------------------------------------
diff --cc src/main/org/apache/tools/ant/util/JavaEnvUtils.java
index e24a647,7c980c8..735675d
--- a/src/main/org/apache/tools/ant/util/JavaEnvUtils.java
+++ b/src/main/org/apache/tools/ant/util/JavaEnvUtils.java
@@@ -502,54 -504,48 +504,48 @@@ public final class JavaEnvUtils 
       * @return a list of test classes depending on the java version.
       */
      public static Vector<String> getJrePackageTestCases() {
 -        Vector<String> tests = new Vector<String>();
 +        Vector<String> tests = new Vector<>();
          tests.addElement("java.lang.Object");
-         switch(javaVersionNumber) {
-             case VERSION_9:
-             case VERSION_1_8:
-             case VERSION_1_7:
-                 tests.addElement("jdk.net.Sockets");
-                 // fall through
-             case VERSION_1_6:
-             case VERSION_1_5:
-                 tests.addElement(
-                     "com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl ");
-                 // Fall through
-             case VERSION_1_4:
-                 tests.addElement("sun.audio.AudioPlayer");
-                 if (javaVersionNumber == VERSION_1_4) {
-                     // only for 1.4, not for higher versions which fall through
-                     tests.addElement("org.apache.crimson.parser.ContentModel");
-                     tests.addElement("org.apache.xalan.processor.ProcessorImport");
-                     tests.addElement("org.apache.xml.utils.URI");
-                     tests.addElement("org.apache.xpath.XPathFactory");
-                 }
-                 tests.addElement("org.ietf.jgss.Oid");
-                 tests.addElement("org.w3c.dom.Attr");
-                 tests.addElement("org.xml.sax.XMLReader");
-                 // fall through
-             case VERSION_1_3:
-                 tests.addElement("org.omg.CORBA.Any");
-                 tests.addElement("com.sun.corba.se.internal.corba.AnyImpl");
-                 tests.addElement("com.sun.jndi.ldap.LdapURL");
-                 tests.addElement("com.sun.media.sound.Printer");
-                 tests.addElement("com.sun.naming.internal.VersionHelper");
-                 tests.addElement("com.sun.org.omg.CORBA.Initializer");
-                 tests.addElement("sunw.io.Serializable");
-                 tests.addElement("sunw.util.EventListener");
-                 // fall through
-             case VERSION_1_2:
-                 tests.addElement("javax.accessibility.Accessible");
-                 tests.addElement("sun.misc.BASE64Encoder");
-                 tests.addElement("com.sun.image.codec.jpeg.JPEGCodec");
-                 // fall through
-             case VERSION_1_1:
-             default:
-                 //things like sun.reflection, sun.misc, sun.net
-                 tests.addElement("sun.reflect.SerializationConstructorAccessorImpl");
-                 tests.addElement("sun.net.www.http.HttpClient");
-                 tests.addElement("sun.audio.AudioPlayer");
-                 break;
+         if (isAtLeastJavaVersion(JAVA_1_1)) {
+             //things like sun.reflection, sun.misc, sun.net
+             tests.addElement("sun.reflect.SerializationConstructorAccessorImpl");
+             tests.addElement("sun.net.www.http.HttpClient");
+             tests.addElement("sun.audio.AudioPlayer");
+         }
+         if (isAtLeastJavaVersion(JAVA_1_2)) {
+             tests.addElement("javax.accessibility.Accessible");
+             tests.addElement("sun.misc.BASE64Encoder");
+             tests.addElement("com.sun.image.codec.jpeg.JPEGCodec");
+         }
+         if (isAtLeastJavaVersion(JAVA_1_3)) {
+             tests.addElement("org.omg.CORBA.Any");
+             tests.addElement("com.sun.corba.se.internal.corba.AnyImpl");
+             tests.addElement("com.sun.jndi.ldap.LdapURL");
+             tests.addElement("com.sun.media.sound.Printer");
+             tests.addElement("com.sun.naming.internal.VersionHelper");
+             tests.addElement("com.sun.org.omg.CORBA.Initializer");
+             tests.addElement("sunw.io.Serializable");
+             tests.addElement("sunw.util.EventListener");
+         }
+         if (isAtLeastJavaVersion(JAVA_1_4)) {
+             tests.addElement("sun.audio.AudioPlayer");
+             if (javaVersionNumber == VERSION_1_4) {
+                 // only for 1.4, not for higher versions
+                 tests.addElement("org.apache.crimson.parser.ContentModel");
+                 tests.addElement("org.apache.xalan.processor.ProcessorImport");
+                 tests.addElement("org.apache.xml.utils.URI");
+                 tests.addElement("org.apache.xpath.XPathFactory");
+             }
+             tests.addElement("org.ietf.jgss.Oid");
+             tests.addElement("org.w3c.dom.Attr");
+             tests.addElement("org.xml.sax.XMLReader");
+         }
+         if (isAtLeastJavaVersion(JAVA_1_5)) {
+             tests.addElement(
+                 "com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl");
+         }
+         if (isAtLeastJavaVersion(JAVA_1_7)) {
+             tests.addElement("jdk.net.Sockets");
          }
          return tests;
      }

http://git-wip-us.apache.org/repos/asf/ant/blob/228e2e25/src/tests/antunit/antunit-base.xml
----------------------------------------------------------------------
diff --cc src/tests/antunit/antunit-base.xml
index e8b3529,4bd4643..30bb0ea
--- a/src/tests/antunit/antunit-base.xml
+++ b/src/tests/antunit/antunit-base.xml
@@@ -27,7 -27,14 +27,10 @@@
    <property name="test3.jar" location="${antunit.tmpdir}/test3.jar"/>
    <property name="test4.jar" location="${antunit.tmpdir}/test4.jar"/>
    <property name="test5.jar" location="${antunit.tmpdir}/test5.jar"/>
+   <condition property="jdk10+">
+     <javaversion atleast="10"/>
+   </condition>
    <available property="jdk9+" classname="java.lang.module.ModuleDescriptor"/>
 -  <available property="jdk1.8+" classname="java.lang.reflect.Executable"/>
 -  <available property="jdk1.7+" classname="java.nio.file.FileSystem"/>
 -  <available property="jdk1.6+" classname="java.net.CookieStore"/>
 -  <available property="jdk1.5+" classname="java.net.Proxy"/>
    <condition property="build.sysclasspath.only">
      <equals arg1="${build.sysclasspath}" arg2="only"/>
    </condition>

http://git-wip-us.apache.org/repos/asf/ant/blob/228e2e25/src/tests/antunit/taskdefs/javac-test.xml
----------------------------------------------------------------------
diff --cc src/tests/antunit/taskdefs/javac-test.xml
index 60bc552,48ed15d..7c1f462
--- a/src/tests/antunit/taskdefs/javac-test.xml
+++ b/src/tests/antunit/taskdefs/javac-test.xml
@@@ -265,9 -314,16 +265,16 @@@ public class Adapter implements Compile
        <delete dir="${javac-dir}/classes"/>
        <mkdir dir="${javac-dir}/classes"/>
      </sequential>
-   </target> 
+ 
+     <sequential if:set="jdk10+">
+       <echo>JDK 10+</echo>
+       <testJavac source="10" target="10"/>
+       <delete dir="${javac-dir}/classes"/>
+       <mkdir dir="${javac-dir}/classes"/>
+     </sequential>
+   </target>
  
 -  <target name="testJavacWithNativeHeaderGeneration" if="jdk1.8+" depends="setup">
 +  <target name="testJavacWithNativeHeaderGeneration" depends="setup">
      <mkdir dir="${javac-dir}/src/org/example" />
      <mkdir dir="${javac-dir}/classes"/>
      <mkdir dir="${javac-dir}/headers"/>