git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1236803 13f79535-47bb-0310-9956-ffa450edef68master
@@ -178,6 +178,8 @@ Other changes: | |||
algorithms. | |||
Bugzilla Report 52344. | |||
* Initial support for Java 8. | |||
Changes from Ant 1.8.1 TO Ant 1.8.2 | |||
=================================== | |||
@@ -369,6 +369,7 @@ | |||
<available property="jdk1.5+" classname="java.net.Proxy"/> | |||
<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="kaffe" classname="kaffe.util.NotImplemented"/> | |||
<available property="harmony" | |||
classname="org.apache.harmony.luni.util.Base64"/> | |||
@@ -72,12 +72,13 @@ attribute are:</a></p> | |||
<li><code>classic</code> (the standard compiler of JDK 1.1/1.2) – | |||
<code>javac1.1</code> and | |||
<code>javac1.2</code> can be used as aliases.</li> | |||
<li><code>modern</code> (the standard compiler of JDK 1.3/1.4/1.5/1.6/1.7) – | |||
<li><code>modern</code> (the standard compiler of JDK 1.3/1.4/1.5/1.6/1.7/1.8) – | |||
<code>javac1.3</code> and | |||
<code>javac1.4</code> and | |||
<code>javac1.5</code> and | |||
<code>javac1.6</code> and | |||
<code>javac1.7</code> (<em>since Ant 1.8.2</em>) can be used as aliases.</li> | |||
<code>javac1.7</code> (<em>since Ant 1.8.2</em>) and | |||
<code>javac1.8</code> (<em>since Ant 1.8.3</em>) can be used as aliases.</li> | |||
<li><code>jikes</code> (the <a | |||
href="http://jikes.sourceforge.net/" target="_top">Jikes</a> | |||
compiler).</li> | |||
@@ -80,6 +80,7 @@ public class Javac extends MatchingTask { | |||
private static final String FAIL_MSG | |||
= "Compile failed; see the compiler error output for details."; | |||
private static final String JAVAC18 = "javac1.8"; | |||
private static final String JAVAC17 = "javac1.7"; | |||
private static final String JAVAC16 = "javac1.6"; | |||
private static final String JAVAC15 = "javac1.5"; | |||
@@ -149,6 +150,8 @@ public class Javac extends MatchingTask { | |||
return JAVAC16; | |||
} else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_7)) { | |||
return JAVAC17; | |||
} else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_8)) { | |||
return JAVAC18; | |||
} else { | |||
return CLASSIC; | |||
} | |||
@@ -600,7 +603,7 @@ public class Javac extends MatchingTask { | |||
/** | |||
* Sets the target VM that the classes will be compiled for. Valid | |||
* values depend on the compiler, for jdk 1.4 the valid values are | |||
* "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "5", "6" and "7". | |||
* "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "5", "6", "7" and "8". | |||
* @param target the target VM | |||
*/ | |||
public void setTarget(String target) { | |||
@@ -765,6 +768,7 @@ public class Javac extends MatchingTask { | |||
private String getAltCompilerName(String anImplementation) { | |||
if (JAVAC17.equalsIgnoreCase(anImplementation) | |||
|| JAVAC18.equalsIgnoreCase(anImplementation) | |||
|| JAVAC16.equalsIgnoreCase(anImplementation) | |||
|| JAVAC15.equalsIgnoreCase(anImplementation) | |||
|| JAVAC14.equalsIgnoreCase(anImplementation) | |||
@@ -778,6 +782,7 @@ public class Javac extends MatchingTask { | |||
if (MODERN.equalsIgnoreCase(anImplementation)) { | |||
String nextSelected = assumedJavaVersion(); | |||
if (JAVAC17.equalsIgnoreCase(nextSelected) | |||
|| JAVAC18.equalsIgnoreCase(nextSelected) | |||
|| JAVAC16.equalsIgnoreCase(nextSelected) | |||
|| JAVAC15.equalsIgnoreCase(nextSelected) | |||
|| JAVAC14.equalsIgnoreCase(nextSelected) | |||
@@ -1014,6 +1019,7 @@ public class Javac extends MatchingTask { | |||
protected boolean isJdkCompiler(String compilerImpl) { | |||
return MODERN.equals(compilerImpl) | |||
|| CLASSIC.equals(compilerImpl) | |||
|| JAVAC18.equals(compilerImpl) | |||
|| JAVAC17.equals(compilerImpl) | |||
|| JAVAC16.equals(compilerImpl) | |||
|| JAVAC15.equals(compilerImpl) | |||
@@ -348,7 +348,7 @@ public abstract class DefaultCompilerAdapter | |||
} else { | |||
cmd.createArgument().setValue(source); | |||
} | |||
} else if ((assumeJava15() || assumeJava16() || assumeJava17()) | |||
} else if ((assumeJava15() || assumeJava16() || assumeJava17() || assumeJava18()) | |||
&& attributes.getTarget() != null) { | |||
String t = attributes.getTarget(); | |||
if (t.equals("1.1") || t.equals("1.2") || t.equals("1.3") | |||
@@ -360,10 +360,15 @@ public abstract class DefaultCompilerAdapter | |||
} | |||
setImplicitSourceSwitch((assumeJava15() || assumeJava16()) | |||
? "1.5 in JDK 1.5 and 1.6" | |||
: "1.7 in JDK 1.7", | |||
: (assumeJava17() | |||
? "1.7 in JDK 1.7" | |||
: "1.8 in JDK 1.8"), | |||
cmd, t, s); | |||
} else if (assumeJava17() && (t.equals("1.5") || t.equals("1.6"))) { | |||
setImplicitSourceSwitch("1.7 in JDK 1.7", cmd, t, t); | |||
} else if (assumeJava18() && | |||
(t.equals("1.5") || t.equals("1.6") || t.equals("1.7"))) { | |||
setImplicitSourceSwitch("1.8 in JDK 1.8", cmd, t, t); | |||
} | |||
} | |||
return cmd; | |||
@@ -637,6 +642,21 @@ public abstract class DefaultCompilerAdapter | |||
&& JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_7)); | |||
} | |||
/** | |||
* Shall we assume JDK 1.8 command line switches? | |||
* @return true if JDK 1.8 | |||
* @since Ant 1.8.3 | |||
*/ | |||
protected boolean assumeJava18() { | |||
return "javac1.8".equals(attributes.getCompilerVersion()) | |||
|| ("classic".equals(attributes.getCompilerVersion()) | |||
&& JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_8)) | |||
|| ("modern".equals(attributes.getCompilerVersion()) | |||
&& JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_8)) | |||
|| ("extJavac".equals(attributes.getCompilerVersion()) | |||
&& JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_8)); | |||
} | |||
/** | |||
* Combines a user specified bootclasspath with the system | |||
* bootclasspath taking build.sysclasspath into account. | |||
@@ -94,6 +94,11 @@ public final class JavaEnvUtils { | |||
/** Number Version constant for Java 1.7 */ | |||
public static final int VERSION_1_7 = 17; | |||
/** Version constant for Java 1.8 */ | |||
public static final String JAVA_1_8 = "1.8"; | |||
/** Number Version constant for Java 1.8 */ | |||
public static final int VERSION_1_8 = 18; | |||
/** Whether this is the Kaffe VM */ | |||
private static boolean kaffeDetected; | |||
/** Whether this is the GNU VM (gcj/gij) */ | |||
@@ -140,6 +145,9 @@ public final class JavaEnvUtils { | |||
Class.forName("java.nio.file.FileSystem"); | |||
javaVersion = JAVA_1_7; | |||
javaVersionNumber++; | |||
Class.forName("java.lang.reflect.Executable"); | |||
javaVersion = JAVA_1_8; | |||
javaVersionNumber++; | |||
} catch (Throwable t) { | |||
// swallow as we've hit the max class version that | |||
// we have | |||
@@ -370,6 +378,7 @@ public final class JavaEnvUtils { | |||
private static void buildJrePackages() { | |||
jrePackages = new Vector(); | |||
switch(javaVersionNumber) { | |||
case VERSION_1_8: | |||
case VERSION_1_7: | |||
case VERSION_1_6: | |||
case VERSION_1_5: | |||
@@ -421,6 +430,7 @@ public final class JavaEnvUtils { | |||
Vector tests = new Vector(); | |||
tests.addElement("java.lang.Object"); | |||
switch(javaVersionNumber) { | |||
case VERSION_1_8: | |||
case VERSION_1_7: | |||
case VERSION_1_6: | |||
case VERSION_1_5: | |||
@@ -26,6 +26,7 @@ | |||
<property name="test3.jar" location="${java.io.tmpdir}/test3.jar"/> | |||
<property name="test4.jar" location="${java.io.tmpdir}/test4.jar"/> | |||
<property name="test5.jar" location="${java.io.tmpdir}/test5.jar"/> | |||
<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"/> | |||