From b1c63b2dee167ba4ecc1d135a4175e0b831ebbcd Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Fri, 3 Mar 2006 20:56:53 +0000 Subject: [PATCH] preliminary Mustang support git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@382927 13f79535-47bb-0310-9956-ffa450edef68 --- build.xml | 1 + docs/manual/CoreTasks/javac.html | 7 ++--- .../org/apache/tools/ant/taskdefs/Javac.java | 27 ++++++++++++------- .../compilers/DefaultCompilerAdapter.java | 22 ++++++++++++--- .../apache/tools/ant/util/JavaEnvUtils.java | 9 ++++++- 5 files changed, 49 insertions(+), 17 deletions(-) diff --git a/build.xml b/build.xml index 4beea70fc..a82f1ca1a 100644 --- a/build.xml +++ b/build.xml @@ -398,6 +398,7 @@ +

  • classic (the standard compiler of JDK 1.1/1.2) – javac1.1 and javac1.2 can be used as aliases.
  • -
  • modern (the standard compiler of JDK 1.3/1.4/1.5) – +
  • modern (the standard compiler of JDK 1.3/1.4/1.5/1.6) – javac1.3 and javac1.4 and - javac1.5 can be used as aliases.
  • + javac1.5 and + javac1.6 can be used as aliases.
  • jikes (the Jikes compiler).
  • @@ -613,7 +614,7 @@ while all others are false.

    <javac>.


    -

    Copyright © 2000-2005 The Apache Software Foundation. +

    Copyright © 2000-2006 The Apache Software Foundation. All rights Reserved.

    diff --git a/src/main/org/apache/tools/ant/taskdefs/Javac.java b/src/main/org/apache/tools/ant/taskdefs/Javac.java index 3b4c8a451..02233738f 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Javac.java +++ b/src/main/org/apache/tools/ant/taskdefs/Javac.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2005 The Apache Software Foundation + * Copyright 2000-2006 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -69,6 +69,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 JAVAC16 = "javac1.6"; private static final String JAVAC15 = "javac1.5"; private static final String JAVAC14 = "javac1.4"; private static final String JAVAC13 = "javac1.3"; @@ -126,6 +127,8 @@ public class Javac extends MatchingTask { return JAVAC14; } else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_5)) { return JAVAC15; + } else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_6)) { + return JAVAC16; } else { return CLASSIC; } @@ -167,10 +170,10 @@ public class Javac extends MatchingTask { * Value of the -source command-line switch; will be ignored * by all implementations except modern and jikes. * - * If you use this attribute together with jikes, you must - * make sure that your version of jikes supports the -source switch. - * Legal values are 1.3, 1.4 and 1.5 - by default, no -source argument - * will be used at all. + * If you use this attribute together with jikes, you must make + * sure that your version of jikes supports the -source switch. + * Legal values are 1.3, 1.4, 1.5, and 5 - by default, no + * -source argument will be used at all. * * @param v Value to assign to source. */ @@ -573,7 +576,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" and "1.5". + * "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "5" and "6". * @param target the target VM */ public void setTarget(String target) { @@ -735,7 +738,8 @@ public class Javac extends MatchingTask { } private String getAltCompilerName(String anImplementation) { - if (JAVAC15.equalsIgnoreCase(anImplementation) + if (JAVAC16.equalsIgnoreCase(anImplementation) + || JAVAC15.equalsIgnoreCase(anImplementation) || JAVAC14.equalsIgnoreCase(anImplementation) || JAVAC13.equalsIgnoreCase(anImplementation)) { return MODERN; @@ -746,7 +750,8 @@ public class Javac extends MatchingTask { } if (MODERN.equalsIgnoreCase(anImplementation)) { String nextSelected = assumedJavaVersion(); - if (JAVAC15.equalsIgnoreCase(nextSelected) + if (JAVAC16.equalsIgnoreCase(nextSelected) + || JAVAC15.equalsIgnoreCase(nextSelected) || JAVAC14.equalsIgnoreCase(nextSelected) || JAVAC13.equalsIgnoreCase(nextSelected)) { return nextSelected; @@ -854,12 +859,14 @@ public class Javac extends MatchingTask { * Is the compiler implementation a jdk compiler * * @param compilerImpl the name of the compiler implementation - * @return true if compilerImpl is "modern", "classic", "javac1.1", - * "javac1.2", "javac1.3", "javac1.4" or "javac1.5". + * @return true if compilerImpl is "modern", "classic", + * "javac1.1", "javac1.2", "javac1.3", "javac1.4", "javac1.5" or + * "javac1.6". */ protected boolean isJdkCompiler(String compilerImpl) { return MODERN.equals(compilerImpl) || CLASSIC.equals(compilerImpl) + || JAVAC16.equals(compilerImpl) || JAVAC15.equals(compilerImpl) || JAVAC14.equals(compilerImpl) || JAVAC13.equals(compilerImpl) diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java b/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java index 71fddb2ce..0cb7ed532 100644 --- a/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java +++ b/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2001-2005 The Apache Software Foundation + * Copyright 2001-2006 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -322,7 +322,8 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter { } else { cmd.createArgument().setValue(source); } - } else if (assumeJava15() && attributes.getTarget() != null) { + } else if ((assumeJava15() || assumeJava16()) + && attributes.getTarget() != null) { String t = attributes.getTarget(); if (t.equals("1.1") || t.equals("1.2") || t.equals("1.3") || t.equals("1.4")) { @@ -334,7 +335,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter { attributes.log("", Project.MSG_WARN); attributes.log(" WARNING", Project.MSG_WARN); attributes.log("", Project.MSG_WARN); - attributes.log("The -source switch defaults to 1.5 in JDK 1.5.", + attributes.log("The -source switch defaults to 1.5 in JDK 1.5 and 1.6.", Project.MSG_WARN); attributes.log("If you specify -target " + t + " you now must also specify -source " + s @@ -590,6 +591,21 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter { && JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_5)); } + /** + * Shall we assume JDK 1.6 command line switches? + * @return true if JDK 1.6 + * @since Ant 1.7 + */ + protected boolean assumeJava16() { + return "javac1.6".equals(attributes.getCompilerVersion()) + || ("classic".equals(attributes.getCompilerVersion()) + && JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_6)) + || ("modern".equals(attributes.getCompilerVersion()) + && JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_6)) + || ("extJavac".equals(attributes.getCompilerVersion()) + && JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_6)); + } + /** * Combines a user specified bootclasspath with the system * bootclasspath taking build.sysclasspath into account. diff --git a/src/main/org/apache/tools/ant/util/JavaEnvUtils.java b/src/main/org/apache/tools/ant/util/JavaEnvUtils.java index 8e27ec690..231531ada 100644 --- a/src/main/org/apache/tools/ant/util/JavaEnvUtils.java +++ b/src/main/org/apache/tools/ant/util/JavaEnvUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2005 The Apache Software Foundation + * Copyright 2002-2006 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,6 +66,8 @@ public final class JavaEnvUtils { public static final String JAVA_1_4 = "1.4"; /** Version constant for Java 1.5 */ public static final String JAVA_1_5 = "1.5"; + /** Version constant for Java 1.6 */ + public static final String JAVA_1_6 = "1.6"; /** Whether this is the Kaffe VM */ private static boolean kaffeDetected; @@ -102,6 +104,9 @@ public final class JavaEnvUtils { Class.forName("java.lang.Readable"); javaVersion = JAVA_1_5; javaVersionNumber++; + Class.forName("java.util.Service"); + javaVersion = JAVA_1_6; + javaVersionNumber++; } catch (Throwable t) { // swallow as we've hit the max class version that // we have @@ -284,6 +289,7 @@ public final class JavaEnvUtils { private static void buildJrePackages() { jrePackages = new Vector(); switch(javaVersionNumber) { + case 16: case 15: //In Java1.5, the apache stuff moved. jrePackages.addElement("com.sun.org.apache"); @@ -333,6 +339,7 @@ public final class JavaEnvUtils { Vector tests = new Vector(); tests.addElement("java.lang.Object"); switch(javaVersionNumber) { + case 16: case 15: tests.addElement("com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl "); case 14: