Author: jglick
Date: Wed Aug 26 18:48:21 2009
New Revision: 808156
URL: http://svn.apache.org/viewvc?rev=808156&view=rev
Log:
Some miscellaneous updates given that JDK 1.4 can be assumed.
The biggest outstanding JDK 1.3 code is in Locator but I am scared to touch it.
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/RuntimeConfigurable.java
ant/core/trunk/src/main/org/apache/tools/ant/launch/Locator.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Execute.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Parallel.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/IsReachable.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/SetProxy.java
ant/core/trunk/src/main/org/apache/tools/ant/types/RegularExpression.java
ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/launch/LocatorTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java
Modified: ant/core/trunk/src/main/org/apache/tools/ant/RuntimeConfigurable.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/RuntimeConfigurable.java?rev=808156&r1=808155&r2=808156&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/RuntimeConfigurable.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/RuntimeConfigurable.java Wed
Aug 26 18:48:21 2009
@@ -69,13 +69,14 @@
* exact order. The following code is copied from AttributeImpl.
* We could also just use SAX2 Attributes and convert to SAX1 ( DOM
* attribute Nodes can also be stored in SAX2 Attributes )
- * XXX under JDK 1.4 you can just use a LinkedHashMap for this purpose
-jglick
* The only exception to this order is the treatment of
* refid. A number of datatypes check if refid is set
* when other attributes are set. This check will not
* work if the build script has the other attribute before
* the "refid" attribute, so now (ANT 1.7) the refid
* attribute will be processed first.
+ * (Other than treatment of refid, could just use a LinkedHashMap,
+ * but peterreilly's rev 452635 includes no regression test.)
*/
private List/*<String>*/ attributeNames = null;
Modified: ant/core/trunk/src/main/org/apache/tools/ant/launch/Locator.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/launch/Locator.java?rev=808156&r1=808155&r2=808156&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/launch/Locator.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/launch/Locator.java Wed Aug 26
18:48:21 2009
@@ -165,7 +165,7 @@
*
* <p>Will be an absolute path if the given URI is absolute.</p>
*
- * <p>Prior to Java 1.4,
+ * <p>Prior to Java 1.4,<!-- XXX is JDK version actually relevant? -->
* swallows '%' that are not followed by two characters.</p>
*
* See <a href="http://www.w3.org/TR/xml11/#dt-sysid">dt-sysid</a>
@@ -178,76 +178,55 @@
* @since Ant 1.6
*/
public static String fromURI(String uri) {
+ return fromURIJava13(uri);
// #buzilla8031: first try Java 1.4.
- String result = null;
- //result = fromUriJava14(uri);
- if (result == null) {
- result = fromURIJava13(uri);
- }
- return result;
+ // XXX should use java.net.URI now that we can rely on 1.4...
+ // but check for UNC-related regressions, e.g. #42275
+ // (and remember that \\server\share\file -> file:////server/share/file
+ // rather than -> file://server/share/file as it should;
+ // fixed only in JDK 7's java.nio.file.Path.toUri)
+ // return fromUriJava14(uri);
}
-
/**
* Java1.4+ code to extract the path from the URI.
* @param uri
* @return null if a conversion was not possible
*/
+ /* currently unused:
private static String fromUriJava14(String uri) {
- Class uriClazz = null;
- try {
- uriClazz = Class.forName("java.net.URI");
- } catch (ClassNotFoundException cnfe) {
- // Fine, Java 1.3 or earlier, do it by hand.
- return null;
- }
// Also check for properly formed URIs. Ant formerly recommended using
// nonsense URIs such as "file:./foo.xml" in XML includes. You
shouldn't
// do that (just "foo.xml" is correct) but for compatibility we
special-case
// things when the path is not absolute, and fall back to the old
parsing behavior.
- if (uriClazz != null && uri.startsWith("file:/")) {
+ if (uri.startsWith("file:/")) {
try {
- java.lang.reflect.Method createMethod
- = uriClazz.getMethod("create", new
Class[]{String.class});
- Object uriObj = createMethod.invoke(null, new
Object[]{encodeURI(uri)});
- java.lang.reflect.Constructor fileConst
- = File.class.getConstructor(new Class[]{uriClazz});
- File f = (File) fileConst.newInstance(new Object[]{uriObj});
+ File f = new File(URI.create(encodeURI(uri)));
//bug #42227 forgot to decode before returning
return decodeUri(f.getAbsolutePath());
- } catch (java.lang.reflect.InvocationTargetException e) {
- Throwable e2 = e.getTargetException();
- if (e2 instanceof IllegalArgumentException) {
- // Bad URI, pass this on.
- // no, this is downgraded to a warning after various
- // JRE bugs surfaced. Hand off
- // to our built in code on a failure
- //throw new IllegalArgumentException(
- // "Bad URI " + uri + ":" + e2.getMessage(), e2);
- e2.printStackTrace();
-
- } else {
- // Unexpected target exception? Should not happen.
- e2.printStackTrace();
- }
+ } catch (IllegalArgumentException e) {
+ // Bad URI, pass this on.
+ // no, this is downgraded to a warning after various
+ // JRE bugs surfaced. Hand off
+ // to our built in code on a failure
+ //throw new IllegalArgumentException(
+ // "Bad URI " + uri + ":" + e.getMessage(), e);
+ e.printStackTrace();
} catch (Exception e) {
- // Reflection problems? Should not happen, debug.
+ // Unexpected exception? Should not happen.
e.printStackTrace();
}
}
return null;
}
-
-
-
+ */
/**
- * This method is public for testing; we may delete it without any warning
-it is not part of Ant's stable API.
* @param uri uri to expand
* @return the decoded URI
* @since Ant1.7.1
*/
- public static String fromURIJava13(String uri) {
+ private static String fromURIJava13(String uri) {
// Fallback method for Java 1.3 or earlier.
URL url = null;
@@ -409,7 +388,7 @@
* Convert a File to a URL.
* File.toURL() does not encode characters like #.
* File.toURI() has been introduced in java 1.4, so
- * ANT cannot use it (except by reflection)
+ * Ant cannot use it (except by reflection) <!-- XXX no longer true -->
* FileUtils.toURI() cannot be used by Locator.java
* Implemented this way.
* File.toURL() adds file: and changes '\' to '/' for dos OSes
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Execute.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Execute.java?rev=808156&r1=808155&r2=808156&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Execute.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Execute.java Wed Aug
26 18:48:21 2009
@@ -1146,7 +1146,7 @@
/**
* Launches the given command in a new process, in the given working
- * directory. Note that under Java 1.3.1, 1.4.0 and 1.4.1 on VMS this
+ * directory. Note that under Java 1.4.0 and 1.4.1 on VMS this
* method only works if <code>workingDir</code> is null or the logical
* JAVA$FORK_SUPPORT_CHDIR needs to be set to TRUE.
* @param project the Ant project.
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Parallel.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Parallel.java?rev=808156&r1=808155&r2=808156&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Parallel.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Parallel.java Wed Aug
26 18:48:21 2009
@@ -153,10 +153,8 @@
/**
* Dynamically generates the number of threads to execute based on the
* number of available processors (via
- * <code>java.lang.Runtime.availableProcessors()</code>). Requires a J2SE
- * 1.4 VM, and it will overwrite the value set in threadCount.
- * If used in a 1.1, 1.2, or 1.3 VM then the task will defer to
- * <code>threadCount</code>.; optional
+ * <code>java.lang.Runtime.availableProcessors()</code>).
+ * Will overwrite the value set in threadCount; optional
* @param numThreadsPerProcessor Number of threads to create per available
* processor.
*
@@ -170,7 +168,7 @@
* simultaneously. If there are less tasks than threads then all will be
* executed at once, if there are more then only <code>threadCount</code>
* tasks will be executed at one time. If <code>threadsPerProcessor</code>
- * is set and the JVM is at least a 1.4 VM then this value is
+ * is set then this value is
* ignored.; optional
*
* @param numThreads total number of threads.
@@ -213,10 +211,8 @@
*/
private void updateThreadCounts() {
if (numThreadsPerProcessor != 0) {
- int numProcessors = getNumProcessors();
- if (numProcessors != 0) {
- numThreads = numProcessors * numThreadsPerProcessor;
- }
+ numThreads = Runtime.getRuntime().availableProcessors() *
+ numThreadsPerProcessor;
}
}
@@ -409,26 +405,6 @@
}
/**
- * Determine the number of processors. Only effective on Java 1.4+
- *
- * @return the number of processors available or 0 if not determinable.
- */
- private int getNumProcessors() {
- try {
- Class[] paramTypes = {};
- Method availableProcessors =
- Runtime.class.getMethod("availableProcessors", paramTypes);
-
- Object[] args = {};
- Integer ret = (Integer)
availableProcessors.invoke(Runtime.getRuntime(), args);
- return ret.intValue();
- } catch (Exception e) {
- // return a bogus number
- return 0;
- }
- }
-
- /**
* thread that execs a task
*/
private class TaskRunnable implements Runnable {
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/IsReachable.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/IsReachable.java?rev=808156&r1=808155&r2=808156&view=diff
==============================================================================
---
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/IsReachable.java
(original)
+++
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/IsReachable.java
Wed Aug 26 18:48:21 2009
@@ -46,7 +46,7 @@
* on the floor. Similarly, a host may be detected as reachable with ICMP, but
not
* reachable on other ports (i.e. port 80), because of firewalls.
* <p/>
- * Requires Java1.5+ to work properly. On Java1.4 and earlier, if a hostname
+ * Requires Java 5+ to work properly. On Java 1.4, if a hostname
* can be resolved, the destination is assumed to be reachable.
*
* @since Ant 1.7
@@ -194,7 +194,7 @@
reachable = false;
}
} catch (NoSuchMethodException e) {
- //java1.4 or earlier
+ //java1.4
log("Not found: InetAddress." + METHOD_NAME, Project.MSG_VERBOSE);
log(MSG_NO_REACHABLE_TEST);
reachable = true;
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java?rev=808156&r1=808155&r2=808156&view=diff
==============================================================================
---
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java
(original)
+++
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java
Wed Aug 26 18:48:21 2009
@@ -56,16 +56,16 @@
* requires the Jakarta Oro Package).
*
* <pre>
- * For jdk <= 1.3, there are two available implementations:
- * org.apache.tools.ant.util.regexp.JakartaOroRegexp (the default)
+ * Available implementations:
+ *
+ * org.apache.tools.ant.util.regexp.JakartaOroRegexp (the default if
available)
* Requires the jakarta-oro package
*
* org.apache.tools.ant.util.regexp.JakartaRegexpRegexp
* Requires the jakarta-regexp package
*
- * For jdk >= 1.4 an additional implementation is available:
- * org.apache.tools.ant.util.regexp.Jdk14RegexpRegexp
- * Requires the jdk 1.4 built in regular expression package.
+ * org.apache.tools.ant.util.regexp.Jdk14RegexpRegexp (fallback default)
+ * Uses Java's built-in regular expression package
*
* Usage:
*
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/SetProxy.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/SetProxy.java?rev=808156&r1=808155&r2=808156&view=diff
==============================================================================
---
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/SetProxy.java
(original)
+++
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/SetProxy.java
Wed Aug 26 18:48:21 2009
@@ -47,7 +47,7 @@
* stop using the socks server.
* <p>
* You can set a username and password for http with the <tt>proxyHost</tt>
- * and <tt>proxyPassword</tt> attributes. On Java1.4 and above these can also
be
+ * and <tt>proxyPassword</tt> attributes. These can also be
* used against SOCKS5 servers.
* </p>
* @see <a
href="http://java.sun.com/j2se/1.5.0/docs/guide/net/properties.html">
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/types/RegularExpression.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/RegularExpression.java?rev=808156&r1=808155&r2=808156&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/RegularExpression.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/RegularExpression.java
Wed Aug 26 18:48:21 2009
@@ -31,16 +31,16 @@
* that will be used.
*
* <pre>
- * For jdk <= 1.3, there are two available implementations:
- * org.apache.tools.ant.util.regexp.JakartaOroRegexp (the default)
+ * Available implementations:
+ *
+ * org.apache.tools.ant.util.regexp.JakartaOroRegexp (the default if
available)
* Based on the jakarta-oro package
*
* org.apache.tools.ant.util.regexp.JakartaRegexpRegexp
* Based on the jakarta-regexp package
*
- * For jdk >= 1.4 an additional implementation is available:
- * org.apache.tools.ant.util.regexp.Jdk14RegexpRegexp
- * Based on the jdk 1.4 built in regular expression package.
+ * org.apache.tools.ant.util.regexp.Jdk14RegexpRegexp (fallback default)
+ * Based on the JDK's built-in regular expression package
* </pre>
*
* <pre>
Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java?rev=808156&r1=808155&r2=808156&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java Wed Aug 26
18:48:21 2009
@@ -1550,14 +1550,7 @@
public static String[] getPathStack(String path) {
String normalizedPath = path.replace(File.separatorChar, '/');
- // since Java 1.4
- //return normalizedPath.split("/");
- // workaround for Java 1.2-1.3
- Object[] tokens = StringUtils.split(normalizedPath, '/').toArray();
- String[] rv = new String[tokens.length];
- System.arraycopy(tokens, 0, rv, 0, tokens.length);
-
- return rv;
+ return normalizedPath.split("/");
}
/**
Modified:
ant/core/trunk/src/tests/junit/org/apache/tools/ant/launch/LocatorTest.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/launch/LocatorTest.java?rev=808156&r1=808155&r2=808156&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/launch/LocatorTest.java
(original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/launch/LocatorTest.java
Wed Aug 26 18:48:21 2009
@@ -54,14 +54,6 @@
unix = Os.isFamily(Os.FAMILY_UNIX);
}
- private String resolve(String uri) {
- String j14 = Locator.fromURI(uri);
- String j13 = Locator.fromURIJava13(uri);
- assertEquals("Different fromURI conversion.\nJava1.4=" + j14 +
"\nJava1.3=" + j13 + "\n",
- j14, j13);
- return j14;
- }
-
/**
* expect a uri to resolve to strings on different platforms
* @param uri uri to parse
@@ -70,7 +62,7 @@
* @return the resolved string
*/
private String resolveTo(String uri, String expectedUnix, String
expectedDos) {
- String result = resolve(uri);
+ String result = Locator.fromURI(uri);
assertResolved(uri, expectedUnix, result, unix);
assertResolved(uri, expectedDos, result, windows);
return result;
Modified:
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java?rev=808156&r1=808155&r2=808156&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java
(original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java
Wed Aug 26 18:48:21 2009
@@ -315,11 +315,7 @@
// Cf. #42263
executeTarget("sub-show-ant.core.lib");
String realLog = getLog();
- assertTrue("found ant.core.lib in: " + realLog,
- // String.matches would be simpler... can we assume JDK 1.4+
yet?
- realLog.indexOf("ant.jar") != -1 ||
- realLog.indexOf("build/classes") != 1 ||
- realLog.indexOf("build\\classes") != -1);
+ assertTrue("found ant.core.lib in: " + realLog,
realLog.matches(".*(ant[.]jar|build.classes).*"));
}
private class BasedirChecker implements BuildListener {
Modified:
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java?rev=808156&r1=808155&r2=808156&view=diff
==============================================================================
---
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java
(original)
+++
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java
Wed Aug 26 18:48:21 2009
@@ -141,19 +141,11 @@
"../../resources/dsp-void/");
}
public void testInternationalGerman() {
- if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_1_4)) {
- System.out.println("Test with international characters skipped
under pre 1.4 jvm.");
- return;
- }
executeTarget("international-german");
expectLogContaining("run-two-jars", "beta alpha");
}
public void testInternationalHebrew() {
- if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_1_4)) {
- System.out.println("Test with international characters skipped
under pre 1.4 jvm.");
- return;
- }
if (!Os.isFamily("windows")) {
executeTarget("international-hebrew");
expectLogContaining("run-two-jars", "beta alpha");
Modified:
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java?rev=808156&r1=808155&r2=808156&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java
(original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java
Wed Aug 26 18:48:21 2009
@@ -470,15 +470,6 @@
if (Os.isFamily("dos") || Os.isFamily("netware")) {
dosRoot = System.getProperty("user.dir")
.substring(0, 3).replace(File.separatorChar, '/');
-
- //preserve case on Cygwin when using 1.4 toURI:
- Class uriClazz = null;
- try {
- uriClazz = Class.forName("java.net.URI");
- } catch (ClassNotFoundException e) {
- // OK, Java 1.3.
- dosRoot = dosRoot.toUpperCase();
- }
}
else
{