You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by mb...@apache.org on 2012/08/20 19:49:15 UTC
svn commit: r1375137 [2/3] - in
/ant/core/trunk/src/main/org/apache/tools/ant: ./ property/ taskdefs/
types/ util/
Modified: ant/core/trunk/src/main/org/apache/tools/ant/Main.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/Main.java?rev=1375137&r1=1375136&r2=1375137&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/Main.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/Main.java Mon Aug 20 17:49:13 2012
@@ -24,11 +24,14 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
import java.util.Vector;
@@ -58,18 +61,12 @@ import org.apache.tools.ant.util.ProxySe
public class Main implements AntMain {
/**
- * A Set of args are are handled by the launcher and should
+ * A Set of args that are handled by the launcher and should
* not be seen by Main.
*/
- private static final Set LAUNCH_COMMANDS = new HashSet();
- static {
- LAUNCH_COMMANDS.add("-lib");
- LAUNCH_COMMANDS.add("-cp");
- LAUNCH_COMMANDS.add("-noclasspath");
- LAUNCH_COMMANDS.add("--noclasspath");
- LAUNCH_COMMANDS.add("-nouserlib");
- LAUNCH_COMMANDS.add("-main");
- }
+ private static final Set<String> LAUNCH_COMMANDS = Collections
+ .unmodifiableSet(new HashSet<String>(Arrays.asList("-lib", "-cp", "-noclasspath",
+ "--noclasspath", "-nouserlib", "-main")));
/** The default build file name. {@value} */
public static final String DEFAULT_BUILD_FILENAME = "build.xml";
@@ -87,16 +84,16 @@ public class Main implements AntMain {
private static PrintStream err = System.err;
/** The build targets. */
- private Vector targets = new Vector();
+ private Vector<String> targets = new Vector<String>();
/** Set of properties that can be used by tasks. */
private Properties definedProps = new Properties();
/** Names of classes to add as listeners to project. */
- private Vector listeners = new Vector(1);
+ private Vector<String> listeners = new Vector<String>(1);
/** File names of property files to load on startup. */
- private Vector propertyFiles = new Vector(1);
+ private Vector<String> propertyFiles = new Vector<String>(1);
/** Indicates whether this build is to support interactive input */
private boolean allowInput = true;
@@ -154,15 +151,15 @@ public class Main implements AntMain {
* proxy flag: default is false
*/
private boolean proxy = false;
-
-
+
+
private static final GetProperty NOPROPERTIES = new GetProperty(){
public Object getProperty(String aName) {
// No existing property takes precedence
return null;
}};
-
-
+
+
/**
@@ -219,7 +216,7 @@ public class Main implements AntMain {
}
if (additionalUserProperties != null) {
- for (Enumeration e = additionalUserProperties.keys();
+ for (Enumeration<?> e = additionalUserProperties.keys();
e.hasMoreElements();) {
String key = (String) e.nextElement();
String property = additionalUserProperties.getProperty(key);
@@ -438,9 +435,9 @@ public class Main implements AntMain {
}
} else {
// no search file specified: so search an existing default file
- Iterator it = ProjectHelperRepository.getInstance().getHelpers();
+ Iterator<ProjectHelper> it = ProjectHelperRepository.getInstance().getHelpers();
do {
- ProjectHelper helper = (ProjectHelper) it.next();
+ ProjectHelper helper = it.next();
searchForThis = helper.getDefaultBuildFile();
if (msgOutputLevel >= Project.MSG_VERBOSE) {
System.out.println("Searching the default build file: " + searchForThis);
@@ -453,9 +450,9 @@ public class Main implements AntMain {
}
} else {
// no build file specified: so search an existing default file
- Iterator it = ProjectHelperRepository.getInstance().getHelpers();
+ Iterator<ProjectHelper> it = ProjectHelperRepository.getInstance().getHelpers();
do {
- ProjectHelper helper = (ProjectHelper) it.next();
+ ProjectHelper helper = it.next();
buildFile = new File(helper.getDefaultBuildFile());
if (msgOutputLevel >= Project.MSG_VERBOSE) {
System.out.println("Trying the default build file: " + buildFile);
@@ -628,11 +625,7 @@ public class Main implements AntMain {
/** Load the property files specified by -propertyfile */
private void loadPropertyFiles() {
- for (int propertyFileIndex = 0;
- propertyFileIndex < propertyFiles.size();
- propertyFileIndex++) {
- String filename
- = (String) propertyFiles.elementAt(propertyFileIndex);
+ for (String filename : propertyFiles) {
Properties props = new Properties();
FileInputStream fis = null;
try {
@@ -646,7 +639,7 @@ public class Main implements AntMain {
}
// ensure that -D properties take precedence
- Enumeration propertyNames = props.propertyNames();
+ Enumeration<?> propertyNames = props.propertyNames();
while (propertyNames.hasMoreElements()) {
String name = (String) propertyNames.nextElement();
if (definedProps.getProperty(name) == null) {
@@ -846,21 +839,20 @@ public class Main implements AntMain {
}
private void setProperties(final Project project) {
-
+
project.init();
-
+
// resolve properties
PropertyHelper propertyHelper = (PropertyHelper) PropertyHelper
.getPropertyHelper(project);
- HashMap props = new HashMap(definedProps);
-
+ HashMap<Object, Object> props = new HashMap<Object, Object>(definedProps);
+
ResolvePropertyMap resolver = new ResolvePropertyMap(project,
NOPROPERTIES, propertyHelper.getExpanders());
resolver.resolveAllProperties(props, null, false);
// set user-define properties
- for (Iterator e = props.entrySet().iterator(); e.hasNext(); ) {
- Map.Entry ent = (Map.Entry) e.next();
+ for (Entry<Object, Object> ent : props.entrySet()) {
String arg = (String) ent.getKey();
Object value = ent.getValue();
project.setUserProperty(arg, String.valueOf(value));
@@ -1076,17 +1068,15 @@ public class Main implements AntMain {
* @param targets the targets to filter.
* @return the filtered targets.
*/
- private static Map removeDuplicateTargets(Map targets) {
- Map locationMap = new HashMap();
- for (Iterator i = targets.entrySet().iterator(); i.hasNext();) {
- Map.Entry entry = (Map.Entry) i.next();
- String name = (String) entry.getKey();
- Target target = (Target) entry.getValue();
- Target otherTarget =
- (Target) locationMap.get(target.getLocation());
+ private static Map<String, Target> removeDuplicateTargets(Map<String, Target> targets) {
+ Map<Location, Target> locationMap = new HashMap<Location, Target>();
+ for (Entry<String, Target> entry : targets.entrySet()) {
+ String name = entry.getKey();
+ Target target = entry.getValue();
+ Target otherTarget = locationMap.get(target.getLocation());
// Place this entry in the location map if
// a) location is not in the map
- // b) location is in map, but it's name is longer
+ // b) location is in map, but its name is longer
// (an imported target will have a name. prefix)
if (otherTarget == null
|| otherTarget.getName().length() > name.length()) {
@@ -1094,9 +1084,8 @@ public class Main implements AntMain {
target.getLocation(), target); // Smallest name wins
}
}
- Map ret = new HashMap();
- for (Iterator i = locationMap.values().iterator(); i.hasNext();) {
- Target target = (Target) i.next();
+ Map<String, Target> ret = new HashMap<String, Target>();
+ for (Target target : locationMap.values()) {
ret.put(target.getName(), target);
}
return ret;
@@ -1115,25 +1104,21 @@ public class Main implements AntMain {
boolean printDependencies) {
// find the target with the longest name
int maxLength = 0;
- Map ptargets = removeDuplicateTargets(project.getTargets());
- String targetName;
- String targetDescription;
- Target currentTarget;
+ Map<String, Target> ptargets = removeDuplicateTargets(project.getTargets());
// split the targets in top-level and sub-targets depending
// on the presence of a description
- Vector topNames = new Vector();
- Vector topDescriptions = new Vector();
- Vector/*<Enumeration<String>>*/ topDependencies = new Vector();
- Vector subNames = new Vector();
- Vector/*<Enumeration<String>>*/ subDependencies = new Vector();
-
- for (Iterator i = ptargets.values().iterator(); i.hasNext();) {
- currentTarget = (Target) i.next();
- targetName = currentTarget.getName();
+ Vector<String> topNames = new Vector<String>();
+ Vector<String> topDescriptions = new Vector<String>();
+ Vector<Enumeration<String>> topDependencies = new Vector<Enumeration<String>>();
+ Vector<String> subNames = new Vector<String>();
+ Vector<Enumeration<String>> subDependencies = new Vector<Enumeration<String>>();
+
+ for (Target currentTarget : ptargets.values()) {
+ String targetName = currentTarget.getName();
if (targetName.equals("")) {
continue;
}
- targetDescription = currentTarget.getDescription();
+ String targetDescription = currentTarget.getDescription();
// maintain a sorted list of targets
if (targetDescription == null) {
int pos = findTargetPosition(subNames, targetName);
@@ -1182,11 +1167,11 @@ public class Main implements AntMain {
*
* @return the correct place in the list for the given name
*/
- private static int findTargetPosition(Vector names, String name) {
+ private static int findTargetPosition(Vector<String> names, String name) {
final int size = names.size();
int res = size;
for (int i = 0; i < size && res == size; i++) {
- if (name.compareTo((String) names.elementAt(i)) < 0) {
+ if (name.compareTo(names.elementAt(i)) < 0) {
res = i;
}
}
@@ -1216,8 +1201,8 @@ public class Main implements AntMain {
* position so they line up (so long as the names really
* <i>are</i> shorter than this).
*/
- private static void printTargets(Project project, Vector names,
- Vector descriptions, Vector dependencies,
+ private static void printTargets(Project project, Vector<String> names,
+ Vector<String> descriptions, Vector<Enumeration<String>> dependencies,
String heading,
int maxlen) {
// now, start printing the targets and their descriptions
@@ -1227,7 +1212,7 @@ public class Main implements AntMain {
while (spaces.length() <= maxlen) {
spaces += spaces;
}
- StringBuffer msg = new StringBuffer();
+ StringBuilder msg = new StringBuilder();
msg.append(heading + lSep + lSep);
final int size = names.size();
for (int i = 0; i < size; i++) {
@@ -1235,12 +1220,12 @@ public class Main implements AntMain {
msg.append(names.elementAt(i));
if (descriptions != null) {
msg.append(
- spaces.substring(0, maxlen - ((String) names.elementAt(i)).length() + 2));
+ spaces.substring(0, maxlen - names.elementAt(i).length() + 2));
msg.append(descriptions.elementAt(i));
}
msg.append(lSep);
if (!dependencies.isEmpty()) {
- Enumeration deps = (Enumeration) dependencies.elementAt(i);
+ Enumeration<String> deps = dependencies.elementAt(i);
if (deps.hasMoreElements()) {
msg.append(" depends on: ");
while (deps.hasMoreElements()) {
@@ -1249,7 +1234,7 @@ public class Main implements AntMain {
msg.append(", ");
}
}
- msg.append(lSep);
+ msg.append(lSep);
}
}
}
Modified: ant/core/trunk/src/main/org/apache/tools/ant/Project.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/Project.java?rev=1375137&r1=1375136&r2=1375137&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/Project.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/Project.java Mon Aug 20 17:49:13 2012
@@ -135,19 +135,16 @@ public class Project implements Resource
/** Map of references within the project (paths etc) (String to Object). */
- private Hashtable references = new AntRefTable();
+ private Hashtable<String, Object> references = new AntRefTable();
/** Map of id references - used for indicating broken build files */
- private HashMap idReferences = new HashMap();
-
- /** the parent project for old id resolution (if inheritreferences is set) */
- private Project parentIdProject = null;
+ private HashMap<String, Object> idReferences = new HashMap<String, Object>();
/** Name of the project's default target. */
private String defaultTarget;
/** Map from target names to targets (String to Target). */
- private Hashtable targets = new Hashtable();
+ private Hashtable<String, Target> targets = new Hashtable<String, Target>();
/** Set of global filters. */
private FilterSet globalFilterSet = new FilterSet();
{
@@ -174,8 +171,8 @@ public class Project implements Resource
/** for each thread, record whether it is currently executing
messageLogged */
- private final ThreadLocal isLoggingMessage = new ThreadLocal() {
- protected Object initialValue() {
+ private final ThreadLocal<Boolean> isLoggingMessage = new ThreadLocal<Boolean>() {
+ protected Boolean initialValue() {
return Boolean.FALSE;
}
};
@@ -187,12 +184,12 @@ public class Project implements Resource
private ClassLoader coreLoader = null;
/** Records the latest task to be executed on a thread. */
- private final Map/*<Thread,Task>*/ threadTasks =
- Collections.synchronizedMap(new WeakHashMap());
+ private final Map<Thread,Task> threadTasks =
+ Collections.synchronizedMap(new WeakHashMap<Thread, Task>());
/** Records the latest task to be executed on a thread group. */
- private final Map/*<ThreadGroup,Task>*/ threadGroupTasks
- = Collections.synchronizedMap(new WeakHashMap());
+ private final Map<ThreadGroup,Task> threadGroupTasks
+ = Collections.synchronizedMap(new WeakHashMap<ThreadGroup,Task>());
/**
* Called to handle any input requests.
@@ -427,12 +424,12 @@ public class Project implements Resource
/**
* Return a copy of the list of build listeners for the project.
- *
+ *
* @return a list of build listeners for the project
*/
- public Vector getBuildListeners() {
+ public Vector<BuildListener> getBuildListeners() {
synchronized (listenersLock) {
- Vector r = new Vector(listeners.length);
+ Vector<BuildListener> r = new Vector<BuildListener>(listeners.length);
for (int i = 0; i < listeners.length; i++) {
r.add(listeners[i]);
}
@@ -644,7 +641,7 @@ public class Project implements Resource
* @return a hashtable containing all properties
* (including user properties).
*/
- public Hashtable getProperties() {
+ public Hashtable<String, Object> getProperties() {
return PropertyHelper.getPropertyHelper(this).getProperties();
}
@@ -652,7 +649,7 @@ public class Project implements Resource
* Return a copy of the user property hashtable.
* @return a hashtable containing just the user properties.
*/
- public Hashtable getUserProperties() {
+ public Hashtable<String, Object> getUserProperties() {
return PropertyHelper.getPropertyHelper(this).getUserProperties();
}
@@ -661,7 +658,7 @@ public class Project implements Resource
* @return a hashtable containing just the inherited properties.
* @since Ant 1.8.0
*/
- public Hashtable getInheritedProperties() {
+ public Hashtable<String, Object> getInheritedProperties() {
return PropertyHelper.getPropertyHelper(this).getInheritedProperties();
}
@@ -811,7 +808,7 @@ public class Project implements Resource
* @see #getGlobalFilterSet()
* @see FilterSet#getFilterHash()
*/
- public Hashtable getFilters() {
+ public Hashtable<String, String> getFilters() {
// we need to build the hashtable dynamically
return globalFilterSet.getFilterHash();
}
@@ -936,7 +933,7 @@ public class Project implements Resource
*/
public void setSystemProperties() {
Properties systemP = System.getProperties();
- Enumeration e = systemP.propertyNames();
+ Enumeration<?> e = systemP.propertyNames();
while (e.hasMoreElements()) {
String propertyName = (String) e.nextElement();
String value = systemP.getProperty(propertyName);
@@ -966,7 +963,7 @@ public class Project implements Resource
*
* @see #checkTaskClass(Class)
*/
- public void addTaskDefinition(String taskName, Class taskClass)
+ public void addTaskDefinition(String taskName, Class<?> taskClass)
throws BuildException {
ComponentHelper.getComponentHelper(this).addTaskDefinition(taskName,
taskClass);
@@ -984,7 +981,7 @@ public class Project implements Resource
* task. An error level message is logged before
* this exception is thrown.
*/
- public void checkTaskClass(final Class taskClass) throws BuildException {
+ public void checkTaskClass(final Class<?> taskClass) throws BuildException {
ComponentHelper.getComponentHelper(this).checkTaskClass(taskClass);
if (!Modifier.isPublic(taskClass.getModifiers())) {
@@ -998,7 +995,7 @@ public class Project implements Resource
throw new BuildException(message);
}
try {
- taskClass.getConstructor((Class[]) null);
+ taskClass.getConstructor();
// don't have to check for public, since
// getConstructor finds public constructors only.
} catch (NoSuchMethodException e) {
@@ -1023,7 +1020,7 @@ public class Project implements Resource
* @return a map of from task name to implementing class
* (String to Class).
*/
- public Hashtable getTaskDefinitions() {
+ public Hashtable<String, Class<?>> getTaskDefinitions() {
return ComponentHelper.getComponentHelper(this).getTaskDefinitions();
}
@@ -1036,8 +1033,8 @@ public class Project implements Resource
*
* @since Ant 1.8.1
*/
- public Map getCopyOfTaskDefinitions() {
- return new HashMap(getTaskDefinitions());
+ public Map<String, Class<?>> getCopyOfTaskDefinitions() {
+ return new HashMap<String, Class<?>>(getTaskDefinitions());
}
/**
@@ -1053,7 +1050,7 @@ public class Project implements Resource
* @param typeClass The full name of the class implementing the datatype.
* Must not be <code>null</code>.
*/
- public void addDataTypeDefinition(String typeName, Class typeClass) {
+ public void addDataTypeDefinition(String typeName, Class<?> typeClass) {
ComponentHelper.getComponentHelper(this).addDataTypeDefinition(typeName,
typeClass);
}
@@ -1065,7 +1062,7 @@ public class Project implements Resource
* @return a map of from datatype name to implementing class
* (String to Class).
*/
- public Hashtable getDataTypeDefinitions() {
+ public Hashtable<String, Class<?>> getDataTypeDefinitions() {
return ComponentHelper.getComponentHelper(this).getDataTypeDefinitions();
}
@@ -1078,8 +1075,8 @@ public class Project implements Resource
*
* @since Ant 1.8.1
*/
- public Map getCopyOfDataTypeDefinitions() {
- return new HashMap(getDataTypeDefinitions());
+ public Map<String, Class<?>> getCopyOfDataTypeDefinitions() {
+ return new HashMap<String, Class<?>>(getDataTypeDefinitions());
}
/**
@@ -1148,7 +1145,7 @@ public class Project implements Resource
* is "live" and so should not be modified.
* @return a map from name to target (String to Target).
*/
- public Hashtable getTargets() {
+ public Hashtable<String, Target> getTargets() {
return targets;
}
@@ -1158,8 +1155,8 @@ public class Project implements Resource
* @return a map from name to target (String to Target).
* @since Ant 1.8.1
*/
- public Map getCopyOfTargets() {
- return new HashMap(targets);
+ public Map<String, Target> getCopyOfTargets() {
+ return new HashMap<String, Target>(targets);
}
/**
@@ -1245,11 +1242,10 @@ public class Project implements Resource
*
* @exception BuildException if the build failed.
*/
- public void executeTargets(Vector names) throws BuildException {
+ public void executeTargets(Vector<String> names) throws BuildException {
setUserProperty(MagicNames.PROJECT_INVOKED_TARGETS,
CollectionUtils.flattenToString(names));
- getExecutor().executeTargets(this,
- (String[]) (names.toArray(new String[names.size()])));
+ getExecutor().executeTargets(this, names.toArray(new String[names.size()]));
}
/**
@@ -1373,17 +1369,15 @@ public class Project implements Resource
* @param sortedTargets the aforementioned <code>Vector</code>.
* @throws BuildException on error.
*/
- public void executeSortedTargets(Vector sortedTargets)
+ public void executeSortedTargets(Vector<Target> sortedTargets)
throws BuildException {
- Set succeededTargets = new HashSet();
+ Set<String> succeededTargets = new HashSet<String>();
BuildException buildException = null; // first build exception
- for (Enumeration iter = sortedTargets.elements();
- iter.hasMoreElements();) {
- Target curtarget = (Target) iter.nextElement();
+ for (Target curtarget : sortedTargets) {
boolean canExecute = true;
- for (Enumeration depIter = curtarget.getDependencies();
+ for (Enumeration<String> depIter = curtarget.getDependencies();
depIter.hasMoreElements();) {
- String dependencyName = ((String) depIter.nextElement());
+ String dependencyName = depIter.nextElement();
if (!succeededTargets.contains(dependencyName)) {
canExecute = false;
log(curtarget,
@@ -1756,7 +1750,7 @@ public class Project implements Resource
* @exception BuildException if there is a cyclic dependency among the
* targets, or if a named target does not exist.
*/
- public final Vector topoSort(String root, Hashtable targetTable)
+ public final Vector<Target> topoSort(String root, Hashtable<String, Target> targetTable)
throws BuildException {
return topoSort(new String[] {root}, targetTable, true);
}
@@ -1778,7 +1772,7 @@ public class Project implements Resource
* targets, or if a named target does not exist.
* @since Ant 1.6.3
*/
- public final Vector topoSort(String root, Hashtable targetTable,
+ public final Vector<Target> topoSort(String root, Hashtable<String, Target> targetTable,
boolean returnAll) throws BuildException {
return topoSort(new String[] {root}, targetTable, returnAll);
}
@@ -1800,11 +1794,11 @@ public class Project implements Resource
* targets, or if a named target does not exist.
* @since Ant 1.6.3
*/
- public final Vector topoSort(String[] root, Hashtable targetTable,
+ public final Vector<Target> topoSort(String[] root, Hashtable<String, Target> targetTable,
boolean returnAll) throws BuildException {
- Vector ret = new VectorSet();
- Hashtable state = new Hashtable();
- Stack visiting = new Stack();
+ Vector<Target> ret = new VectorSet<Target>();
+ Hashtable<String, String> state = new Hashtable<String, String>();
+ Stack<String> visiting = new Stack<String>();
// We first run a DFS based sort using each root as a starting node.
// This creates the minimum sequence of Targets to the root node(s).
@@ -1831,10 +1825,10 @@ public class Project implements Resource
buf.append(" is " + ret);
log(buf.toString(), MSG_VERBOSE);
- Vector complete = (returnAll) ? ret : new Vector(ret);
- for (Enumeration en = targetTable.keys(); en.hasMoreElements();) {
- String curTarget = (String) en.nextElement();
- String st = (String) state.get(curTarget);
+ Vector<Target> complete = (returnAll) ? ret : new Vector<Target>(ret);
+ for (Enumeration<String> en = targetTable.keys(); en.hasMoreElements();) {
+ String curTarget = en.nextElement();
+ String st = state.get(curTarget);
if (st == null) {
tsort(curTarget, targetTable, state, visiting, complete);
} else if (st == VISITING) {
@@ -1886,34 +1880,34 @@ public class Project implements Resource
* @exception BuildException if a non-existent target is specified or if
* a circular dependency is detected.
*/
- private void tsort(String root, Hashtable targetTable,
- Hashtable state, Stack visiting,
- Vector ret)
+ private void tsort(String root, Hashtable<String, Target> targetTable,
+ Hashtable<String, String> state, Stack<String> visiting,
+ Vector<Target> ret)
throws BuildException {
state.put(root, VISITING);
visiting.push(root);
- Target target = (Target) targetTable.get(root);
+ Target target = targetTable.get(root);
// Make sure we exist
if (target == null) {
- StringBuffer sb = new StringBuffer("Target \"");
+ StringBuilder sb = new StringBuilder("Target \"");
sb.append(root);
sb.append("\" does not exist in the project \"");
sb.append(name);
sb.append("\". ");
visiting.pop();
if (!visiting.empty()) {
- String parent = (String) visiting.peek();
+ String parent = visiting.peek();
sb.append("It is used from target \"");
sb.append(parent);
sb.append("\".");
}
throw new BuildException(new String(sb));
}
- for (Enumeration en = target.getDependencies(); en.hasMoreElements();) {
- String cur = (String) en.nextElement();
- String m = (String) state.get(cur);
+ for (Enumeration<String> en = target.getDependencies(); en.hasMoreElements();) {
+ String cur = en.nextElement();
+ String m = state.get(cur);
if (m == null) {
// Not been visited
tsort(cur, targetTable, state, visiting, ret);
@@ -1922,7 +1916,7 @@ public class Project implements Resource
throw makeCircularException(cur, visiting);
}
}
- String p = (String) visiting.pop();
+ String p = visiting.pop();
if (root != p) {
throw new RuntimeException("Unexpected internal error: expected to "
+ "pop " + root + " but got " + p);
@@ -1940,16 +1934,16 @@ public class Project implements Resource
*
* @return a BuildException detailing the specified circular dependency.
*/
- private static BuildException makeCircularException(String end, Stack stk) {
- StringBuffer sb = new StringBuffer("Circular dependency: ");
+ private static BuildException makeCircularException(String end, Stack<String> stk) {
+ final StringBuilder sb = new StringBuilder("Circular dependency: ");
sb.append(end);
String c;
do {
- c = (String) stk.pop();
+ c = stk.pop();
sb.append(" <- ");
sb.append(c);
} while (!c.equals(end));
- return new BuildException(new String(sb));
+ return new BuildException(sb.toString());
}
/**
@@ -1957,7 +1951,6 @@ public class Project implements Resource
* @param parent the parent project of this project.
*/
public void inheritIDReferences(Project parent) {
- parentIdProject = parent;
}
/**
@@ -1996,7 +1989,7 @@ public class Project implements Resource
*
* @return a map of the references in the project (String to Object).
*/
- public Hashtable getReferences() {
+ public Hashtable<String, Object> getReferences() {
return references;
}
@@ -2018,8 +2011,8 @@ public class Project implements Resource
*
* @since Ant 1.8.1
*/
- public Map getCopyOfReferences() {
- return new HashMap(references);
+ public Map<String, Object> getCopyOfReferences() {
+ return new HashMap<String, Object>(references);
}
/**
@@ -2031,8 +2024,9 @@ public class Project implements Resource
* @return the reference with the specified ID, or <code>null</code> if
* there is no such reference in the project.
*/
- public Object getReference(String key) {
- Object ret = references.get(key);
+ public <T> T getReference(String key) {
+ @SuppressWarnings("unchecked")
+ final T ret = (T) references.get(key);
if (ret != null) {
return ret;
}
@@ -2046,7 +2040,7 @@ public class Project implements Resource
//ignore
}
}
- return ret;
+ return null;
}
/**
@@ -2397,7 +2391,8 @@ public class Project implements Resource
// Should move to a separate public class - and have API to add
// listeners, etc.
- private static class AntRefTable extends Hashtable {
+ private static class AntRefTable extends Hashtable<String, Object> {
+ private static final long serialVersionUID = 1L;
AntRefTable() {
super();
@@ -2426,7 +2421,6 @@ public class Project implements Resource
* @return mapped value.
*/
public Object get(Object key) {
- //System.out.println("AntRefTable.get " + key);
Object o = getReal(key);
if (o instanceof UnknownElement) {
// Make sure that
Modified: ant/core/trunk/src/main/org/apache/tools/ant/ProjectHelper.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/ProjectHelper.java?rev=1375137&r1=1375136&r2=1375137&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/ProjectHelper.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/ProjectHelper.java Mon Aug 20 17:49:13 2012
@@ -87,7 +87,7 @@ public class ProjectHelper {
* targets that want to extend missing extension-points.
* <p>
* This class behaves like a Java 1.5 Enum class.
- *
+ *
* @since 1.8.2
*/
public final static class OnMissingExtensionPoint {
@@ -143,8 +143,8 @@ public class ProjectHelper {
// The following properties are required by import ( and other tasks
// that read build files using ProjectHelper ).
- private Vector importStack = new Vector();
- private List extensionStack = new LinkedList();
+ private Vector<Object> importStack = new Vector<Object>();
+ private List<String[]> extensionStack = new LinkedList<String[]>();
/**
* Import stack.
@@ -153,7 +153,7 @@ public class ProjectHelper {
*
* @return the stack of import source objects.
*/
- public Vector getImportStack() {
+ public Vector<Object> getImportStack() {
return importStack;
}
@@ -170,11 +170,7 @@ public class ProjectHelper {
return extensionStack;
}
- private final static ThreadLocal targetPrefix = new ThreadLocal() {
- protected Object initialValue() {
- return (String) null;
- }
- };
+ private final static ThreadLocal<String> targetPrefix = new ThreadLocal<String>();
/**
* The prefix to prepend to imported target names.
@@ -186,7 +182,7 @@ public class ProjectHelper {
* @since Ant 1.8.0
*/
public static String getCurrentTargetPrefix() {
- return (String) targetPrefix.get();
+ return targetPrefix.get();
}
/**
@@ -198,8 +194,8 @@ public class ProjectHelper {
targetPrefix.set(prefix);
}
- private final static ThreadLocal prefixSeparator = new ThreadLocal() {
- protected Object initialValue() {
+ private final static ThreadLocal<String> prefixSeparator = new ThreadLocal<String>() {
+ protected String initialValue() {
return ".";
}
};
@@ -212,7 +208,7 @@ public class ProjectHelper {
* @since Ant 1.8.0
*/
public static String getCurrentPrefixSeparator() {
- return (String) prefixSeparator.get();
+ return prefixSeparator.get();
}
/**
@@ -224,8 +220,8 @@ public class ProjectHelper {
prefixSeparator.set(sep);
}
- private final static ThreadLocal inIncludeMode = new ThreadLocal() {
- protected Object initialValue() {
+ private final static ThreadLocal<Boolean> inIncludeMode = new ThreadLocal<Boolean>() {
+ protected Boolean initialValue() {
return Boolean.FALSE;
}
};
@@ -246,7 +242,7 @@ public class ProjectHelper {
* @since Ant 1.8.0
*/
public static boolean isInIncludeMode() {
- return inIncludeMode.get() == Boolean.TRUE;
+ return Boolean.TRUE.equals(inIncludeMode.get());
}
/**
@@ -256,7 +252,7 @@ public class ProjectHelper {
* @since Ant 1.8.0
*/
public static void setInIncludeMode(boolean includeMode) {
- inIncludeMode.set(includeMode ? Boolean.TRUE : Boolean.FALSE);
+ inIncludeMode.set(Boolean.valueOf(includeMode));
}
// -------------------- Parse method --------------------
@@ -280,7 +276,7 @@ public class ProjectHelper {
/**
* Get the first project helper found in the classpath
- *
+ *
* @return an project helper, never <code>null</code>
* @see org.apache.tools.ant.ProjectHelperRepository#getHelpers()
*/
@@ -436,7 +432,7 @@ public class ProjectHelper {
* @param value The string to be scanned for property references.
* May be <code>null</code>, in which case this
* method returns immediately with no effect.
- * @param keys Mapping (String to String) of property names to their
+ * @param keys Mapping (String to Object) of property names to their
* values. Must not be <code>null</code>.
*
* @exception BuildException if the string contains an opening
@@ -447,7 +443,7 @@ public class ProjectHelper {
* @deprecated since 1.6.x.
* Use PropertyHelper.
*/
- public static String replaceProperties(Project project, String value, Hashtable keys)
+ public static String replaceProperties(Project project, String value, Hashtable<String, Object> keys)
throws BuildException {
PropertyHelper ph = PropertyHelper.getPropertyHelper(project);
return ph.replaceProperties(null, value, keys);
@@ -474,7 +470,7 @@ public class ProjectHelper {
* @exception BuildException if the string contains an opening
* <code>${</code> without a closing <code>}</code>
*/
- public static void parsePropertyString(String value, Vector fragments, Vector propertyRefs)
+ public static void parsePropertyString(String value, Vector<String> fragments, Vector<String> propertyRefs)
throws BuildException {
PropertyHelper.parsePropertyStringDefault(value, fragments, propertyRefs);
}
@@ -587,7 +583,7 @@ public class ProjectHelper {
/**
* Check if the helper supports the kind of file. Some basic check on the
* extension's file should be done here.
- *
+ *
* @param buildFile
* the file expected to be parsed (never <code>null</code>)
* @return true if the helper supports it
@@ -599,7 +595,7 @@ public class ProjectHelper {
/**
* The file name of the build script to be parsed if none specified on the command line
- *
+ *
* @return the name of the default file (never <code>null</code>)
* @since Ant 1.8.0
*/
@@ -618,7 +614,7 @@ public class ProjectHelper {
* This should be invoked by each concrete implementation of ProjectHelper
* when the root "buildfile" and all imported/included buildfile are loaded.
* </p>
- *
+ *
* @param project The project containing the target. Must not be
* <code>null</code>.
* @exception BuildException if OnMissingExtensionPoint.FAIL and
@@ -638,11 +634,11 @@ public class ProjectHelper {
String prefixAndSep = extensionInfo.length > 3 ? extensionInfo[3] : null;
// find the target we're extending
- Hashtable projectTargets = project.getTargets();
+ Hashtable<String, Target> projectTargets = project.getTargets();
Target extPoint = null;
if (prefixAndSep == null) {
// no prefix - not from an imported/included build file
- extPoint = (Target) projectTargets.get(extPointName);
+ extPoint = projectTargets.get(extPointName);
} else {
// we have a prefix, which means we came from an include/import
@@ -652,9 +648,9 @@ public class ProjectHelper {
// which prefix should be tested before testing the non-prefix
// root name.
- extPoint = (Target) projectTargets.get(prefixAndSep + extPointName);
+ extPoint = projectTargets.get(prefixAndSep + extPointName);
if (extPoint == null) {
- extPoint = (Target) projectTargets.get(extPointName);
+ extPoint = projectTargets.get(extPointName);
}
}
@@ -666,7 +662,7 @@ public class ProjectHelper {
if (missingBehaviour == OnMissingExtensionPoint.FAIL) {
throw new BuildException(message);
} else if (missingBehaviour == OnMissingExtensionPoint.WARN) {
- Target t = (Target) projectTargets.get(targetName);
+ Target t = projectTargets.get(targetName);
project.log(t, "Warning: " + message, Project.MSG_WARN);
}
} else {
Modified: ant/core/trunk/src/main/org/apache/tools/ant/ProjectHelperRepository.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/ProjectHelperRepository.java?rev=1375137&r1=1375136&r2=1375137&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/ProjectHelperRepository.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/ProjectHelperRepository.java Mon Aug 20 17:49:13 2012
@@ -34,9 +34,9 @@ import org.apache.tools.ant.util.LoaderU
/**
* Repository of {@link ProjectHelper} found in the classpath or via
* some System properties.
- *
+ *
* <p>See the ProjectHelper documentation in the manual.</p>
- *
+ *
* @since Ant 1.8.0
*/
public class ProjectHelperRepository {
@@ -52,17 +52,13 @@ public class ProjectHelperRepository {
private static ProjectHelperRepository instance =
new ProjectHelperRepository();
- private List/* <Constructor> */ helpers = new ArrayList();
+ private List<Constructor<? extends ProjectHelper>> helpers = new ArrayList<Constructor<? extends ProjectHelper>>();
- private static final Class[] NO_CLASS = new Class[0];
- private static final Object[] NO_OBJECT = new Object[0];
-
- private static Constructor PROJECTHELPER2_CONSTRUCTOR;
+ private static Constructor<ProjectHelper2> PROJECTHELPER2_CONSTRUCTOR;
static {
try {
- PROJECTHELPER2_CONSTRUCTOR = ProjectHelper2.class
- .getConstructor(NO_CLASS);
+ PROJECTHELPER2_CONSTRUCTOR = ProjectHelper2.class.getConstructor();
} catch (Exception e) {
// ProjectHelper2 must be available
throw new RuntimeException(e);
@@ -79,7 +75,7 @@ public class ProjectHelperRepository {
private void collectProjectHelpers() {
// First, try the system property
- Constructor projectHelper = getProjectHelperBySystemProperty();
+ Constructor<? extends ProjectHelper> projectHelper = getProjectHelperBySystemProperty();
registerProjectHelper(projectHelper);
// A JDK1.3 'service' ( like in JAXP ). That will plug a helper
@@ -87,10 +83,10 @@ public class ProjectHelperRepository {
try {
ClassLoader classLoader = LoaderUtils.getContextClassLoader();
if (classLoader != null) {
- Enumeration resources =
+ Enumeration<URL> resources =
classLoader.getResources(ProjectHelper.SERVICE_ID);
while (resources.hasMoreElements()) {
- URL resource = (URL) resources.nextElement();
+ URL resource = resources.nextElement();
projectHelper =
getProjectHelperByService(resource.openStream());
registerProjectHelper(projectHelper);
@@ -119,7 +115,7 @@ public class ProjectHelperRepository {
* <p>
* The helper will be added after all the already registered helpers, but
* before the default one (ProjectHelper2)
- *
+ *
* @param helperClassName
* the fully qualified name of the helper
* @throws BuildException
@@ -137,23 +133,23 @@ public class ProjectHelperRepository {
* <p>
* The helper will be added after all the already registered helpers, but
* before the default one (ProjectHelper2)
- *
+ *
* @param helperClass
* the class of the helper
* @throws BuildException
* if there is no constructor with no argument
* @since Ant 1.8.2
*/
- public void registerProjectHelper(Class helperClass) throws BuildException {
+ public void registerProjectHelper(Class<? extends ProjectHelper> helperClass) throws BuildException {
try {
- registerProjectHelper(helperClass.getConstructor(NO_CLASS));
+ registerProjectHelper(helperClass.getConstructor());
} catch (NoSuchMethodException e) {
throw new BuildException("Couldn't find no-arg constructor in "
+ helperClass.getName());
}
}
- private void registerProjectHelper(Constructor helperConstructor) {
+ private void registerProjectHelper(Constructor<? extends ProjectHelper> helperConstructor) {
if (helperConstructor == null) {
return;
}
@@ -164,7 +160,7 @@ public class ProjectHelperRepository {
helpers.add(helperConstructor);
}
- private Constructor getProjectHelperBySystemProperty() {
+ private Constructor<? extends ProjectHelper> getProjectHelperBySystemProperty() {
String helperClass = System.getProperty(ProjectHelper.HELPER_PROPERTY);
try {
if (helperClass != null) {
@@ -182,7 +178,7 @@ public class ProjectHelperRepository {
return null;
}
- private Constructor getProjectHelperByService(InputStream is) {
+ private Constructor<? extends ProjectHelper> getProjectHelperByService(InputStream is) {
try {
// This code is needed by EBCDIC and other strange systems.
// It's a fix for bugs reported in xerces
@@ -214,21 +210,21 @@ public class ProjectHelperRepository {
* Get the constructor with not argument of an helper from its class name.
* It'll first try the thread class loader, then Class.forName() will load
* from the same loader that loaded this class.
- *
+ *
* @param helperClass
* The name of the class to create an instance of. Must not be
* <code>null</code>.
- *
+ *
* @return the constructor of the specified class.
- *
+ *
* @exception BuildException
* if the class cannot be found or if a constructor with no
* argument cannot be found.
*/
- private Constructor getHelperConstructor(String helperClass) throws BuildException {
+ private Constructor<? extends ProjectHelper> getHelperConstructor(String helperClass) throws BuildException {
ClassLoader classLoader = LoaderUtils.getContextClassLoader();
try {
- Class clazz = null;
+ Class<?> clazz = null;
if (classLoader != null) {
try {
clazz = classLoader.loadClass(helperClass);
@@ -239,7 +235,7 @@ public class ProjectHelperRepository {
if (clazz == null) {
clazz = Class.forName(helperClass);
}
- return clazz.getConstructor(NO_CLASS);
+ return clazz.asSubclass(ProjectHelper.class).getConstructor();
} catch (Exception e) {
throw new BuildException(e);
}
@@ -248,13 +244,12 @@ public class ProjectHelperRepository {
/**
* Get the helper that will be able to parse the specified build file. The helper
* will be chosen among the ones found in the classpath
- *
+ *
* @return the first ProjectHelper that fit the requirement (never <code>null</code>).
*/
public ProjectHelper getProjectHelperForBuildFile(Resource buildFile) throws BuildException {
- Iterator it = getHelpers();
- while (it.hasNext()) {
- ProjectHelper helper = (ProjectHelper) it.next();
+ for (Iterator<ProjectHelper> it = getHelpers(); it.hasNext();) {
+ ProjectHelper helper = it.next();
if (helper.canParseBuildFile(buildFile)) {
if (DEBUG) {
System.out.println("ProjectHelper "
@@ -272,13 +267,12 @@ public class ProjectHelperRepository {
/**
* Get the helper that will be able to parse the specified antlib. The helper
* will be chosen among the ones found in the classpath
- *
+ *
* @return the first ProjectHelper that fit the requirement (never <code>null</code>).
*/
public ProjectHelper getProjectHelperForAntlib(Resource antlib) throws BuildException {
- Iterator it = getHelpers();
- while (it.hasNext()) {
- ProjectHelper helper = (ProjectHelper) it.next();
+ for (Iterator<ProjectHelper> it = getHelpers(); it.hasNext();) {
+ ProjectHelper helper = it.next();
if (helper.canParseAntlibDescriptor(antlib)) {
if (DEBUG) {
System.out.println("ProjectHelper "
@@ -297,18 +291,18 @@ public class ProjectHelperRepository {
* Get an iterator on the list of project helpers configured. The iterator
* will always return at least one element as there will always be the
* default project helper configured.
- *
+ *
* @return an iterator of {@link ProjectHelper}
*/
- public Iterator getHelpers() {
+ public Iterator<ProjectHelper> getHelpers() {
return new ConstructingIterator(helpers.iterator());
}
- private static class ConstructingIterator implements Iterator {
- private final Iterator nested;
+ private static class ConstructingIterator implements Iterator<ProjectHelper> {
+ private final Iterator<Constructor<? extends ProjectHelper>> nested;
private boolean empty = false;
- ConstructingIterator(Iterator nested) {
+ ConstructingIterator(Iterator<Constructor<? extends ProjectHelper>> nested) {
this.nested = nested;
}
@@ -316,17 +310,17 @@ public class ProjectHelperRepository {
return nested.hasNext() || !empty;
}
- public Object next() {
- Constructor c;
+ public ProjectHelper next() {
+ Constructor<? extends ProjectHelper> c;
if (nested.hasNext()) {
- c = (Constructor) nested.next();
+ c = nested.next();
} else {
// last but not least, ant default project helper
empty = true;
c = PROJECTHELPER2_CONSTRUCTOR;
}
try {
- return c.newInstance(NO_OBJECT);
+ return c.newInstance();
} catch (Exception e) {
throw new BuildException("Failed to invoke no-arg constructor"
+ " on " + c.getName());
Modified: ant/core/trunk/src/main/org/apache/tools/ant/PropertyHelper.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/PropertyHelper.java?rev=1375137&r1=1375136&r2=1375137&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/PropertyHelper.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/PropertyHelper.java Mon Aug 20 17:49:13 2012
@@ -19,21 +19,20 @@ package org.apache.tools.ant;
import java.text.ParsePosition;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
+import java.util.Enumeration;
import java.util.HashSet;
import java.util.Hashtable;
-import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.Vector;
-import java.util.Enumeration;
-import java.util.Collection;
-import org.apache.tools.ant.property.NullReturn;
import org.apache.tools.ant.property.GetProperty;
+import org.apache.tools.ant.property.NullReturn;
import org.apache.tools.ant.property.ParseNextProperty;
-import org.apache.tools.ant.property.PropertyExpander;
import org.apache.tools.ant.property.ParseProperties;
+import org.apache.tools.ant.property.PropertyExpander;
/* ISSUES:
- ns param. It could be used to provide "namespaces" for properties, which
@@ -248,24 +247,24 @@ public class PropertyHelper implements G
private Project project;
private PropertyHelper next;
- private Hashtable delegates = new Hashtable();
+ private final Hashtable<Class<? extends Delegate>, List<Delegate>> delegates = new Hashtable<Class<? extends Delegate>, List<Delegate>>();
/** Project properties map (usually String to String). */
- private Hashtable properties = new Hashtable();
+ private Hashtable<String, Object> properties = new Hashtable<String, Object>();
/**
* Map of "user" properties (as created in the Ant task, for example).
* Note that these key/value pairs are also always put into the
* project properties, so only the project properties need to be queried.
*/
- private Hashtable userProperties = new Hashtable();
+ private Hashtable<String, Object> userProperties = new Hashtable<String, Object>();
/**
* Map of inherited "user" properties - that are those "user"
* properties that have been created by tasks and not been set
* from the command line or a GUI tool.
*/
- private Hashtable inheritedProperties = new Hashtable();
+ private Hashtable<String, Object> inheritedProperties = new Hashtable<String, Object>();
/**
* Default constructor.
@@ -414,7 +413,7 @@ public class PropertyHelper implements G
* @since Ant 1.8.0
* @return the expanders.
*/
- public Collection getExpanders() {
+ public Collection<PropertyExpander> getExpanders() {
return getDelegates(PropertyExpander.class);
}
@@ -519,8 +518,8 @@ public class PropertyHelper implements G
* <code>}</code>
* @deprecated use the other mechanisms of this class instead
*/
- public void parsePropertyString(String value, Vector fragments,
- Vector propertyRefs) throws BuildException {
+ public void parsePropertyString(String value, Vector<String> fragments,
+ Vector<String> propertyRefs) throws BuildException {
parsePropertyStringDefault(value, fragments, propertyRefs);
}
@@ -535,7 +534,7 @@ public class PropertyHelper implements G
* @param value The string to be scanned for property references.
* May be <code>null</code>, in which case this
* method returns immediately with no effect.
- * @param keys Mapping (String to String) of property names to their
+ * @param keys Mapping (String to Object) of property names to their
* values. If <code>null</code>, only project properties will
* be used.
*
@@ -545,7 +544,8 @@ public class PropertyHelper implements G
* @return the original string with the properties replaced, or
* <code>null</code> if the original string is <code>null</code>.
*/
- public String replaceProperties(String ns, String value, Hashtable keys) throws BuildException {
+ //TODO deprecate? Recall why no longer using ns/keys params
+ public String replaceProperties(String ns, String value, Hashtable<String, Object> keys) throws BuildException {
return replaceProperties(value);
}
@@ -629,8 +629,7 @@ public class PropertyHelper implements G
* @return true if the property is set.
*/
public boolean setProperty(String name, Object value, boolean verbose) {
- for (Iterator iter = getDelegates(PropertySetter.class).iterator(); iter.hasNext();) {
- PropertySetter setter = (PropertySetter) iter.next();
+ for (PropertySetter setter : getDelegates(PropertySetter.class)) {
if (setter.set(name, value, this)) {
return true;
}
@@ -691,9 +690,7 @@ public class PropertyHelper implements G
* @since Ant 1.8.0
*/
public void setNewProperty(String name, Object value) {
- for (Iterator iter = getDelegates(PropertySetter.class).iterator();
- iter.hasNext();) {
- PropertySetter setter = (PropertySetter) iter.next();
+ for (PropertySetter setter : getDelegates(PropertySetter.class)) {
if (setter.setNew(name, value, this)) {
return;
}
@@ -841,14 +838,12 @@ public class PropertyHelper implements G
if (name == null) {
return null;
}
- for (Iterator iter = getDelegates(PropertyEvaluator.class).iterator(); iter.hasNext();) {
- Object o = ((PropertyEvaluator) iter.next()).evaluate(name, this);
- if (o != null) {
- if (o instanceof NullReturn) {
- return null;
- }
- return o;
+ for (PropertyEvaluator evaluator : getDelegates(PropertyEvaluator.class)) {
+ final Object o = evaluator.evaluate(name, this);
+ if (o == null) {
+ continue;
}
+ return o instanceof NullReturn ? null : o;
}
return properties.get(name);
}
@@ -901,10 +896,10 @@ public class PropertyHelper implements G
*
* @return a hashtable containing all properties (including user properties).
*/
- public Hashtable getProperties() {
+ public Hashtable<String, Object> getProperties() {
//avoid concurrent modification:
synchronized (properties) {
- return new Hashtable(properties);
+ return new Hashtable<String, Object>(properties);
}
// There is a better way to save the context. This shouldn't
// delegate to next, it's for backward compatibility only.
@@ -918,10 +913,10 @@ public class PropertyHelper implements G
*
* @return a hashtable containing just the user properties
*/
- public Hashtable getUserProperties() {
+ public Hashtable<String, Object> getUserProperties() {
//avoid concurrent modification:
synchronized (userProperties) {
- return new Hashtable(userProperties);
+ return new Hashtable<String, Object>(userProperties);
}
}
@@ -933,10 +928,10 @@ public class PropertyHelper implements G
*
* @return a hashtable containing just the inherited properties
*/
- public Hashtable getInheritedProperties() {
+ public Hashtable<String, Object> getInheritedProperties() {
//avoid concurrent modification:
synchronized (inheritedProperties) {
- return new Hashtable(inheritedProperties);
+ return new Hashtable<String, Object>(inheritedProperties);
}
}
@@ -944,7 +939,7 @@ public class PropertyHelper implements G
* special back door for subclasses, internal access to the hashtables
* @return the live hashtable of all properties
*/
- protected Hashtable getInternalProperties() {
+ protected Hashtable<String, Object> getInternalProperties() {
return properties;
}
@@ -953,7 +948,7 @@ public class PropertyHelper implements G
*
* @return the live hashtable of user properties
*/
- protected Hashtable getInternalUserProperties() {
+ protected Hashtable<String, Object> getInternalUserProperties() {
return userProperties;
}
@@ -962,7 +957,7 @@ public class PropertyHelper implements G
*
* @return the live hashtable inherited properties
*/
- protected Hashtable getInternalInheritedProperties() {
+ protected Hashtable<String, Object> getInternalInheritedProperties() {
return inheritedProperties;
}
@@ -984,7 +979,7 @@ public class PropertyHelper implements G
public void copyInheritedProperties(Project other) {
//avoid concurrent modification:
synchronized (inheritedProperties) {
- Enumeration e = inheritedProperties.keys();
+ Enumeration<String> e = inheritedProperties.keys();
while (e.hasMoreElements()) {
String arg = e.nextElement().toString();
if (other.getUserProperty(arg) != null) {
@@ -1014,7 +1009,7 @@ public class PropertyHelper implements G
public void copyUserProperties(Project other) {
//avoid concurrent modification:
synchronized (userProperties) {
- Enumeration e = userProperties.keys();
+ Enumeration<String> e = userProperties.keys();
while (e.hasMoreElements()) {
Object arg = e.nextElement();
if (inheritedProperties.containsKey(arg)) {
@@ -1035,7 +1030,7 @@ public class PropertyHelper implements G
* Default parsing method. It is here only to support backward compatibility
* for the static ProjectHelper.parsePropertyString().
*/
- static void parsePropertyStringDefault(String value, Vector fragments, Vector propertyRefs)
+ static void parsePropertyStringDefault(String value, Vector<String> fragments, Vector<String> propertyRefs)
throws BuildException {
int prev = 0;
int pos;
@@ -1097,13 +1092,13 @@ public class PropertyHelper implements G
*/
public void add(Delegate delegate) {
synchronized (delegates) {
- for (Iterator iter = getDelegateInterfaces(delegate).iterator(); iter.hasNext();) {
- Object key = iter.next();
- List list = (List) delegates.get(key);
+ for (Class<? extends Delegate> key : getDelegateInterfaces(delegate)) {
+ List<Delegate> list = delegates.get(key);
if (list == null) {
- list = new ArrayList();
+ list = new ArrayList<Delegate>();
} else {
- list = new ArrayList(list);
+ //copy on write, top priority
+ list = new ArrayList<Delegate>(list);
list.remove(delegate);
}
list.add(0, delegate);
@@ -1114,15 +1109,16 @@ public class PropertyHelper implements G
/**
* Get the Collection of delegates of the specified type.
- *
+ *
* @param type
* delegate type.
* @return Collection.
* @since Ant 1.8.0
*/
- protected List getDelegates(Class type) {
- List r = (List) delegates.get(type);
- return r == null ? Collections.EMPTY_LIST : r;
+ protected <D extends Delegate> List<D> getDelegates(Class<D> type) {
+ @SuppressWarnings("unchecked")
+ final List<D> result = (List<D>) delegates.get(type);
+ return result == null ? Collections.<D> emptyList() : result;
}
/**
@@ -1131,14 +1127,16 @@ public class PropertyHelper implements G
* @return Set<Class>
* @since Ant 1.8.0
*/
- protected static Set getDelegateInterfaces(Delegate d) {
- HashSet result = new HashSet();
- Class c = d.getClass();
+ protected static Set<Class<? extends Delegate>> getDelegateInterfaces(Delegate d) {
+ final HashSet<Class<? extends Delegate>> result = new HashSet<Class<? extends Delegate>>();
+ Class<?> c = d.getClass();
while (c != null) {
- Class[] ifs = c.getInterfaces();
+ Class<?>[] ifs = c.getInterfaces();
for (int i = 0; i < ifs.length; i++) {
if (Delegate.class.isAssignableFrom(ifs[i])) {
- result.add(ifs[i]);
+ @SuppressWarnings("unchecked")
+ final Class<? extends Delegate> delegateInterface = (Class<? extends Delegate>) ifs[i];
+ result.add(delegateInterface);
}
}
c = c.getSuperclass();
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=1375137&r1=1375136&r2=1375137&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 Mon Aug 20 17:49:13 2012
@@ -25,11 +25,10 @@ import java.util.Enumeration;
import java.util.Hashtable;
import java.util.LinkedHashMap;
import java.util.List;
-import java.util.Iterator;
import java.util.Map.Entry;
import org.apache.tools.ant.util.CollectionUtils;
-import org.apache.tools.ant.taskdefs.MacroDef;
+import org.apache.tools.ant.taskdefs.MacroDef.Attribute;
import org.apache.tools.ant.taskdefs.MacroInstance;
import org.xml.sax.AttributeList;
import org.xml.sax.helpers.AttributeListImpl;
@@ -59,9 +58,6 @@ public class RuntimeConfigurable impleme
*/
private transient Object wrappedObject = null;
- /** the creator used to make the wrapped object */
- private transient IntrospectionHelper.Creator creator;
-
/**
* XML attributes for the element.
* @deprecated since 1.6.x
@@ -70,7 +66,7 @@ public class RuntimeConfigurable impleme
/** Attribute names and values. While the XML spec doesn't require
* preserving the order ( AFAIK ), some ant tests do rely on the
- * exact order.
+ * exact order.
* 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
@@ -124,7 +120,6 @@ public class RuntimeConfigurable impleme
* @param creator the creator object.
*/
synchronized void setCreator(IntrospectionHelper.Creator creator) {
- this.creator = creator;
}
/**
@@ -250,7 +245,7 @@ public class RuntimeConfigurable impleme
* Must not be <code>null</code>.
*/
public synchronized void addChild(RuntimeConfigurable child) {
- children = (children == null) ? new ArrayList() : children;
+ children = (children == null) ? new ArrayList<RuntimeConfigurable>() : children;
children.add(child);
}
@@ -263,7 +258,7 @@ public class RuntimeConfigurable impleme
* list.
*/
synchronized RuntimeConfigurable getChild(int index) {
- return (RuntimeConfigurable) children.get(index);
+ return children.get(index);
}
/**
@@ -271,8 +266,8 @@ public class RuntimeConfigurable impleme
* @return an enumeration of the child wrappers.
* @since Ant 1.6
*/
- public synchronized Enumeration getChildren() {
- return (children == null) ? new CollectionUtils.EmptyEnumeration()
+ public synchronized Enumeration<RuntimeConfigurable> getChildren() {
+ return (children == null) ? new CollectionUtils.EmptyEnumeration<RuntimeConfigurable>()
: Collections.enumeration(children);
}
@@ -405,8 +400,7 @@ public class RuntimeConfigurable impleme
attrValue = PropertyHelper.getPropertyHelper(p).parseProperties(value.toString());
}
if (target instanceof MacroInstance) {
- for (Iterator attrs = ((MacroInstance) target).getMacroDef().getAttributes().iterator(); attrs.hasNext();) {
- MacroDef.Attribute attr = (MacroDef.Attribute) attrs.next();
+ for (Attribute attr : ((MacroInstance) target).getMacroDef().getAttributes()) {
if (attr.getName().equals(name)) {
if (!attr.isDoubleExpanding()) {
attrValue = value;
@@ -469,8 +463,7 @@ public class RuntimeConfigurable impleme
public void applyPreSet(RuntimeConfigurable r) {
// Attributes
if (r.attributeMap != null) {
- for (Iterator i = r.attributeMap.keySet().iterator(); i.hasNext();) {
- String name = (String) i.next();
+ for (String name : r.attributeMap.keySet()) {
if (attributeMap == null || attributeMap.get(name) == null) {
setAttribute(name, (String) r.attributeMap.get(name));
}
@@ -482,7 +475,7 @@ public class RuntimeConfigurable impleme
// Children (this is a shadow of UnknownElement#children)
if (r.children != null) {
- List newChildren = new ArrayList();
+ List<RuntimeConfigurable> newChildren = new ArrayList<RuntimeConfigurable>();
newChildren.addAll(r.children);
if (children != null) {
newChildren.addAll(children);
Modified: ant/core/trunk/src/main/org/apache/tools/ant/Target.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/Target.java?rev=1375137&r1=1375136&r2=1375137&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/Target.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/Target.java Mon Aug 20 17:49:13 2012
@@ -21,7 +21,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Hashtable;
-import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
@@ -53,10 +52,10 @@ public class Target implements TaskConta
private Condition unlessCondition;
/** List of targets this target is dependent on. */
- private List/*<String>*/ dependencies = null;
+ private List<String> dependencies = null;
/** Children of this target (tasks and data types). */
- private List children = new ArrayList();
+ private List<Object> children = new ArrayList<Object>();
/** Since Ant 1.6.2 */
private Location location = Location.UNKNOWN_LOCATION;
@@ -138,9 +137,8 @@ public class Target implements TaskConta
* depends on. Must not be <code>null</code>.
*/
public void setDepends(String depS) {
- for (Iterator iter = parseDepends(depS, getName(), "depends").iterator();
- iter.hasNext(); ) {
- addDependency((String) iter.next());
+ for (String dep : parseDepends(depS, getName(), "depends")) {
+ addDependency(dep);
}
}
@@ -227,15 +225,13 @@ public class Target implements TaskConta
* @return an array of the tasks currently within this target
*/
public Task[] getTasks() {
- List tasks = new ArrayList(children.size());
- Iterator it = children.iterator();
- while (it.hasNext()) {
- Object o = it.next();
+ List<Task> tasks = new ArrayList<Task>(children.size());
+ for (Object o : children) {
if (o instanceof Task) {
- tasks.add(o);
+ tasks.add((Task) o);
}
}
- return (Task[]) tasks.toArray(new Task[tasks.size()]);
+ return tasks.toArray(new Task[tasks.size()]);
}
/**
@@ -246,7 +242,7 @@ public class Target implements TaskConta
*/
public void addDependency(String dependency) {
if (dependencies == null) {
- dependencies = new ArrayList(2);
+ dependencies = new ArrayList<String>(2);
}
dependencies.add(dependency);
}
@@ -256,9 +252,9 @@ public class Target implements TaskConta
*
* @return an enumeration of the dependencies of this target (enumeration of String)
*/
- public Enumeration getDependencies() {
+ public Enumeration<String> getDependencies() {
return Collections
- .enumeration(dependencies == null ? Collections.EMPTY_LIST : dependencies);
+ .enumeration(dependencies == null ? Collections.<String> emptyList() : dependencies);
}
/**
@@ -269,7 +265,7 @@ public class Target implements TaskConta
*/
public boolean dependsOn(String other) {
Project p = getProject();
- Hashtable t = p == null ? null : p.getTargets();
+ Hashtable<String, Target> t = p == null ? null : p.getTargets();
return p != null && p.topoSort(getName(), t, false).contains(t.get(other));
}
@@ -304,7 +300,7 @@ public class Target implements TaskConta
/**
* Same as {@link #setIf(String)} but requires a {@link Condition} instance
- *
+ *
* @since 1.9
*/
public void setIf(Condition condition) {
@@ -351,7 +347,7 @@ public class Target implements TaskConta
/**
* Same as {@link #setUnless(String)} but requires a {@link Condition} instance
- *
+ *
* @since 1.9
*/
public void setUnless(Condition condition) {
Modified: ant/core/trunk/src/main/org/apache/tools/ant/Task.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/Task.java?rev=1375137&r1=1375136&r2=1375137&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/Task.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/Task.java Mon Aug 20 17:49:13 2012
@@ -427,10 +427,9 @@ public abstract class Task extends Proje
*/
private void replaceChildren(RuntimeConfigurable wrapper,
UnknownElement parentElement) {
- Enumeration e = wrapper.getChildren();
+ Enumeration<RuntimeConfigurable> e = wrapper.getChildren();
while (e.hasMoreElements()) {
- RuntimeConfigurable childWrapper =
- (RuntimeConfigurable) e.nextElement();
+ RuntimeConfigurable childWrapper = e.nextElement();
UnknownElement childElement =
new UnknownElement(childWrapper.getElementTag());
parentElement.addChild(childElement);
Modified: ant/core/trunk/src/main/org/apache/tools/ant/TaskAdapter.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/TaskAdapter.java?rev=1375137&r1=1375136&r2=1375137&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/TaskAdapter.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/TaskAdapter.java Mon Aug 20 17:49:13 2012
@@ -74,7 +74,7 @@ public class TaskAdapter extends Task im
*
* @see Project#checkTaskClass(Class)
*/
- public static void checkTaskClass(final Class taskClass,
+ public static void checkTaskClass(final Class<?> taskClass,
final Project project) {
if (!Dispatchable.class.isAssignableFrom(taskClass)) {
// don't have to check for interface, since then
@@ -109,7 +109,7 @@ public class TaskAdapter extends Task im
* The class must have a public no-arg "execute()" method.
* @param proxyClass the class to check.
*/
- public void checkProxyClass(Class proxyClass) {
+ public void checkProxyClass(Class<?> proxyClass) {
checkTaskClass(proxyClass, getProject());
}
Modified: ant/core/trunk/src/main/org/apache/tools/ant/TypeAdapter.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/TypeAdapter.java?rev=1375137&r1=1375136&r2=1375137&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/TypeAdapter.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/TypeAdapter.java Mon Aug 20 17:49:13 2012
@@ -62,5 +62,5 @@ public interface TypeAdapter {
*
* @param proxyClass the class to be checked.
*/
- void checkProxyClass(Class proxyClass);
+ void checkProxyClass(Class<?> proxyClass);
}
Modified: ant/core/trunk/src/main/org/apache/tools/ant/UnknownElement.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/UnknownElement.java?rev=1375137&r1=1375136&r2=1375137&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/UnknownElement.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/UnknownElement.java Mon Aug 20 17:49:13 2012
@@ -59,7 +59,7 @@ public class UnknownElement extends Task
/**
* List of child elements (UnknownElements).
*/
- private List/*<UnknownElement>*/ children = null;
+ private List<UnknownElement> children = null;
/** Specifies if a predefined definition has been done */
private boolean presetDefed = false;
@@ -77,7 +77,7 @@ public class UnknownElement extends Task
/**
* @return the list of nested UnknownElements for this UnknownElement.
*/
- public List getChildren() {
+ public List<UnknownElement> getChildren() {
return children;
}
@@ -309,7 +309,7 @@ public class UnknownElement extends Task
*/
public void addChild(UnknownElement child) {
if (children == null) {
- children = new ArrayList();
+ children = new ArrayList<UnknownElement>();
}
children.add(child);
}
@@ -336,15 +336,15 @@ public class UnknownElement extends Task
}
String parentUri = getNamespace();
- Class parentClass = parent.getClass();
+ Class<?> parentClass = parent.getClass();
IntrospectionHelper ih = IntrospectionHelper.getHelper(getProject(), parentClass);
if (children != null) {
- Iterator it = children.iterator();
+ Iterator<UnknownElement> it = children.iterator();
for (int i = 0; it.hasNext(); i++) {
RuntimeConfigurable childWrapper = parentWrapper.getChild(i);
- UnknownElement child = (UnknownElement) it.next();
+ UnknownElement child = it.next();
try {
if (!handleChild(
parentUri, ih, parent, child, childWrapper)) {
@@ -390,7 +390,7 @@ public class UnknownElement extends Task
// Do the runtime
getWrapper().applyPreSet(u.getWrapper());
if (u.children != null) {
- List newChildren = new ArrayList();
+ List<UnknownElement> newChildren = new ArrayList<UnknownElement>();
newChildren.addAll(u.children);
if (children != null) {
newChildren.addAll(children);
@@ -668,16 +668,14 @@ public class UnknownElement extends Task
RuntimeConfigurable copyRC = new RuntimeConfigurable(
ret, getTaskName());
copyRC.setPolyType(getWrapper().getPolyType());
- Map m = getWrapper().getAttributeMap();
- for (Iterator i = m.entrySet().iterator(); i.hasNext();) {
- Map.Entry entry = (Map.Entry) i.next();
- copyRC.setAttribute(
- (String) entry.getKey(), (String) entry.getValue());
+ Map<String, Object> m = getWrapper().getAttributeMap();
+ for (Map.Entry<String, Object> entry : m.entrySet()) {
+ copyRC.setAttribute(entry.getKey(), (String) entry.getValue());
}
copyRC.addText(getWrapper().getText().toString());
- for (Enumeration e = getWrapper().getChildren(); e.hasMoreElements();) {
- RuntimeConfigurable r = (RuntimeConfigurable) e.nextElement();
+ for (Enumeration<RuntimeConfigurable> e = getWrapper().getChildren(); e.hasMoreElements();) {
+ RuntimeConfigurable r = e.nextElement();
UnknownElement ueChild = (UnknownElement) r.getProxy();
UnknownElement copyChild = ueChild.copy(newProject);
copyRC.addChild(copyChild.getWrapper());
Modified: ant/core/trunk/src/main/org/apache/tools/ant/UnsupportedAttributeException.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/UnsupportedAttributeException.java?rev=1375137&r1=1375136&r2=1375137&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/UnsupportedAttributeException.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/UnsupportedAttributeException.java Mon Aug 20 17:49:13 2012
@@ -23,6 +23,7 @@ package org.apache.tools.ant;
* @since Ant 1.6.3
*/
public class UnsupportedAttributeException extends BuildException {
+ private static final long serialVersionUID = 1L;
private final String attribute;
Modified: ant/core/trunk/src/main/org/apache/tools/ant/UnsupportedElementException.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/UnsupportedElementException.java?rev=1375137&r1=1375136&r2=1375137&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/UnsupportedElementException.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/UnsupportedElementException.java Mon Aug 20 17:49:13 2012
@@ -32,6 +32,7 @@ package org.apache.tools.ant;
* @since Ant 1.6.3
*/
public class UnsupportedElementException extends BuildException {
+ private static final long serialVersionUID = 1L;
private final String element;
Modified: ant/core/trunk/src/main/org/apache/tools/ant/XmlLogger.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/XmlLogger.java?rev=1375137&r1=1375136&r2=1375137&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/XmlLogger.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/XmlLogger.java Mon Aug 20 17:49:13 2012
@@ -28,6 +28,7 @@ import java.util.Stack;
import java.util.Enumeration;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
+
import org.apache.tools.ant.util.DOMElementWriter;
import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.util.StringUtils;
@@ -106,16 +107,16 @@ public class XmlLogger implements BuildL
private Document doc = builder.newDocument();
/** Mapping for when tasks started (Task to TimedElement). */
- private Hashtable tasks = new Hashtable();
+ private Hashtable<Task, TimedElement> tasks = new Hashtable<Task, TimedElement>();
- /** Mapping for when targets started (Task to TimedElement). */
- private Hashtable targets = new Hashtable();
+ /** Mapping for when targets started (Target to TimedElement). */
+ private Hashtable<Target, TimedElement> targets = new Hashtable<Target, XmlLogger.TimedElement>();
/**
* Mapping of threads to stacks of elements
* (Thread to Stack of TimedElement).
*/
- private Hashtable threadStacks = new Hashtable();
+ private Hashtable<Thread, Stack<TimedElement>> threadStacks = new Hashtable<Thread, Stack<TimedElement>>();
/**
* When the build started.
@@ -210,10 +211,10 @@ public class XmlLogger implements BuildL
* Returns the stack of timed elements for the current thread.
* @return the stack of timed elements for the current thread
*/
- private Stack getStack() {
- Stack threadStack = (Stack) threadStacks.get(Thread.currentThread());
+ private Stack<TimedElement> getStack() {
+ Stack<TimedElement> threadStack = threadStacks.get(Thread.currentThread());
if (threadStack == null) {
- threadStack = new Stack();
+ threadStack = new Stack<TimedElement>();
threadStacks.put(Thread.currentThread(), threadStack);
}
/* For debugging purposes uncomment:
@@ -256,9 +257,9 @@ public class XmlLogger implements BuildL
targetElement.element.setAttribute(TIME_ATTR, DefaultLogger.formatTime(totalTime));
TimedElement parentElement = null;
- Stack threadStack = getStack();
+ Stack<TimedElement> threadStack = getStack();
if (!threadStack.empty()) {
- TimedElement poppedStack = (TimedElement) threadStack.pop();
+ TimedElement poppedStack = threadStack.pop();
if (poppedStack != targetElement) {
throw new RuntimeException("Mismatch - popped element = " + poppedStack
+ " finished target element = " + targetElement);
@@ -326,9 +327,9 @@ public class XmlLogger implements BuildL
} else {
synchronizedAppend(targetElement.element, taskElement.element);
}
- Stack threadStack = getStack();
+ Stack<TimedElement> threadStack = getStack();
if (!threadStack.empty()) {
- TimedElement poppedStack = (TimedElement) threadStack.pop();
+ TimedElement poppedStack = threadStack.pop();
if (poppedStack != taskElement) {
throw new RuntimeException("Mismatch - popped element = " + poppedStack
+ " finished task element = " + taskElement);
@@ -348,8 +349,8 @@ public class XmlLogger implements BuildL
if (element != null) {
return element;
}
- for (Enumeration e = tasks.keys(); e.hasMoreElements();) {
- Task key = (Task) e.nextElement();
+ for (Enumeration<Task> e = tasks.keys(); e.hasMoreElements();) {
+ Task key = e.nextElement();
if (key instanceof UnknownElement) {
if (((UnknownElement) key).getTask() == task) {
return (TimedElement) tasks.get(key);
Modified: ant/core/trunk/src/main/org/apache/tools/ant/property/LocalProperties.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/property/LocalProperties.java?rev=1375137&r1=1375136&r2=1375137&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/property/LocalProperties.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/property/LocalProperties.java Mon Aug 20 17:49:13 2012
@@ -26,7 +26,7 @@ import org.apache.tools.ant.MagicNames;
* @since Ant 1.8.0
*/
public class LocalProperties
- extends InheritableThreadLocal
+ extends InheritableThreadLocal<LocalPropertyStack>
implements PropertyHelper.PropertyEvaluator,
PropertyHelper.PropertySetter {
@@ -62,7 +62,7 @@ public class LocalProperties
* Get the initial value.
* @return a new localproperties stack.
*/
- protected synchronized Object initialValue() {
+ protected synchronized LocalPropertyStack initialValue() {
return new LocalPropertyStack();
}