Browse Source

Purge of many (but not all) the if-java-1.1 tests in the ant code. I left those in the tests in, and I left the javac and javadoc tests in, as they are more complex. This is the simple set.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276382 13f79535-47bb-0310-9956-ffa450edef68
master
Steve Loughran 21 years ago
parent
commit
fb77359665
8 changed files with 21 additions and 104 deletions
  1. +7
    -9
      src/main/org/apache/tools/ant/Project.java
  2. +0
    -4
      src/main/org/apache/tools/ant/taskdefs/GenerateKey.java
  3. +1
    -3
      src/main/org/apache/tools/ant/taskdefs/Get.java
  4. +4
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/Javah.java
  5. +0
    -34
      src/main/org/apache/tools/ant/taskdefs/optional/net/SetProxy.java
  6. +2
    -9
      src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java
  7. +6
    -42
      src/main/org/apache/tools/ant/util/WeakishReference.java
  8. +1
    -2
      src/testcases/org/apache/tools/ant/DirectoryScannerTest.java

+ 7
- 9
src/main/org/apache/tools/ant/Project.java View File

@@ -274,16 +274,14 @@ public class Project {
*/
private AntClassLoader createClassLoader() {
AntClassLoader loader = null;
if (!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) {
try {
// 1.2+ - create advanced helper dynamically
Class loaderClass
try {
// 1.2+ - create advanced helper dynamically
Class loaderClass
= Class.forName(ANTCLASSLOADER_JDK12);
loader = (AntClassLoader) loaderClass.newInstance();
} catch (Exception e) {
log("Unable to create Class Loader: "
+ e.getMessage(), Project.MSG_DEBUG);
}
loader = (AntClassLoader) loaderClass.newInstance();
} catch (Exception e) {
log("Unable to create Class Loader: "
+ e.getMessage(), Project.MSG_DEBUG);
}

if (loader == null) {


+ 0
- 4
src/main/org/apache/tools/ant/taskdefs/GenerateKey.java View File

@@ -265,10 +265,6 @@ public class GenerateKey extends Task {
}

public void execute() throws BuildException {
if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) {
throw new BuildException("The genkey task is only available on JDK"
+ " versions 1.2 or greater");
}

if (null == alias) {
throw new BuildException("alias attribute must be set");


+ 1
- 3
src/main/org/apache/tools/ant/taskdefs/Get.java View File

@@ -288,9 +288,7 @@ public class Get extends Task {
* @param v "true" to enable file time fetching
*/
public void setUseTimestamp(boolean v) {
if (!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) {
useTimestamp = v;
}
useTimestamp = v;
}




+ 4
- 1
src/main/org/apache/tools/ant/taskdefs/optional/Javah.java View File

@@ -271,6 +271,9 @@ public class Javah extends Task {
classpath = classpath.concatSystemClasspath("ignore");
}

/* unused.
TODO: If anyone cannot come up with a reason for this, lets delete it

String compiler = getProject().getProperty("build.compiler");
if (compiler == null) {
if (!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)
@@ -280,7 +283,7 @@ public class Javah extends Task {
compiler = "classic";
}
}
*/
doClassicCompile();
}



+ 0
- 34
src/main/org/apache/tools/ant/taskdefs/optional/net/SetProxy.java View File

@@ -229,13 +229,6 @@ public class SetProxy extends Task {
sysprops.remove("java.net.socks.password");
}
}


//for Java1.1 we need to tell the system that the settings are new
if (settingsChanged
&& JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) {
legacyResetProxySettingsCall(enablingProxy);
}
}

/**
@@ -248,33 +241,6 @@ public class SetProxy extends Task {
Project.MSG_VERBOSE);
}


/**
* make a call to sun.net.www.http.HttpClient.resetProperties();
* this is only needed for java 1.1; reflection is used to stop the compiler
* whining, and in case cleanroom JVMs dont have the class.
* @return true if we did something
*/

protected boolean legacyResetProxySettingsCall(boolean setProxy) {
System.getProperties().put("http.proxySet", new Boolean(setProxy).toString());
try {
Class c = Class.forName("sun.net.www.http.HttpClient");
Method reset = c.getMethod("resetProperties", null);
reset.invoke(null, null);
return true;
} catch (ClassNotFoundException cnfe) {
return false;
} catch (NoSuchMethodException e) {
return false;
} catch (IllegalAccessException e) {
return false;
} catch (InvocationTargetException e) {
return false;
}
}


/**
* Does the work.
*


+ 2
- 9
src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java View File

@@ -147,15 +147,8 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
cmd.createArgument().setFile(attributes.getBase());

if (attributes.getExtdirs() != null) {
if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) {
/*
* XXX - This doesn't mix very well with build.systemclasspath,
*/
classpath.addExtdirs(attributes.getExtdirs());
} else {
cmd.createArgument().setValue("-extdirs");
cmd.createArgument().setPath(attributes.getExtdirs());
}
cmd.createArgument().setValue("-extdirs");
cmd.createArgument().setPath(attributes.getExtdirs());
}

cmd.createArgument().setValue("-classpath");


+ 6
- 42
src/main/org/apache/tools/ant/util/WeakishReference.java View File

@@ -18,64 +18,27 @@
package org.apache.tools.ant.util;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.util.optional.WeakishReference12;

import java.lang.reflect.Constructor;


/**
* this is a weak reference on java1.2 and up, a hard
* reference on java1.1
* this is a weak reference on java1.2 and up, i.e. all
* platforms Ant1.7 supports
* @since ant1.6
*/
public abstract class WeakishReference {

private static Constructor referenceConstructor;

private final static String WEAK_REFERENCE_NAME
= "org.apache.tools.ant.util.optional.WeakishReference12";

/**
* create the appropriate type of reference for the java version
* @param object
* @return reference to the Object.
*/
public static WeakishReference createReference(Object object) {
if (referenceConstructor == null) {
createReferenceConstructor();
}
try {
return (WeakishReference) referenceConstructor
.newInstance(new Object[]{object});
} catch (Exception e) {
throw new BuildException("while creating a weakish reference", e);
}
return new WeakishReference12(object);
}

/**
* create the appropriate constructor method for the
*/
private static void createReferenceConstructor() {
Class[] ctor = new Class[]{Object.class};
try {
referenceConstructor = HardReference.class.getConstructor(ctor);
} catch (NoSuchMethodException e) {
//deep trouble here
throw new BuildException("when creating a Hard Reference constructor", e);
}
if (!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) {
//create a weak ref constructor. If this fails we have that hard one anyway
try {
Class clazz = Class.forName(WEAK_REFERENCE_NAME);
referenceConstructor = clazz.getConstructor(ctor);
} catch (ClassNotFoundException e) {
// ignore
} catch (NoSuchMethodException e) {
// ignore
}
}
}


/**
* Returns this reference object's referent. If this reference object has
* been cleared, then this method returns <code>null</code>.
@@ -86,7 +49,8 @@ public abstract class WeakishReference {
public abstract Object get();

/**
* A hard reference for Java 1.1
* A hard reference for Java 1.1.
* Hopefully nobody is using this.
*/
public static class HardReference extends WeakishReference {
private Object object;


+ 1
- 2
src/testcases/org/apache/tools/ant/DirectoryScannerTest.java View File

@@ -37,8 +37,7 @@ public class DirectoryScannerTest extends BuildFileTest {
public DirectoryScannerTest(String name) {super(name);}

// keep track of what operating systems are supported here.
private boolean supportsSymlinks = Os.isFamily("unix")
&& !JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1);
private boolean supportsSymlinks = Os.isFamily("unix");

public void setUp() {
configureProject("src/etc/testcases/core/directoryscanner.xml");


Loading…
Cancel
Save