Browse Source

Very initial JDK 1.5 support

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275868 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 21 years ago
parent
commit
636efd4eb0
5 changed files with 31 additions and 16 deletions
  1. +7
    -6
      docs/manual/CoreTasks/javac.html
  2. +7
    -4
      src/main/org/apache/tools/ant/taskdefs/Javac.java
  3. +7
    -4
      src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java
  4. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
  5. +9
    -1
      src/main/org/apache/tools/ant/util/JavaEnvUtils.java

+ 7
- 6
docs/manual/CoreTasks/javac.html View File

@@ -52,9 +52,10 @@ attribute are:</a></p>
<li><code>classic</code> (the standard compiler of JDK 1.1/1.2) &ndash; <li><code>classic</code> (the standard compiler of JDK 1.1/1.2) &ndash;
<code>javac1.1</code> and <code>javac1.1</code> and
<code>javac1.2</code> can be used as aliases.</li> <code>javac1.2</code> can be used as aliases.</li>
<li><code>modern</code> (the standard compiler of JDK 1.3/1.4) &ndash;
<li><code>modern</code> (the standard compiler of JDK 1.3/1.4/1.5) &ndash;
<code>javac1.3</code> and <code>javac1.3</code> and
<code>javac1.4</code> can be used as aliases.</li>
<code>javac1.4</code> and
<code>javac1.5</code> can be used as aliases.</li>
<li><code>jikes</code> (the <a <li><code>jikes</code> (the <a
href="http://oss.software.ibm.com/developerworks/opensource/jikes/" target="_top">Jikes</a> href="http://oss.software.ibm.com/developerworks/opensource/jikes/" target="_top">Jikes</a>
compiler).</li> compiler).</li>
@@ -235,7 +236,7 @@ invoking the compiler.</p>
<td valign="top">Generate class files for specific VM version <td valign="top">Generate class files for specific VM version
(e.g., <code>1.1</code> or <code>1.2</code>). <b>Note that the (e.g., <code>1.1</code> or <code>1.2</code>). <b>Note that the
default value depends on the JVM that is running Ant. In default value depends on the JVM that is running Ant. In
particular, if you use JDK 1.4 the generated classes will not be
particular, if you use JDK 1.4+ the generated classes will not be
usable for a 1.1 Java VM unless you explicitly set this attribute usable for a 1.1 Java VM unless you explicitly set this attribute
to the value 1.1 (which is the default value for JDK 1.1 to to the value 1.1 (which is the default value for JDK 1.1 to
1.3).</b></td> 1.3).</b></td>
@@ -310,12 +311,12 @@ invoking the compiler.</p>
<td valign="top">source</td> <td valign="top">source</td>


<td valign="top">Value of the <code>-source</code> command-line <td valign="top">Value of the <code>-source</code> command-line
switch; will be ignored by all implementations except
switch; will be ignored by all implementations prior to
<code>javac1.4</code> (or <code>modern</code> when Ant is not <code>javac1.4</code> (or <code>modern</code> when Ant is not
running in a 1.3 VM) and <code>jikes</code>.<br> If you use this running in a 1.3 VM) and <code>jikes</code>.<br> If you use this
attribute together with <code>jikes</code>, you must make sure attribute together with <code>jikes</code>, you must make sure
that your version of jikes supports the <code>-source</code> that your version of jikes supports the <code>-source</code>
switch.<br> Legal values are <code>1.3</code> and <code>1.4</code>
switch.<br> Legal values are <code>1.3</code>, <code>1.4</code> and <code>1.5</code>
&ndash; by default, no <code>-source</code> argument will be used &ndash; by default, no <code>-source</code> argument will be used
at all.</td> at all.</td>


@@ -594,7 +595,7 @@ while all others are <code>false</code>.</p>
<code>&lt;javac&gt;</code>.</p> <code>&lt;javac&gt;</code>.</p>


