git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@910832 13f79535-47bb-0310-9956-ffa450edef68master
@@ -41,6 +41,7 @@ import org.apache.tools.ant.MagicNames; | |||
import org.apache.tools.ant.Main; | |||
import org.apache.tools.ant.types.PropertySet; | |||
import org.apache.tools.ant.util.FileUtils; | |||
import org.apache.tools.ant.util.VectorSet; | |||
/** | |||
* Build a sub-project. | |||
@@ -333,7 +334,7 @@ public class Ant extends Task { | |||
public void execute() throws BuildException { | |||
File savedDir = dir; | |||
String savedAntFile = antFile; | |||
Vector locals = new Vector(targets); | |||
Vector locals = new VectorSet(targets); | |||
try { | |||
getNewProject(); | |||
@@ -20,7 +20,7 @@ package org.apache.tools.ant.taskdefs; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.Hashtable; | |||
import java.util.HashSet; | |||
import java.util.Iterator; | |||
import java.util.Vector; | |||
import org.apache.tools.ant.BuildException; | |||
@@ -527,7 +527,7 @@ public class ExecuteOn extends ExecTask { | |||
final char fileSeparator = File.separatorChar; | |||
Vector targets = new Vector(); | |||
if (targetFilePos != null) { | |||
Hashtable addedFiles = new Hashtable(); | |||
HashSet addedFiles = new HashSet(); | |||
for (int i = 0; i < srcFiles.length; i++) { | |||
String[] subTargets = mapper.mapFileName(srcFiles[i]); | |||
if (subTargets != null) { | |||
@@ -543,7 +543,7 @@ public class ExecuteOn extends ExecTask { | |||
} | |||
if (!addedFiles.contains(name)) { | |||
targets.addElement(name); | |||
addedFiles.put(name, name); | |||
addedFiles.add(name); | |||
} | |||
} | |||
} | |||
@@ -28,6 +28,7 @@ import java.net.MalformedURLException; | |||
import java.net.URL; | |||
import java.util.ArrayList; | |||
import java.util.Enumeration; | |||
import java.util.HashSet; | |||
import java.util.Iterator; | |||
import java.util.Locale; | |||
import java.util.StringTokenizer; | |||
@@ -2320,7 +2321,7 @@ public class Javadoc extends Task { | |||
* @since 1.5 | |||
*/ | |||
private void parsePackages(Vector pn, Path sp) { | |||
Vector addedPackages = new Vector(); | |||
HashSet addedPackages = new HashSet(); | |||
Vector dirSets = (Vector) packageSets.clone(); | |||
// for each sourcePath entry, add a directoryset with includes | |||
@@ -2403,7 +2404,7 @@ public class Javadoc extends Task { | |||
String packageName = | |||
dirs[i].replace(File.separatorChar, '.'); | |||
if (!addedPackages.contains(packageName)) { | |||
addedPackages.addElement(packageName); | |||
addedPackages.add(packageName); | |||
pn.addElement(packageName); | |||
} | |||
} | |||
@@ -31,6 +31,7 @@ import java.util.Hashtable; | |||
import java.util.Vector; | |||
import org.apache.tools.ant.BuildException; | |||
import org.apache.tools.ant.util.FileUtils; | |||
import org.apache.tools.ant.util.VectorSet; | |||
/** | |||
* Holds the data of a jar manifest. | |||
@@ -401,7 +402,7 @@ public class Manifest { | |||
private Hashtable attributes = new Hashtable(); | |||
/** Index used to retain the attribute ordering */ | |||
private Vector attributeIndex = new Vector(); | |||
private Vector attributeIndex = new VectorSet(); | |||
/** | |||
* The name of the section; optional -default is the main section. | |||
@@ -784,7 +785,7 @@ public class Manifest { | |||
private Hashtable sections = new Hashtable(); | |||
/** Index of sections - used to retain order of sections in manifest */ | |||
private Vector sectionIndex = new Vector(); | |||
private Vector sectionIndex = new VectorSet(); | |||
/** | |||
* Construct a manifest from Ant's default manifest file. | |||
@@ -20,8 +20,8 @@ package org.apache.tools.ant.taskdefs; | |||
import java.lang.reflect.InvocationTargetException; | |||
import java.lang.reflect.Method; | |||
import java.util.Enumeration; | |||
import java.util.Vector; | |||
import java.util.HashSet; | |||
import java.util.Iterator; | |||
/** | |||
* Destroys all registered <code>Process</code>es when the VM exits. | |||
@@ -30,7 +30,7 @@ import java.util.Vector; | |||
*/ | |||
class ProcessDestroyer implements Runnable { | |||
private static final int THREAD_DIE_TIMEOUT = 20000; | |||
private Vector processes = new Vector(); | |||
private HashSet processes = new HashSet(); | |||
// methods to register and unregister shutdown hooks | |||
private Method addShutdownHookMethod; | |||
private Method removeShutdownHookMethod; | |||
@@ -183,8 +183,7 @@ class ProcessDestroyer implements Runnable { | |||
if (processes.size() == 0) { | |||
addShutdownHook(); | |||
} | |||
processes.addElement(process); | |||
return processes.contains(process); | |||
return processes.add(process); | |||
} | |||
} | |||
@@ -198,7 +197,7 @@ class ProcessDestroyer implements Runnable { | |||
*/ | |||
public boolean remove(Process process) { | |||
synchronized (processes) { | |||
boolean processRemoved = processes.removeElement(process); | |||
boolean processRemoved = processes.remove(process); | |||
if (processRemoved && processes.size() == 0) { | |||
removeShutdownHook(); | |||
} | |||
@@ -212,9 +211,9 @@ class ProcessDestroyer implements Runnable { | |||
public void run() { | |||
synchronized (processes) { | |||
running = true; | |||
Enumeration e = processes.elements(); | |||
while (e.hasMoreElements()) { | |||
((Process) e.nextElement()).destroy(); | |||
Iterator e = processes.iterator(); | |||
while (e.hasNext()) { | |||
((Process) e.next()).destroy(); | |||
} | |||
} | |||
} | |||
@@ -37,9 +37,25 @@ import java.util.Vector; | |||
* | |||
* @since Ant 1.8.0 | |||
*/ | |||
public class VectorSet extends Vector { | |||
public final class VectorSet extends Vector { | |||
private final HashSet set = new HashSet(); | |||
public VectorSet() { super(); } | |||
public VectorSet(int initialCapacity) { super(initialCapacity); } | |||
public VectorSet(int initialCapacity, int capacityIncrement) { | |||
super(initialCapacity, capacityIncrement); | |||
} | |||
public VectorSet(Collection c) { | |||
if (c != null) { | |||
for (Iterator i = c.iterator(); i.hasNext(); ) { | |||
add(i.next()); | |||
} | |||
} | |||
} | |||
public synchronized boolean add(Object o) { | |||
if (!set.contains(o)) { | |||
doAdd(size(), o); | |||