<hr> <hr>
<p align="center">Copyright &copy; 2000-2003 Apache Software Foundation.
<p align="center">Copyright &copy; 2000-2004 Apache Software Foundation.
All rights Reserved.</p> All rights Reserved.</p>


</body> </body>


+ 7
- 4
src/main/org/apache/tools/ant/taskdefs/Javac.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
* *
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* Copyright (c) 2000-2004 The Apache Software Foundation. All rights
* reserved. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -155,6 +155,8 @@ public class Javac extends MatchingTask {
facade = new FacadeTaskHelper("javac1.3"); facade = new FacadeTaskHelper("javac1.3");
} else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_4)) { } else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_4)) {
facade = new FacadeTaskHelper("javac1.4"); facade = new FacadeTaskHelper("javac1.4");
} else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_5)) {
facade = new FacadeTaskHelper("javac1.5");
} else { } else {
facade = new FacadeTaskHelper("classic"); facade = new FacadeTaskHelper("classic");
} }
@@ -198,7 +200,7 @@ public class Javac extends MatchingTask {
* *
* If you use this attribute together with jikes, you must * If you use this attribute together with jikes, you must
* make sure that your version of jikes supports the -source switch. * make sure that your version of jikes supports the -source switch.
* Legal values are 1.3 and 1.4 - by default, no -source argument
* Legal values are 1.3, 1.4 and 1.5 - by default, no -source argument
* will be used at all. * will be used at all.
* *
* @param v Value to assign to source. * @param v Value to assign to source.
@@ -845,7 +847,7 @@ public class Javac extends MatchingTask {
* *
* @param compilerImpl the name of the compiler implementation * @param compilerImpl the name of the compiler implementation
* @return true if compilerImpl is "modern", "classic", "javac1.1", * @return true if compilerImpl is "modern", "classic", "javac1.1",
* "javac1.2", "javac1.3" or "javac1.4".
* "javac1.2", "javac1.3", "javac1.4" or "javac1.5".
*/ */
protected boolean isJdkCompiler(String compilerImpl) { protected boolean isJdkCompiler(String compilerImpl) {
return "modern".equals(compilerImpl) return "modern".equals(compilerImpl)
@@ -853,7 +855,8 @@ public class Javac extends MatchingTask {
|| "javac1.1".equals(compilerImpl) || "javac1.1".equals(compilerImpl)
|| "javac1.2".equals(compilerImpl) || "javac1.2".equals(compilerImpl)
|| "javac1.3".equals(compilerImpl) || "javac1.3".equals(compilerImpl)
|| "javac1.4".equals(compilerImpl);
|| "javac1.4".equals(compilerImpl)
|| "javac1.5".equals(compilerImpl);
} }


/** /**


+ 7
- 4
src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
* *
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* Copyright (c) 2001-2004 The Apache Software Foundation. All rights
* reserved. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -80,7 +80,7 @@ public class CompilerAdapterFactory {
* <ul><li>jikes = jikes compiler * <ul><li>jikes = jikes compiler
* <li>classic, javac1.1, javac1.2 = the standard compiler from JDK * <li>classic, javac1.1, javac1.2 = the standard compiler from JDK
* 1.1/1.2 * 1.1/1.2
* <li>modern, javac1.3, javac1.4 = the compiler of JDK 1.3+
* <li>modern, javac1.3, javac1.4, javac1.5 = the compiler of JDK 1.3+
* <li>jvc, microsoft = the command line compiler from Microsoft's SDK * <li>jvc, microsoft = the command line compiler from Microsoft's SDK
* for Java / Visual J++ * for Java / Visual J++
* <li>kjc = the kopi compiler</li> * <li>kjc = the kopi compiler</li>
@@ -100,7 +100,9 @@ public class CompilerAdapterFactory {
throws BuildException { throws BuildException {
boolean isClassicCompilerSupported = true; boolean isClassicCompilerSupported = true;
//as new versions of java come out, add them to this test //as new versions of java come out, add them to this test
if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_4)) {
if (!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)
&& !JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_2)
&& !JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_3)) {
isClassicCompilerSupported = false; isClassicCompilerSupported = false;
} }


@@ -127,7 +129,8 @@ public class CompilerAdapterFactory {
//but on java>=1.4 we just bail out early //but on java>=1.4 we just bail out early
if (compilerType.equalsIgnoreCase("modern") if (compilerType.equalsIgnoreCase("modern")
|| compilerType.equalsIgnoreCase("javac1.3") || compilerType.equalsIgnoreCase("javac1.3")
|| compilerType.equalsIgnoreCase("javac1.4")) {
|| compilerType.equalsIgnoreCase("javac1.4")
|| compilerType.equalsIgnoreCase("javac1.5")) {
// does the modern compiler exist? // does the modern compiler exist?
if (doesModernCompilerExist()) { if (doesModernCompilerExist()) {
return new Javac13(); return new Javac13();


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
* *
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* Copyright (c) 2001-2004 The Apache Software Foundation. All rights
* reserved. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without


+ 9
- 1
src/main/org/apache/tools/ant/util/JavaEnvUtils.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
* *
* Copyright (c) 2002-2003 The Apache Software Foundation. All rights
* Copyright (c) 2002-2004 The Apache Software Foundation. All rights
* reserved. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -96,6 +96,8 @@ public class JavaEnvUtils {
public static final String JAVA_1_3 = "1.3"; public static final String JAVA_1_3 = "1.3";
/** Version constant for Java 1.4 */ /** Version constant for Java 1.4 */
public static final String JAVA_1_4 = "1.4"; public static final String JAVA_1_4 = "1.4";
/** Version constant for Java 1.5 */
public static final String JAVA_1_5 = "1.5";


/** array of packages in the runtime */ /** array of packages in the runtime */
private static Vector jrePackages; private static Vector jrePackages;
@@ -104,6 +106,7 @@ public class JavaEnvUtils {
static { static {


// Determine the Java version by looking at available classes // Determine the Java version by looking at available classes
// java.lang.Readable was introduced in JDK 1.5
// java.lang.CharSequence was introduced in JDK 1.4 // java.lang.CharSequence was introduced in JDK 1.4
// java.lang.StrictMath was introduced in JDK 1.3 // java.lang.StrictMath was introduced in JDK 1.3
// java.lang.ThreadLocal was introduced in JDK 1.2 // java.lang.ThreadLocal was introduced in JDK 1.2
@@ -125,6 +128,9 @@ public class JavaEnvUtils {
Class.forName("java.lang.CharSequence"); Class.forName("java.lang.CharSequence");
javaVersion = JAVA_1_4; javaVersion = JAVA_1_4;
javaVersionNumber++; javaVersionNumber++;
Class.forName("java.lang.Readable");
javaVersion = JAVA_1_5;
javaVersionNumber++;
} catch (Throwable t) { } catch (Throwable t) {
// swallow as we've hit the max class version that // swallow as we've hit the max class version that
// we have // we have
@@ -275,6 +281,7 @@ public class JavaEnvUtils {
private static void buildJrePackages() { private static void buildJrePackages() {
jrePackages = new Vector(); jrePackages = new Vector();
switch(javaVersionNumber) { switch(javaVersionNumber) {
case 15:
case 14: case 14:
jrePackages.addElement("org.apache.crimson"); jrePackages.addElement("org.apache.crimson");
jrePackages.addElement("org.apache.xalan"); jrePackages.addElement("org.apache.xalan");
@@ -317,6 +324,7 @@ public class JavaEnvUtils {
Vector tests = new Vector(); Vector tests = new Vector();
tests.addElement("java.lang.Object"); tests.addElement("java.lang.Object");
switch(javaVersionNumber) { switch(javaVersionNumber) {
case 15:
case 14: case 14:
tests.addElement("sun.audio.AudioPlayer"); tests.addElement("sun.audio.AudioPlayer");
tests.addElement("org.apache.crimson.parser.ContentModel"); tests.addElement("org.apache.crimson.parser.ContentModel");


Loading…
Cancel
Save