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 [1/3] - in /ant/core/trunk/src/main/org/apache/tools/ant: ./ property/ taskdefs/ types/ util/

Author: mbenson
Date: Mon Aug 20 17:49:13 2012
New Revision: 1375137

URL: http://svn.apache.org/viewvc?rev=1375137&view=rev
Log:
java 5 updates

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/AntClassLoader.java
    ant/core/trunk/src/main/org/apache/tools/ant/AntTypeDefinition.java
    ant/core/trunk/src/main/org/apache/tools/ant/BuildException.java
    ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java
    ant/core/trunk/src/main/org/apache/tools/ant/DemuxOutputStream.java
    ant/core/trunk/src/main/org/apache/tools/ant/Diagnostics.java
    ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java
    ant/core/trunk/src/main/org/apache/tools/ant/IntrospectionHelper.java
    ant/core/trunk/src/main/org/apache/tools/ant/Location.java
    ant/core/trunk/src/main/org/apache/tools/ant/Main.java
    ant/core/trunk/src/main/org/apache/tools/ant/Project.java
    ant/core/trunk/src/main/org/apache/tools/ant/ProjectHelper.java
    ant/core/trunk/src/main/org/apache/tools/ant/ProjectHelperRepository.java
    ant/core/trunk/src/main/org/apache/tools/ant/PropertyHelper.java
    ant/core/trunk/src/main/org/apache/tools/ant/RuntimeConfigurable.java
    ant/core/trunk/src/main/org/apache/tools/ant/Target.java
    ant/core/trunk/src/main/org/apache/tools/ant/Task.java
    ant/core/trunk/src/main/org/apache/tools/ant/TaskAdapter.java
    ant/core/trunk/src/main/org/apache/tools/ant/TypeAdapter.java
    ant/core/trunk/src/main/org/apache/tools/ant/UnknownElement.java
    ant/core/trunk/src/main/org/apache/tools/ant/UnsupportedAttributeException.java
    ant/core/trunk/src/main/org/apache/tools/ant/UnsupportedElementException.java
    ant/core/trunk/src/main/org/apache/tools/ant/XmlLogger.java
    ant/core/trunk/src/main/org/apache/tools/ant/property/LocalProperties.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/MacroDef.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/FilterSet.java
    ant/core/trunk/src/main/org/apache/tools/ant/util/CollectionUtils.java
    ant/core/trunk/src/main/org/apache/tools/ant/util/JavaEnvUtils.java
    ant/core/trunk/src/main/org/apache/tools/ant/util/VectorSet.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/AntClassLoader.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/AntClassLoader.java?rev=1375137&r1=1375136&r2=1375137&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/AntClassLoader.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/AntClassLoader.java Mon Aug 20 17:49:13 2012
@@ -80,7 +80,7 @@ public class AntClassLoader extends Clas
      * @see AntClassLoader#findResources(String)
      * @see java.lang.ClassLoader#getResources(String)
      */
-    private class ResourceEnumeration implements Enumeration {
+    private class ResourceEnumeration implements Enumeration<URL> {
         /**
          * The name of the resource being searched for.
          */
@@ -126,7 +126,7 @@ public class AntClassLoader extends Clas
          *
          * @return the next resource in the enumeration
          */
-        public Object nextElement() {
+        public URL nextElement() {
             URL ret = this.nextResource;
             if (ret == null) {
                 throw new NoSuchElementException();
@@ -171,7 +171,7 @@ public class AntClassLoader extends Clas
      * The components of the classpath that the classloader searches
      * for classes.
      */
-    private Vector pathComponents  = new VectorSet();
+    private Vector<File> pathComponents  = new VectorSet<File>();
 
     /**
      * The project to which this class loader belongs.
@@ -189,14 +189,14 @@ public class AntClassLoader extends Clas
      * loader regardless of whether the parent class loader is being searched
      * first or not.
      */
-    private Vector systemPackages = new Vector();
+    private Vector<String> systemPackages = new Vector<String>();
 
     /**
      * These are the package roots that are to be loaded by this class loader
      * regardless of whether the parent class loader is being searched first
      * or not.
      */
-    private Vector loaderPackages = new Vector();
+    private Vector<String> loaderPackages = new Vector<String>();
 
     /**
      * Whether or not this classloader will ignore the base
@@ -214,10 +214,10 @@ public class AntClassLoader extends Clas
     /**
      * A hashtable of zip files opened by the classloader (File to JarFile).
      */
-    private Hashtable jarFiles = new Hashtable();
+    private Hashtable<File, JarFile> jarFiles = new Hashtable<File, JarFile>();
 
     /** Static map of jar file/time to manifest class-path entries */
-    private static Map/*<String,String>*/ pathMap = Collections.synchronizedMap(new HashMap());
+    private static Map<String,String> pathMap = Collections.synchronizedMap(new HashMap<String, String>());
 
     /**
      * The context loader saved when setting the thread's current
@@ -535,16 +535,16 @@ public class AntClassLoader extends Clas
      *         separated by the path separator for the system.
      */
     public String getClasspath() {
-        StringBuffer sb = new StringBuffer();
+        final StringBuilder sb = new StringBuilder();
         boolean firstPass = true;
-        Enumeration componentEnum = pathComponents.elements();
+        Enumeration<File> componentEnum = pathComponents.elements();
         while (componentEnum.hasMoreElements()) {
             if (!firstPass) {
                 sb.append(System.getProperty("path.separator"));
             } else {
                 firstPass = false;
             }
-            sb.append(((File) componentEnum.nextElement()).getAbsolutePath());
+            sb.append(componentEnum.nextElement().getAbsolutePath());
         }
         return sb.toString();
     }
@@ -572,13 +572,13 @@ public class AntClassLoader extends Clas
      * @deprecated since 1.6.x.
      *             Use Class.forName with initialize=true instead.
      */
-    public static void initializeClass(Class theClass) {
+    public static void initializeClass(Class<?> theClass) {
         // ***HACK*** We ask the VM to create an instance
         // by voluntarily providing illegal arguments to force
         // the VM to run the class' static initializer, while
         // at the same time not running a valid constructor.
 
-        final Constructor[] cons = theClass.getDeclaredConstructors();
+        final Constructor<?>[] cons = theClass.getDeclaredConstructors();
         //At least one constructor is guaranteed to be there, but check anyway.
         if (cons != null) {
             if (cons.length > 0 && cons[0] != null) {
@@ -646,10 +646,10 @@ public class AntClassLoader extends Clas
      * @exception ClassNotFoundException if the requested class does not exist
      *                                   on this loader's classpath.
      */
-    public Class forceLoadClass(String classname) throws ClassNotFoundException {
+    public Class<?> forceLoadClass(String classname) throws ClassNotFoundException {
         log("force loading " + classname, Project.MSG_DEBUG);
 
-        Class theClass = findLoadedClass(classname);
+        Class<?> theClass = findLoadedClass(classname);
 
         if (theClass == null) {
             theClass = findClass(classname);
@@ -673,10 +673,10 @@ public class AntClassLoader extends Clas
      * @exception ClassNotFoundException if the requested class does not exist
      * on this loader's classpath.
      */
-    public Class forceLoadSystemClass(String classname) throws ClassNotFoundException {
+    public Class<?> forceLoadSystemClass(String classname) throws ClassNotFoundException {
         log("force system loading " + classname, Project.MSG_DEBUG);
 
-        Class theClass = findLoadedClass(classname);
+        Class<?> theClass = findLoadedClass(classname);
 
         if (theClass == null) {
             theClass = findBaseClass(classname);
@@ -739,9 +739,9 @@ public class AntClassLoader extends Clas
         // find the class we want.
         InputStream stream = null;
 
-        Enumeration e = pathComponents.elements();
+        Enumeration<File> e = pathComponents.elements();
         while (e.hasMoreElements() && stream == null) {
-            File pathComponent = (File) e.nextElement();
+            File pathComponent = e.nextElement();
             stream = getResourceStream(pathComponent, name);
         }
         return stream;
@@ -828,15 +828,15 @@ public class AntClassLoader extends Clas
 
         boolean useParentFirst = parentFirst;
 
-        for (Enumeration e = systemPackages.elements(); e.hasMoreElements();) {
-            String packageName = (String) e.nextElement();
+        for (Enumeration<String> e = systemPackages.elements(); e.hasMoreElements();) {
+            String packageName = e.nextElement();
             if (resourceName.startsWith(packageName)) {
                 useParentFirst = true;
                 break;
             }
         }
-        for (Enumeration e = loaderPackages.elements(); e.hasMoreElements();) {
-            String packageName = (String) e.nextElement();
+        for (Enumeration<String> e = loaderPackages.elements(); e.hasMoreElements();) {
+            String packageName = e.nextElement();
             if (resourceName.startsWith(packageName)) {
                 useParentFirst = false;
                 break;
@@ -881,9 +881,9 @@ public class AntClassLoader extends Clas
         } else {
             // try and load from this loader if the parent either didn't find
             // it or wasn't consulted.
-            Enumeration e = pathComponents.elements();
+            Enumeration<File> e = pathComponents.elements();
             while (e.hasMoreElements() && url == null) {
-                File pathComponent = (File) e.nextElement();
+                File pathComponent = e.nextElement();
                 url = getResourceURL(pathComponent, name);
                 if (url != null) {
                     log("Resource " + name + " loaded from ant loader", Project.MSG_DEBUG);
@@ -917,7 +917,7 @@ public class AntClassLoader extends Clas
      *
      * @since Ant 1.8.0
      */
-    public Enumeration/*<URL>*/ getNamedResources(String name)
+    public Enumeration<URL> getNamedResources(String name)
         throws IOException {
         return findResources(name, false);
     }
@@ -931,7 +931,7 @@ public class AntClassLoader extends Clas
      * @return an enumeration of URLs for the resources
      * @exception IOException if I/O errors occurs (can't happen)
      */
-    protected Enumeration/*<URL>*/ findResources(String name) throws IOException {
+    protected Enumeration<URL> findResources(String name) throws IOException {
         return findResources(name, true);
     }
 
@@ -947,11 +947,11 @@ public class AntClassLoader extends Clas
      * @return an enumeration of URLs for the resources
      * @exception IOException if I/O errors occurs (can't happen)
      */
-    protected Enumeration/*<URL>*/ findResources(String name,
+    protected Enumeration<URL> findResources(String name,
                                                  boolean parentHasBeenSearched)
         throws IOException {
-        Enumeration/*<URL>*/ mine = new ResourceEnumeration(name);
-        Enumeration/*<URL>*/ base;
+        Enumeration<URL> mine = new ResourceEnumeration(name);
+        Enumeration<URL> base;
         if (parent != null && (!parentHasBeenSearched || parent != getParent())) {
             // Delegate to the parent:
             base = parent.getResources(name);
@@ -961,7 +961,7 @@ public class AntClassLoader extends Clas
         } else {
             // ClassLoader.this.parent is already delegated to for example from
             // ClassLoader.getResources, no need:
-            base = new CollectionUtils.EmptyEnumeration();
+            base = new CollectionUtils.EmptyEnumeration<URL>();
         }
         if (isParentFirst(name)) {
             // Normal case.
@@ -1049,13 +1049,13 @@ public class AntClassLoader extends Clas
      * on the system classpath (when not in isolated mode) or this loader's
      * classpath.
      */
-    protected synchronized Class loadClass(String classname, boolean resolve)
+    protected synchronized Class<?> loadClass(String classname, boolean resolve)
             throws ClassNotFoundException {
         // 'sync' is needed - otherwise 2 threads can load the same class
         // twice, resulting in LinkageError: duplicated class definition.
         // findLoadedClass avoids that, but without sync it won't work.
 
-        Class theClass = findLoadedClass(classname);
+        Class<?> theClass = findLoadedClass(classname);
         if (theClass != null) {
             return theClass;
         }
@@ -1113,7 +1113,7 @@ public class AntClassLoader extends Clas
      *
      * @throws IOException if the class data cannot be read.
      */
-    protected Class defineClassFromData(File container, byte[] classData, String classname)
+    protected Class<?> defineClassFromData(File container, byte[] classData, String classname)
             throws IOException {
         definePackage(container, classname);
         ProtectionDomain currentPd = Project.class.getProtectionDomain();
@@ -1286,7 +1286,7 @@ public class AntClassLoader extends Clas
      * @exception SecurityException if there is a security problem while
      * reading the class from the stream.
      */
-    private Class getClassFromStream(InputStream stream, String classname, File container)
+    private Class<?> getClassFromStream(InputStream stream, String classname, File container)
             throws IOException, SecurityException {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         int bytesRead = -1;
@@ -1310,7 +1310,7 @@ public class AntClassLoader extends Clas
      * @exception ClassNotFoundException if the requested class does not exist
      *                                   on this loader's classpath.
      */
-    public Class findClass(String name) throws ClassNotFoundException {
+    public Class<?> findClass(String name) throws ClassNotFoundException {
         log("Finding class " + name, Project.MSG_DEBUG);
         return findClassInComponents(name);
     }
@@ -1337,35 +1337,33 @@ public class AntClassLoader extends Clas
      * @exception ClassNotFoundException if the requested class does not exist
      * on this loader's classpath.
      */
-    private Class findClassInComponents(String name)
+    private Class<?> findClassInComponents(String name)
         throws ClassNotFoundException {
         // we need to search the components of the path to see if
         // we can find the class we want.
-        InputStream stream = null;
         String classFilename = getClassFilename(name);
-        try {
-            Enumeration e = pathComponents.elements();
-            while (e.hasMoreElements()) {
-                File pathComponent = (File) e.nextElement();
-                try {
-                    stream = getResourceStream(pathComponent, classFilename);
-                    if (stream != null) {
-                        log("Loaded from " + pathComponent + " "
-                            + classFilename, Project.MSG_DEBUG);
-                        return getClassFromStream(stream, name, pathComponent);
-                    }
-                } catch (SecurityException se) {
-                    throw se;
-                } catch (IOException ioe) {
-                    // ioe.printStackTrace();
-                    log("Exception reading component " + pathComponent + " (reason: "
-                            + ioe.getMessage() + ")", Project.MSG_VERBOSE);
+        Enumeration<File> e = pathComponents.elements();
+        while (e.hasMoreElements()) {
+            File pathComponent = (File) e.nextElement();
+            InputStream stream = null;
+            try {
+                stream = getResourceStream(pathComponent, classFilename);
+                if (stream != null) {
+                    log("Loaded from " + pathComponent + " "
+                        + classFilename, Project.MSG_DEBUG);
+                    return getClassFromStream(stream, name, pathComponent);
                 }
+            } catch (SecurityException se) {
+                throw se;
+            } catch (IOException ioe) {
+                // ioe.printStackTrace();
+                log("Exception reading component " + pathComponent + " (reason: "
+                        + ioe.getMessage() + ")", Project.MSG_VERBOSE);
+            } finally {
+                FileUtils.close(stream);
             }
-            throw new ClassNotFoundException(name);
-        } finally {
-            FileUtils.close(stream);
         }
+        throw new ClassNotFoundException(name);
     }
 
     /**
@@ -1383,7 +1381,7 @@ public class AntClassLoader extends Clas
      * @exception ClassNotFoundException if the requested class does not exist
      * on this loader's classpath.
      */
-    private Class findBaseClass(String name) throws ClassNotFoundException {
+    private Class<?> findBaseClass(String name) throws ClassNotFoundException {
         return parent == null ? findSystemClass(name) : parent.loadClass(name);
     }
 
@@ -1392,15 +1390,15 @@ public class AntClassLoader extends Clas
      * files are closed.
      */
     public synchronized void cleanup() {
-        for (Enumeration e = jarFiles.elements(); e.hasMoreElements();) {
-            JarFile jarFile = (JarFile) e.nextElement();
+        for (Enumeration<JarFile> e = jarFiles.elements(); e.hasMoreElements();) {
+            JarFile jarFile = e.nextElement();
             try {
                 jarFile.close();
             } catch (IOException ioe) {
                 // ignore
             }
         }
-        jarFiles = new Hashtable();
+        jarFiles = new Hashtable<File, JarFile>();
         if (project != null) {
             project.removeBuildListener(this);
         }
@@ -1512,10 +1510,10 @@ public class AntClassLoader extends Clas
      * here
      */
     public void addJavaLibraries() {
-        Vector packages = JavaEnvUtils.getJrePackages();
-        Enumeration e = packages.elements();
+        Vector<String> packages = JavaEnvUtils.getJrePackages();
+        Enumeration<String> e = packages.elements();
         while (e.hasMoreElements()) {
-            String packageName = (String) e.nextElement();
+            String packageName = e.nextElement();
             addSystemPackageRoot(packageName);
         }
     }
@@ -1528,8 +1526,8 @@ public class AntClassLoader extends Clas
         return "AntClassLoader[" + getClasspath() + "]";
     }
 
-    private static Class subClassToLoad = null;
-    private static final Class[] CONSTRUCTOR_ARGS = new Class[] {
+    private static Class<?> subClassToLoad = null;
+    private static final Class<?>[] CONSTRUCTOR_ARGS = new Class[] {
         ClassLoader.class, Project.class, Path.class, Boolean.TYPE
     };
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/AntTypeDefinition.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/AntTypeDefinition.java?rev=1375137&r1=1375136&r2=1375137&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/AntTypeDefinition.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/AntTypeDefinition.java Mon Aug 20 17:49:13 2012
@@ -33,9 +33,9 @@ import java.lang.reflect.Constructor;
  */
 public class AntTypeDefinition {
     private String      name;
-    private Class       clazz;
-    private Class       adapterClass;
-    private Class       adaptToClass;
+    private Class<?>       clazz;
+    private Class<?>       adapterClass;
+    private Class<?>       adaptToClass;
     private String      className;
     private ClassLoader classLoader;
     private boolean     restrict = false;
@@ -77,7 +77,7 @@ public class AntTypeDefinition {
      * As a side-effect may set the classloader and classname.
      * @param clazz the class of this definition.
      */
-    public void setClass(Class clazz) {
+    public void setClass(Class<?> clazz) {
         this.clazz = clazz;
         if (clazz == null) {
             return;
@@ -109,7 +109,7 @@ public class AntTypeDefinition {
      * required.
      * @param adapterClass the adapterClass.
      */
-    public void setAdapterClass(Class adapterClass) {
+    public void setAdapterClass(Class<?> adapterClass) {
         this.adapterClass = adapterClass;
     }
 
@@ -118,7 +118,7 @@ public class AntTypeDefinition {
      * @param adaptToClass the assignable class.
      */
 
-    public void setAdaptToClass(Class adaptToClass) {
+    public void setAdaptToClass(Class<?> adaptToClass) {
         this.adaptToClass = adaptToClass;
     }
 
@@ -148,9 +148,9 @@ public class AntTypeDefinition {
      * @param project the current project.
      * @return the exposed class - may return null if unable to load the class
      */
-    public Class getExposedClass(Project project) {
+    public Class<?> getExposedClass(Project project) {
         if (adaptToClass != null) {
-            Class z = getTypeClass(project);
+            Class<?> z = getTypeClass(project);
             if (z == null || adaptToClass.isAssignableFrom(z)) {
                 return z;
             }
@@ -163,7 +163,7 @@ public class AntTypeDefinition {
      * @param project the current project.
      * @return the type of the definition.
      */
-    public Class getTypeClass(Project project) {
+    public Class<?> getTypeClass(Project project) {
         try {
             return innerGetTypeClass();
         } catch (NoClassDefFoundError ncdfe) {
@@ -184,7 +184,7 @@ public class AntTypeDefinition {
      * @throws NoClassDefFoundError   if the there is an error
      *                                finding the class.
      */
-    public Class innerGetTypeClass() throws ClassNotFoundException {
+    public Class<?> innerGetTypeClass() throws ClassNotFoundException {
         if (clazz != null) {
             return clazz;
         }
@@ -212,7 +212,7 @@ public class AntTypeDefinition {
      * @return the component as an <code>Object</code>.
      */
     private Object icreate(Project project) {
-        Class c = getTypeClass(project);
+        Class<?> c = getTypeClass(project);
         if (c == null) {
             return null;
         }
@@ -269,7 +269,7 @@ public class AntTypeDefinition {
      * and invoke it.
      * @return the instantiated <code>Object</code>.
      */
-    private Object createAndSet(Project project, Class c) {
+    private Object createAndSet(Project project, Class<?> c) {
         try {
             Object o = innerCreateAndSet(c, project);
             return o;
@@ -307,12 +307,12 @@ public class AntTypeDefinition {
      * @throws IllegalAccessException cannot access the object.
      * @throws InvocationTargetException error in invocation.
      */
-    public Object innerCreateAndSet(Class newclass, Project project)
+    public <T> T innerCreateAndSet(Class<T> newclass, Project project)
             throws NoSuchMethodException,
             InstantiationException,
             IllegalAccessException,
             InvocationTargetException {
-        Constructor ctor = null;
+        Constructor<T> ctor;
         boolean noArg = false;
         // DataType can have a "no arg" constructor or take a single
         // Project argument.
@@ -325,7 +325,7 @@ public class AntTypeDefinition {
             noArg = false;
         }
         //now we instantiate
-        Object o = ctor.newInstance(
+        T o = ctor.newInstance(
             ((noArg) ? new Object[0] : new Object[] {project}));
 
         //set up project references.
@@ -382,7 +382,7 @@ public class AntTypeDefinition {
             .equals(((AntClassLoader) newLoader).getClasspath()));
     }
 
-    private String extractClassname(Class c) {
+    private String extractClassname(Class<?> c) {
         return (c == null) ? "<null>" : c.getClass().getName();
     }
 }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/BuildException.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/BuildException.java?rev=1375137&r1=1375136&r2=1375137&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/BuildException.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/BuildException.java Mon Aug 20 17:49:13 2012
@@ -54,8 +54,7 @@ public class BuildException extends Runt
      *              May be <code>null</code>.
      */
     public BuildException(String message, Throwable cause) {
-        super(message);
-        initCause(cause);
+        super(message, cause);
     }
 
     /**

Modified: ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java?rev=1375137&r1=1375136&r2=1375137&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java Mon Aug 20 17:49:13 2012
@@ -17,28 +17,28 @@
  */
 package org.apache.tools.ant;
 
-import java.lang.reflect.Modifier;
-import java.lang.reflect.InvocationTargetException;
-import java.io.InputStream;
-import java.io.IOException;
 import java.io.File;
-import java.io.StringWriter;
+import java.io.IOException;
+import java.io.InputStream;
 import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
 import java.util.Enumeration;
-import java.util.Hashtable;
+import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Hashtable;
 import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
 import java.util.Stack;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.HashMap;
 
-import org.apache.tools.ant.taskdefs.Typedef;
-import org.apache.tools.ant.taskdefs.Definer;
 import org.apache.tools.ant.launch.Launcher;
+import org.apache.tools.ant.taskdefs.Definer;
+import org.apache.tools.ant.taskdefs.Typedef;
 import org.apache.tools.ant.util.FileUtils;
 
 /**
@@ -59,31 +59,31 @@ import org.apache.tools.ant.util.FileUti
  */
 public class ComponentHelper  {
     /** Map of component name to lists of restricted definitions */
-    private Map          restrictedDefinitions = new HashMap();
+    private Map<String, List<AntTypeDefinition>>          restrictedDefinitions = new HashMap<String, List<AntTypeDefinition>>();
 
     /** Map from component name to anttypedefinition */
-    private AntTypeTable antTypeTable;
+    private final Hashtable<String, AntTypeDefinition> antTypeTable = new Hashtable<String, AntTypeDefinition>();
 
     /** Map of tasks generated from antTypeTable */
-    private final Hashtable taskClassDefinitions = new Hashtable();
+    private final Hashtable<String, Class<?>> taskClassDefinitions = new Hashtable<String, Class<?>>();
 
     /** flag to rebuild taskClassDefinitions */
     private boolean rebuildTaskClassDefinitions = true;
 
     /** Map of types generated from antTypeTable */
-    private final Hashtable typeClassDefinitions = new Hashtable();
+    private final Hashtable<String, Class<?>> typeClassDefinitions = new Hashtable<String, Class<?>>();
 
     /** flag to rebuild typeClassDefinitions */
     private boolean rebuildTypeClassDefinitions = true;
 
     /** Set of namespaces that have been checked for antlibs */
-    private final HashSet checkedNamespaces = new HashSet();
+    private final HashSet<String> checkedNamespaces = new HashSet<String>();
 
     /**
      * Stack of antlib contexts used to resolve definitions while
      *   processing antlib
      */
-    private Stack antLibStack = new Stack();
+    private Stack<String> antLibStack = new Stack<String>();
 
     /** current antlib uri */
     private String antLibCurrentUri = null;
@@ -189,38 +189,37 @@ public class ComponentHelper  {
      */
     public void setProject(Project project) {
         this.project = project;
-        antTypeTable = new AntTypeTable(project);
+//        antTypeTable = new Hashtable<String, AntTypeDefinition>(project);
     }
 
     /**
      * @return A copy of the CheckedNamespace.
      */
-    private synchronized Set getCheckedNamespace() {
-        return (Set) checkedNamespaces.clone();
+    private synchronized Set<String> getCheckedNamespace() {
+        @SuppressWarnings("unchecked")
+        final Set<String> result = (Set<String>) checkedNamespaces.clone();
+        return result;
     }
 
     /**
      * @return A deep copy of the restrictredDefinition
      */
-    private Map getRestrictedDefinition() {
-        Map result = new HashMap();
+    private Map<String, List<AntTypeDefinition>> getRestrictedDefinition() {
+        final Map<String, List<AntTypeDefinition>> result = new HashMap<String, List<AntTypeDefinition>>();
         synchronized (restrictedDefinitions) {
-            for(Iterator i = restrictedDefinitions.entrySet().iterator();
-                         i.hasNext();) {
-                Map.Entry entry = (Map.Entry) i.next();
-                List entryVal = (List) entry.getValue();
+            for (Map.Entry<String, List<AntTypeDefinition>> entry : restrictedDefinitions.entrySet()) {
+                List<AntTypeDefinition> entryVal = entry.getValue();
                 synchronized (entryVal) {
                     //copy the entryVal
-                    entryVal = new ArrayList(entryVal);
+                    entryVal = new ArrayList<AntTypeDefinition> (entryVal);
                 }
-                Object entryKey = entry.getKey();                                    
-                result.put(entryKey, entryVal);
+                result.put(entry.getKey(), entryVal);
             }
         }
         return result;
     }
 
-    
+
     /**
      * Used with creating child projects. Each child
      * project inherits the component definitions
@@ -229,19 +228,19 @@ public class ComponentHelper  {
      */
     public void initSubProject(ComponentHelper helper) {
         // add the types of the parent project
-        AntTypeTable typeTable = (AntTypeTable) helper.antTypeTable.clone();
-        synchronized (antTypeTable) { 
-            for (Iterator i = typeTable.values().iterator(); i.hasNext();) {
-                AntTypeDefinition def = (AntTypeDefinition) i.next();
+        @SuppressWarnings("unchecked")
+        final Hashtable<String, AntTypeDefinition> typeTable = (Hashtable<String, AntTypeDefinition>) helper.antTypeTable.clone();
+        synchronized (antTypeTable) {
+            for (AntTypeDefinition def : typeTable.values()) {
                 antTypeTable.put(def.getName(), def);
             }
         }
         // add the parsed namespaces of the parent project
-        Set inheritedCheckedNamespace = helper.getCheckedNamespace();
+        Set<String> inheritedCheckedNamespace = helper.getCheckedNamespace();
         synchronized (this) {
             checkedNamespaces.addAll(inheritedCheckedNamespace);
         }
-        Map inheritedRestrictedDef = helper.getRestrictedDefinition();
+        Map<String, List<AntTypeDefinition>> inheritedRestrictedDef = helper.getRestrictedDefinition();
         synchronized (restrictedDefinitions) {
             restrictedDefinitions.putAll(inheritedRestrictedDef);
         }
@@ -294,7 +293,7 @@ public class ComponentHelper  {
      *                      name is prefixed with the namespace uri and ":".
      * @return the class if found or null if not.
      */
-    public Class getComponentClass(String componentName) {
+    public Class<?> getComponentClass(String componentName) {
         AntTypeDefinition def = getDefinition(componentName);
         return def == null ? null : def.getExposedClass(project);
     }
@@ -306,7 +305,7 @@ public class ComponentHelper  {
      */
     public AntTypeDefinition getDefinition(String componentName) {
         checkNamespace(componentName);
-        return antTypeTable.getDefinition(componentName);
+        return antTypeTable.get(componentName);
     }
 
     /**
@@ -337,7 +336,7 @@ public class ComponentHelper  {
      *
      * @see #checkTaskClass(Class)
      */
-    public void addTaskDefinition(String taskName, Class taskClass) {
+    public void addTaskDefinition(String taskName, Class<?> taskClass) {
         checkTaskClass(taskClass);
         AntTypeDefinition def = new AntTypeDefinition();
         def.setName(taskName);
@@ -361,7 +360,7 @@ public class ComponentHelper  {
      *                           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 {
         if (!Modifier.isPublic(taskClass.getModifiers())) {
             final String message = taskClass + " is not public";
             project.log(message, Project.MSG_ERR);
@@ -388,25 +387,24 @@ public class ComponentHelper  {
 
     /**
      * Returns the current task definition hashtable. The returned hashtable is
-     * "live" and so should not be modified.  Also, the returned table may be 
+     * "live" and so should not be modified.  Also, the returned table may be
      * modified asynchronously.
      *
      * @return a map of from task name to implementing class
      *         (String to Class).
      */
-    public Hashtable getTaskDefinitions() {
+    public Hashtable<String, Class<?>> getTaskDefinitions() {
         synchronized (taskClassDefinitions) {
             synchronized (antTypeTable) {
                 if (rebuildTaskClassDefinitions) {
                     taskClassDefinitions.clear();
-                    for (Iterator i = antTypeTable.keySet().iterator(); i.hasNext();) {
-                        String name = (String) i.next();
-                        Class clazz = antTypeTable.getExposedClass(name);
+                    for (Map.Entry<String, AntTypeDefinition> e : antTypeTable.entrySet()) {
+                        final Class<?> clazz = e.getValue().getExposedClass(project);
                         if (clazz == null) {
                             continue;
                         }
                         if (Task.class.isAssignableFrom(clazz)) {
-                            taskClassDefinitions.put(name, antTypeTable.getTypeClass(name));
+                            taskClassDefinitions.put(e.getKey(), e.getValue().getTypeClass(project));
                         }
                     }
                     rebuildTaskClassDefinitions = false;
@@ -423,19 +421,18 @@ public class ComponentHelper  {
      * @return a map of from type name to implementing class
      *         (String to Class).
      */
-    public Hashtable getDataTypeDefinitions() {
+    public Hashtable<String, Class<?>> getDataTypeDefinitions() {
         synchronized (typeClassDefinitions) {
             synchronized (antTypeTable) {
                 if (rebuildTypeClassDefinitions) {
                     typeClassDefinitions.clear();
-                    for (Iterator i = antTypeTable.keySet().iterator(); i.hasNext();) {
-                        String name = (String) i.next();
-                        Class clazz = antTypeTable.getExposedClass(name);
+                    for (Map.Entry<String, AntTypeDefinition> e : antTypeTable.entrySet()) {
+                        final Class<?> clazz = e.getValue().getExposedClass(project);
                         if (clazz == null) {
                             continue;
                         }
-                        if (!(Task.class.isAssignableFrom(clazz))) {
-                            typeClassDefinitions.put(name, antTypeTable.getTypeClass(name));
+                        if (!Task.class.isAssignableFrom(clazz)) {
+                            typeClassDefinitions.put(e.getKey(), e.getValue().getTypeClass(project));
                         }
                     }
                     rebuildTypeClassDefinitions = false;
@@ -447,16 +444,16 @@ public class ComponentHelper  {
 
     /**
      * This returns a list of restricted definitions for a name.
-     * The returned List is "live" and so should not be modified.  
-     * Also, the returned list may be modified asynchronously.  
+     * The returned List is "live" and so should not be modified.
+     * Also, the returned list may be modified asynchronously.
      * Any access must be guarded with a lock on the list itself.
-     * 
+     *
      * @param componentName the name to use.
      * @return the list of restricted definitions for a particular name.
      */
-    public List getRestrictedDefinitions(String componentName) {
+    public List<AntTypeDefinition> getRestrictedDefinitions(String componentName) {
         synchronized (restrictedDefinitions) {
-            return (List) restrictedDefinitions.get(componentName);
+            return restrictedDefinitions.get(componentName);
         }
     }
 
@@ -473,8 +470,8 @@ public class ComponentHelper  {
      * @param typeClass The full name of the class implementing the datatype.
      *                  Must not be <code>null</code>.
      */
-    public void addDataTypeDefinition(String typeName, Class typeClass) {
-        AntTypeDefinition def = new AntTypeDefinition();
+    public void addDataTypeDefinition(String typeName, Class<?> typeClass) {
+        final AntTypeDefinition def = new AntTypeDefinition();
         def.setName(typeName);
         def.setClass(typeClass);
         updateDataTypeDefinition(def);
@@ -499,10 +496,10 @@ public class ComponentHelper  {
      * Returns the current datatype definition hashtable. The returned
      * hashtable is "live" and so should not be modified.
      *
-     * @return a map of from datatype name to implementing class
-     *         (String to Class).
+     * @return a map of from datatype name to datatype definition
+     *         (String to {@link AntTypeDefinition}).
      */
-    public Hashtable getAntTypeTable() {
+    public Hashtable<String, AntTypeDefinition> getAntTypeTable() {
         return antTypeTable;
     }
 
@@ -544,7 +541,7 @@ public class ComponentHelper  {
      *                           creation fails.
      */
     private Task createNewTask(String taskType) throws BuildException {
-        Class c = getComponentClass(taskType);
+        Class<?> c = getComponentClass(taskType);
         if (c == null || !(Task.class.isAssignableFrom(c))) {
             return null;
         }
@@ -614,11 +611,10 @@ public class ComponentHelper  {
         //  PR: I do not know what to do if the object class
         //      has multiple defines
         //      but this is for logging only...
-        Class elementClass = o.getClass();
+        Class<?> elementClass = o.getClass();
         String elementClassname = elementClass.getName();
         synchronized (antTypeTable) {
-            for (Iterator i = antTypeTable.values().iterator(); i.hasNext();) {
-                AntTypeDefinition def = (AntTypeDefinition) i.next();
+            for (AntTypeDefinition def : antTypeTable.values()) {
                 if (elementClassname.equals(def.getClassName())
                         && (elementClass == def.getExposedClass(project))) {
                     String name = def.getName();
@@ -647,7 +643,7 @@ public class ComponentHelper  {
                 .getElementName(o, brief);
     }
 
-    private static String getUnmappedElementName(Class c, boolean brief) {
+    private static String getUnmappedElementName(Class<?> c, boolean brief) {
         if (brief) {
             String name = c.getName();
             return name.substring(name.lastIndexOf('.') + 1);
@@ -684,19 +680,19 @@ public class ComponentHelper  {
       */
     private void updateRestrictedDefinition(AntTypeDefinition def) {
         String name = def.getName();
-        List list = null;
+        List<AntTypeDefinition> list = null;
         synchronized (restrictedDefinitions) {
-            list = (List) restrictedDefinitions.get(name);
+            list = restrictedDefinitions.get(name);
             if (list == null) {
-                list = new ArrayList();
+                list = new ArrayList<AntTypeDefinition>();
                 restrictedDefinitions.put(name, list);
             }
         }
         // Check if the classname is already present and remove it
         // if it is
         synchronized (list) {
-            for (Iterator i = list.iterator(); i.hasNext();) {
-                AntTypeDefinition current = (AntTypeDefinition) i.next();
+            for (Iterator<AntTypeDefinition> i = list.iterator(); i.hasNext();) {
+                AntTypeDefinition current = i.next();
                 if (current.getClassName().equals(def.getClassName())) {
                     i.remove();
                     break;
@@ -716,12 +712,12 @@ public class ComponentHelper  {
         synchronized (antTypeTable) {
             rebuildTaskClassDefinitions = true;
             rebuildTypeClassDefinitions = true;
-            AntTypeDefinition old = antTypeTable.getDefinition(name);
+            final AntTypeDefinition old = antTypeTable.get(name);
             if (old != null) {
                 if (sameDefinition(def, old)) {
                     return;
                 }
-                Class oldClass = antTypeTable.getExposedClass(name);
+                Class<?> oldClass = old.getExposedClass(project);
                 boolean isTask = oldClass != null && Task.class.isAssignableFrom(oldClass);
                 project.log("Trying to override old definition of "
                         + (isTask ? "task " : "datatype ") + name, (def.similarDefinition(old,
@@ -762,7 +758,7 @@ public class ComponentHelper  {
     private void initTasks() {
         ClassLoader classLoader = getClassLoader(null);
         Properties props = getDefaultDefinitions(false);
-        Enumeration e = props.propertyNames();
+        Enumeration<?> e = props.propertyNames();
         while (e.hasMoreElements()) {
             String name = (String) e.nextElement();
             String className = props.getProperty(name);
@@ -825,7 +821,7 @@ public class ComponentHelper  {
     private void initTypes() {
         ClassLoader classLoader = getClassLoader(null);
         Properties props = getDefaultDefinitions(true);
-        Enumeration e = props.propertyNames();
+        Enumeration<?> e = props.propertyNames();
         while (e.hasMoreElements()) {
             String name = (String) e.nextElement();
             String className = props.getProperty(name);
@@ -936,7 +932,7 @@ public class ComponentHelper  {
             optional |= classname.startsWith("org.apache.tools.ant.types.optional");
 
             //start with instantiating the class.
-            Class clazz = null;
+            Class<?> clazz = null;
             try {
                 clazz = def.innerGetTypeClass();
             } catch (ClassNotFoundException e) {
@@ -1028,12 +1024,11 @@ public class ComponentHelper  {
         out.println("Action: Check that any <presetdef>/<macrodef>"
                 + " declarations have taken place.");
         if (uri.length() > 0) {
-            List matches = antTypeTable.findMatches(uri);
+            final List<AntTypeDefinition> matches = findTypeMatches(uri);
             if (matches.size() > 0) {
                 out.println();
                 out.println("The definitions in the namespace " + uri + " are:");
-                for (Iterator it = matches.iterator(); it.hasNext();) {
-                    AntTypeDefinition def = (AntTypeDefinition) it.next();
+                for (AntTypeDefinition def : matches) {
                     String local = ProjectHelper.extractNameFromComponentName(def.getName());
                     out.println("    " + local);
                 }
@@ -1086,63 +1081,20 @@ public class ComponentHelper  {
     }
 
     /**
-     * Map that contains the component definitions.
+     * Create a list of all definitions that match a prefix, usually the URI
+     * of a library
+     * @param prefix prefix to match off
+     * @return the (possibly empty) list of definitions
      */
-    private static class AntTypeTable extends Hashtable {
-        private static final long serialVersionUID = -3060442320477772028L;
-        private Project project;
-
-        AntTypeTable(Project project) {
-            this.project = project;
-        }
-
-        AntTypeDefinition getDefinition(String key) {
-            return (AntTypeDefinition) (super.get(key));
-        }
-
-        public Object get(Object key) {
-            return getTypeClass((String) key);
-        }
-
-        Class getTypeClass(String name) {
-            AntTypeDefinition def = getDefinition(name);
-            return (def == null) ? null : def.getTypeClass(project);
-        }
-
-        Class getExposedClass(String name) {
-            AntTypeDefinition def = getDefinition(name);
-            return def == null ? null : def.getExposedClass(project);
-        }
-
-        public synchronized boolean contains(Object clazz) {
-            boolean found = false;
-            if (clazz instanceof Class) {
-                for (Iterator i = values().iterator(); i.hasNext() && !found;) {
-                    found = (((AntTypeDefinition) (i.next())).getExposedClass(project) == clazz);
-                }
-            }
-            return found;
-        }
-
-        public boolean containsValue(Object value) {
-            return contains(value);
-        }
-
-        /**
-         * Create a list of all definitions that match a prefix, usually the URI
-         * of a library
-         * @param prefix prefix to match off
-         * @return the (possibly empty) list of definitions
-         */
-        public synchronized List/*<AntTypeDefinition>*/ findMatches(String prefix) {
-            ArrayList matches = new ArrayList();
-            for (Iterator i = values().iterator(); i.hasNext();) {
-                AntTypeDefinition def = (AntTypeDefinition) (i.next());
+    private List<AntTypeDefinition> findTypeMatches(String prefix) {
+        final List<AntTypeDefinition> result = new ArrayList<AntTypeDefinition>();
+        synchronized (antTypeTable) {
+            for (AntTypeDefinition def : antTypeTable.values()) {
                 if (def.getName().startsWith(prefix)) {
-                    matches.add(def);
+                    result.add(def);
                 }
             }
-            return matches;
         }
+        return result;
     }
 }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/DemuxOutputStream.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/DemuxOutputStream.java?rev=1375137&r1=1375136&r2=1375137&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/DemuxOutputStream.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/DemuxOutputStream.java Mon Aug 20 17:49:13 2012
@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.io.OutputStream;
 import java.util.WeakHashMap;
 
+
 /**
  * Logs content written by a thread and forwards the buffers onto the
  * project object which will forward the content to the appropriate
@@ -62,7 +63,7 @@ public class DemuxOutputStream extends O
     private static final int LF = 0x0a;
 
     /** Mapping from thread to buffer (Thread to BufferInfo). */
-    private WeakHashMap buffers = new WeakHashMap();
+    private WeakHashMap<Thread, BufferInfo> buffers = new WeakHashMap<Thread, BufferInfo>();
 
     /**
      * The project to send output to.

Modified: ant/core/trunk/src/main/org/apache/tools/ant/Diagnostics.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/Diagnostics.java?rev=1375137&r1=1375136&r2=1375137&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/Diagnostics.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/Diagnostics.java Mon Aug 20 17:49:13 2012
@@ -145,7 +145,7 @@ public final class Diagnostics {
      * @return null if there is no package or implementation version.
      * '?.?' for JDK 1.0 or 1.1.
      */
-    private static String getImplementationVersion(Class clazz) {
+    private static String getImplementationVersion(Class<?> clazz) {
         return clazz.getPackage().getImplementationVersion();
     }
 
@@ -154,7 +154,7 @@ public final class Diagnostics {
      * @param clazz the class to get the information from.
      * @since Ant 1.8.0
      */
-    private static URL getClassLocation(Class clazz) {
+    private static URL getClassLocation(Class<?> clazz) {
         if (clazz.getProtectionDomain().getCodeSource() == null) {
             return null;
         }
@@ -364,7 +364,7 @@ public final class Diagnostics {
             out.println("Access to System.getProperties() blocked " + "by a security manager");
             return;
         }
-        for (Enumeration keys = sysprops.propertyNames();
+        for (Enumeration<?> keys = sysprops.propertyNames();
             keys.hasMoreElements();) {
             String key = (String) keys.nextElement();
             String value = getProperty(key);
@@ -455,7 +455,7 @@ public final class Diagnostics {
     private static void doReportWhich(PrintStream out) {
         Throwable error = null;
         try {
-            Class which = Class.forName("org.apache.env.Which");
+            Class<?> which = Class.forName("org.apache.env.Which");
             Method method = which.getMethod(
                 "main", new Class[] {String[].class});
             method.invoke(null, new Object[]{new String[]{}});
@@ -491,7 +491,7 @@ public final class Diagnostics {
             Properties props = new Properties();
             try {
                 props.load(is);
-                for (Enumeration keys = props.keys(); keys.hasMoreElements();) {
+                for (Enumeration<?> keys = props.keys(); keys.hasMoreElements();) {
                     String key = (String) keys.nextElement();
                     String classname = props.getProperty(key);
                     try {
@@ -696,7 +696,7 @@ public final class Diagnostics {
         printProperty(out, ProxySetup.USE_SYSTEM_PROXIES);
         final String proxyDiagClassname = "org.apache.tools.ant.util.java15.ProxyDiagnostics";
         try {
-            Class proxyDiagClass = Class.forName(proxyDiagClassname);
+            Class<?> proxyDiagClass = Class.forName(proxyDiagClassname);
             Object instance = proxyDiagClass.newInstance();
             out.println("Java1.5+ proxy settings:");
             out.println(instance.toString());

Modified: ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java?rev=1375137&r1=1375136&r2=1375137&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java Mon Aug 20 17:49:13 2012
@@ -216,7 +216,7 @@ public class DirectoryScanner
      *
      * @see #addDefaultExcludes()
      */
-    private static final Set defaultExcludes = new HashSet();
+    private static final Set<String> defaultExcludes = new HashSet<String>();
     static {
         resetDefaultExcludes();
     }
@@ -239,43 +239,43 @@ public class DirectoryScanner
      * The files which matched at least one include and no excludes
      * and were selected.
      */
-    protected Vector filesIncluded;
+    protected Vector<String> filesIncluded;
 
     /** The files which did not match any includes or selectors. */
-    protected Vector filesNotIncluded;
+    protected Vector<String> filesNotIncluded;
 
     /**
      * The files which matched at least one include and at least
      * one exclude.
      */
-    protected Vector filesExcluded;
+    protected Vector<String> filesExcluded;
 
     /**
      * The directories which matched at least one include and no excludes
      * and were selected.
      */
-    protected Vector dirsIncluded;
+    protected Vector<String> dirsIncluded;
 
     /** The directories which were found and did not match any includes. */
-    protected Vector dirsNotIncluded;
+    protected Vector<String> dirsNotIncluded;
 
     /**
      * The directories which matched at least one include and at least one
      * exclude.
      */
-    protected Vector dirsExcluded;
+    protected Vector<String> dirsExcluded;
 
     /**
      * The files which matched at least one include and no excludes and
      * which a selector discarded.
      */
-    protected Vector filesDeselected;
+    protected Vector<String> filesDeselected;
 
     /**
      * The directories which matched at least one include and no excludes
      * but which a selector discarded.
      */
-    protected Vector dirsDeselected;
+    protected Vector<String> dirsDeselected;
 
     /** Whether or not our results were built by a slow scan. */
     protected boolean haveSlowResults = false;
@@ -309,7 +309,7 @@ public class DirectoryScanner
      *
      * @since Ant 1.6
      */
-    private Set scannedDirs = new HashSet();
+    private Set<String> scannedDirs = new HashSet<String>();
 
     /**
      * Map of all include patterns that are full file names and don't
@@ -326,7 +326,7 @@ public class DirectoryScanner
      *
      * @since Ant 1.8.0
      */
-    private Map includeNonPatterns = new HashMap();
+    private Map<String, TokenizedPath> includeNonPatterns = new HashMap<String, TokenizedPath>();
 
     /**
      * Map of all exclude patterns that are full file names and don't
@@ -343,7 +343,7 @@ public class DirectoryScanner
      *
      * @since Ant 1.8.0
      */
-    private Map excludeNonPatterns = new HashMap();
+    private Map<String, TokenizedPath> excludeNonPatterns = new HashMap<String, TokenizedPath>();
 
     /**
      * Array of all include patterns that contain wildcards.
@@ -422,7 +422,7 @@ public class DirectoryScanner
      *
      * @since Ant 1.8.0
      */
-    private Set/*<String>*/ notFollowedSymlinks = new HashSet();
+    private Set<String> notFollowedSymlinks = new HashSet<String>();
 
     /**
      * Sole constructor.
@@ -929,7 +929,7 @@ public class DirectoryScanner
      */
     private void checkIncludePatterns() {
         ensureNonPatternSetsReady();
-        Map newroots = new HashMap();
+        Map<TokenizedPath, String> newroots = new HashMap<TokenizedPath, String>();
 
         // put in the newroots map the include patterns without
         // wildcard tokens
@@ -940,12 +940,10 @@ public class DirectoryScanner
                              pattern);
             }
         }
-        for (Iterator iter = includeNonPatterns.entrySet().iterator();
-             iter.hasNext(); ) {
-            Map.Entry entry = (Map.Entry) iter.next();
-            String pattern = (String) entry.getKey();
+        for (Map.Entry<String, TokenizedPath> entry : includeNonPatterns.entrySet()) {
+            String pattern = entry.getKey();
             if (!shouldSkipPattern(pattern)) {
-                newroots.put((TokenizedPath) entry.getValue(), pattern);
+                newroots.put(entry.getValue(), pattern);
             }
         }
 
@@ -954,10 +952,6 @@ public class DirectoryScanner
             // we are going to scan everything anyway
             scandir(basedir, "", true);
         } else {
-            // only scan directories that can include matched files or
-            // directories
-            Iterator it = newroots.entrySet().iterator();
-
             File canonBase = null;
             if (basedir != null) {
                 try {
@@ -966,9 +960,10 @@ public class DirectoryScanner
                     throw new BuildException(ex);
                 }
             }
-            while (it.hasNext()) {
-                Map.Entry entry = (Map.Entry) it.next();
-                TokenizedPath currentPath = (TokenizedPath) entry.getKey();
+            // only scan directories that can include matched files or
+            // directories
+            for (Map.Entry<TokenizedPath, String> entry : newroots.entrySet()) {
+                TokenizedPath currentPath = entry.getKey();
                 String currentelement = currentPath.toString();
                 if (basedir == null
                     && !FileUtils.isAbsolutePath(currentelement)) {
@@ -1069,14 +1064,14 @@ public class DirectoryScanner
      * Clear the result caches for a scan.
      */
     protected synchronized void clearResults() {
-        filesIncluded    = new VectorSet();
-        filesNotIncluded = new VectorSet();
-        filesExcluded    = new VectorSet();
-        filesDeselected  = new VectorSet();
-        dirsIncluded     = new VectorSet();
-        dirsNotIncluded  = new VectorSet();
-        dirsExcluded     = new VectorSet();
-        dirsDeselected   = new VectorSet();
+        filesIncluded    = new VectorSet<String>();
+        filesNotIncluded = new VectorSet<String>();
+        filesExcluded    = new VectorSet<String>();
+        filesDeselected  = new VectorSet<String>();
+        dirsIncluded     = new VectorSet<String>();
+        dirsNotIncluded  = new VectorSet<String>();
+        dirsExcluded     = new VectorSet<String>();
+        dirsDeselected   = new VectorSet<String>();
         everythingIncluded = (basedir != null);
         scannedDirs.clear();
         notFollowedSymlinks.clear();
@@ -1208,11 +1203,11 @@ public class DirectoryScanner
                                          + dir.getAbsolutePath() + "'");
             }
         }
-        scandir(dir, path, fast, newfiles, new LinkedList());
+        scandir(dir, path, fast, newfiles, new LinkedList<String>());
     }
 
     private void scandir(File dir, TokenizedPath path, boolean fast,
-                         String[] newfiles, LinkedList directoryNamesFollowed) {
+                         String[] newfiles, LinkedList<String> directoryNamesFollowed) {
         String vpath = path.toString();
         if (vpath.length() > 0 && !vpath.endsWith(File.separator)) {
             vpath += File.separator;
@@ -1223,7 +1218,7 @@ public class DirectoryScanner
             return;
         }
         if (!followSymlinks) {
-            ArrayList noLinks = new ArrayList();
+            ArrayList<String> noLinks = new ArrayList<String>();
             for (int i = 0; i < newfiles.length; i++) {
                 try {
                     if (SYMLINK_UTILS.isSymbolicLink(dir, newfiles[i])) {
@@ -1327,7 +1322,7 @@ public class DirectoryScanner
     private void accountForIncludedDir(TokenizedPath name,
                                        File file, boolean fast,
                                        String[] children,
-                                       LinkedList directoryNamesFollowed) {
+                                       LinkedList<String> directoryNamesFollowed) {
         processIncluded(name, file, dirsIncluded, dirsExcluded, dirsDeselected);
         if (fast && couldHoldIncluded(name) && !contentsExcluded(name)) {
             scandir(file, name, fast, children, directoryNamesFollowed);
@@ -1335,8 +1330,8 @@ public class DirectoryScanner
     }
 
     private void processIncluded(TokenizedPath path,
-                                 File file, Vector inc, Vector exc,
-                                 Vector des) {
+                                 File file, Vector<String> inc, Vector<String> exc,
+                                 Vector<String> des) {
         String name = path.toString();
         if (inc.contains(name) || exc.contains(name) || des.contains(name)) {
             return;
@@ -1416,10 +1411,10 @@ public class DirectoryScanner
                 return true;
             }
         }
-        for (Iterator iter = includeNonPatterns.values().iterator();
+        for (Iterator<TokenizedPath> iter = includeNonPatterns.values().iterator();
              iter.hasNext(); ) {
             if (couldHoldIncluded(tokenizedName,
-                                  ((TokenizedPath) iter.next()).toPattern())) {
+                                  iter.next().toPattern())) {
                 return true;
             }
         }
@@ -1788,7 +1783,7 @@ public class DirectoryScanner
      * Set is live and should not be modified.
      * @return the Set of relative directory names that have been scanned.
      */
-    /* package-private */ Set getScannedDirs() {
+    /* package-private */ Set<String> getScannedDirs() {
         return scannedDirs;
     }
 
@@ -1827,8 +1822,8 @@ public class DirectoryScanner
      * @param patterns String[] of patterns.
      * @since Ant 1.8.0
      */
-    private TokenizedPattern[] fillNonPatternSet(Map map, String[] patterns) {
-        ArrayList al = new ArrayList(patterns.length);
+    private TokenizedPattern[] fillNonPatternSet(Map<String, TokenizedPath> map, String[] patterns) {
+        ArrayList<TokenizedPattern> al = new ArrayList<TokenizedPattern>(patterns.length);
         for (int i = 0; i < patterns.length; i++) {
             if (!SelectorUtils.hasWildcards(patterns[i])) {
                 String s = isCaseSensitive()
@@ -1853,23 +1848,21 @@ public class DirectoryScanner
      * @since Ant 1.8.0
      */
     private boolean causesIllegalSymlinkLoop(String dirName, File parent,
-                                             LinkedList directoryNamesFollowed) {
+                                             LinkedList<String> directoryNamesFollowed) {
         try {
             if (directoryNamesFollowed.size() >= maxLevelsOfSymlinks
                 && CollectionUtils.frequency(directoryNamesFollowed, dirName)
                    >= maxLevelsOfSymlinks
                 && SYMLINK_UTILS.isSymbolicLink(parent, dirName)) {
 
-                ArrayList files = new ArrayList();
+                ArrayList<String> files = new ArrayList<String>();
                 File f = FILE_UTILS.resolveFile(parent, dirName);
                 String target = f.getCanonicalPath();
                 files.add(target);
 
                 String relPath = "";
-                for (Iterator i = directoryNamesFollowed.iterator();
-                     i.hasNext(); ) {
+                for (String dir : directoryNamesFollowed) {
                     relPath += "../";
-                    String dir = (String) i.next();
                     if (dirName.equals(dir)) {
                         f = FILE_UTILS.resolveFile(parent, relPath + dir);
                         files.add(f.getCanonicalPath());

Modified: ant/core/trunk/src/main/org/apache/tools/ant/IntrospectionHelper.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/IntrospectionHelper.java?rev=1375137&r1=1375136&r2=1375137&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/IntrospectionHelper.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/IntrospectionHelper.java Mon Aug 20 17:49:13 2012
@@ -28,6 +28,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+
 import org.apache.tools.ant.types.EnumeratedAttribute;
 import org.apache.tools.ant.types.Resource;
 import org.apache.tools.ant.types.resources.FileProvider;
@@ -62,7 +63,7 @@ public final class IntrospectionHelper {
     /**
      * Helper instances we've already created (Class.getName() to IntrospectionHelper).
      */
-    private static final Map HELPERS = new Hashtable();
+    private static final Map<String, IntrospectionHelper> HELPERS = new Hashtable<String, IntrospectionHelper>();
 
     /**
      * Map from primitive types to wrapper classes for use in
@@ -70,13 +71,13 @@ public final class IntrospectionHelper {
      * and boolean are in here even though they get special treatment
      * - this way we only need to test for the wrapper class.
      */
-    private static final Map PRIMITIVE_TYPE_MAP = new HashMap(8);
+    private static final Map<Class<?>, Class<?>> PRIMITIVE_TYPE_MAP = new HashMap<Class<?>, Class<?>>(8);
 
     // Set up PRIMITIVE_TYPE_MAP
     static {
-        Class[] primitives = {Boolean.TYPE, Byte.TYPE, Character.TYPE, Short.TYPE,
+        Class<?>[] primitives = {Boolean.TYPE, Byte.TYPE, Character.TYPE, Short.TYPE,
                               Integer.TYPE, Long.TYPE, Float.TYPE, Double.TYPE};
-        Class[] wrappers = {Boolean.class, Byte.class, Character.class, Short.class,
+        Class<?>[] wrappers = {Boolean.class, Byte.class, Character.class, Short.class,
                             Integer.class, Long.class, Float.class, Double.class};
         for (int i = 0; i < primitives.length; i++) {
             PRIMITIVE_TYPE_MAP.put (primitives[i], wrappers[i]);
@@ -90,30 +91,30 @@ public final class IntrospectionHelper {
      * Map from attribute names to attribute types
      * (String to Class).
      */
-    private final Hashtable attributeTypes = new Hashtable();
+    private final Hashtable<String, Class<?>> attributeTypes = new Hashtable<String, Class<?>>();
 
     /**
      * Map from attribute names to attribute setter methods
      * (String to AttributeSetter).
      */
-    private final Hashtable attributeSetters = new Hashtable();
+    private final Hashtable<String, AttributeSetter> attributeSetters = new Hashtable<String, AttributeSetter>();
 
     /**
      * Map from attribute names to nested types
      * (String to Class).
      */
-    private final Hashtable nestedTypes = new Hashtable();
+    private final Hashtable<String, Class<?>> nestedTypes = new Hashtable<String, Class<?>>();
 
     /**
      * Map from attribute names to methods to create nested types
      * (String to NestedCreator).
      */
-    private final Hashtable nestedCreators = new Hashtable();
+    private final Hashtable<String, NestedCreator> nestedCreators = new Hashtable<String, NestedCreator>();
 
     /**
      * Vector of methods matching add[Configured](Class) pattern.
      */
-    private final List addTypeMethods = new ArrayList();
+    private final List<Method> addTypeMethods = new ArrayList<Method>();
 
     /**
      * The method to invoke to add PCDATA.
@@ -123,7 +124,7 @@ public final class IntrospectionHelper {
     /**
      * The class introspected by this instance.
      */
-    private final Class bean;
+    private final Class<?> bean;
 
     /**
      * Sole constructor, which is private to ensure that all
@@ -175,15 +176,15 @@ public final class IntrospectionHelper {
      *
      * @see #getHelper(Class)
      */
-    private IntrospectionHelper(final Class bean) {
+    private IntrospectionHelper(final Class<?> bean) {
         this.bean = bean;
         Method[] methods = bean.getMethods();
         Method addTextMethod = null;
         for (int i = 0; i < methods.length; i++) {
             final Method m = methods[i];
             final String name = m.getName();
-            Class returnType = m.getReturnType();
-            Class[] args = m.getParameterTypes();
+            Class<?> returnType = m.getReturnType();
+            Class<?>[] args = m.getParameterTypes();
 
             // check of add[Configured](Class) pattern
             if (args.length == 1 && java.lang.Void.TYPE.equals(returnType)
@@ -254,11 +255,11 @@ public final class IntrospectionHelper {
                     && !java.lang.String.class.equals(args[0])
                     && !args[0].isArray() && !args[0].isPrimitive()) {
                 try {
-                    Constructor constructor = null;
+                    Constructor<?> constructor = null;
                     try {
-                        constructor = args[0].getConstructor(new Class[] {});
+                        constructor = args[0].getConstructor();
                     } catch (NoSuchMethodException ex) {
-                        constructor = args[0].getConstructor(new Class[] {Project.class});
+                        constructor = args[0].getConstructor(Project.class);
                     }
                     String propName = getPropertyName(name, "addConfigured");
                     nestedTypes.put(propName, args[0]);
@@ -272,11 +273,11 @@ public final class IntrospectionHelper {
                     && !java.lang.String.class.equals(args[0])
                     && !args[0].isArray() && !args[0].isPrimitive()) {
                 try {
-                    Constructor constructor = null;
+                    Constructor<?> constructor = null;
                     try {
-                        constructor = args[0].getConstructor(new Class[] {});
+                        constructor = args[0].getConstructor();
                     } catch (NoSuchMethodException ex) {
-                        constructor = args[0].getConstructor(new Class[] {Project.class});
+                        constructor = args[0].getConstructor(Project.class);
                     }
                     String propName = getPropertyName(name, "add");
                     if (nestedTypes.get(propName) != null) {
@@ -306,7 +307,7 @@ public final class IntrospectionHelper {
      * @param type the type of the set method's parameter
      * @return true if the given set method is to be hidden.
      */
-    private boolean isHiddenSetMethod(String name, Class type) {
+    private boolean isHiddenSetMethod(String name, Class<?> type) {
         if ("setLocation".equals(name) && org.apache.tools.ant.Location.class.equals(type)) {
             return true;
         }
@@ -325,7 +326,7 @@ public final class IntrospectionHelper {
      *
      * @return a helper for the specified class
      */
-    public static synchronized IntrospectionHelper getHelper(Class c) {
+    public static synchronized IntrospectionHelper getHelper(Class<?> c) {
         return getHelper(null, c);
     }
 
@@ -342,8 +343,8 @@ public final class IntrospectionHelper {
      *
      * @return a helper for the specified class
      */
-    public static IntrospectionHelper getHelper(Project p, Class c) {
-        IntrospectionHelper ih = (IntrospectionHelper) HELPERS.get(c.getName());
+    public static IntrospectionHelper getHelper(Project p, Class<?> c) {
+        IntrospectionHelper ih = HELPERS.get(c.getName());
         // If a helper cannot be found, or if the helper is for another
         // classloader, create a new IH
         if (ih == null || ih.bean != c) {
@@ -392,7 +393,7 @@ public final class IntrospectionHelper {
             if (element instanceof DynamicObjectAttribute) {
                 DynamicObjectAttribute dc = (DynamicObjectAttribute) element;
                 dc.setDynamicAttribute(attributeName.toLowerCase(Locale.ENGLISH), value);
-                return;                
+                return;
             }
             if (element instanceof DynamicAttribute) {
                 DynamicAttribute dc = (DynamicAttribute) element;
@@ -830,8 +831,8 @@ public final class IntrospectionHelper {
      * @exception BuildException if the introspected class does not
      *                           support the named nested element.
      */
-    public Class getElementType(String elementName) throws BuildException {
-        Class nt = (Class) nestedTypes.get(elementName);
+    public Class<?> getElementType(String elementName) throws BuildException {
+        Class<?> nt = nestedTypes.get(elementName);
         if (nt == null) {
             throw new UnsupportedElementException("Class "
                     + bean.getName() + " doesn't support the nested \""
@@ -852,8 +853,8 @@ public final class IntrospectionHelper {
      * @exception BuildException if the introspected class does not
      *                           support the named attribute.
      */
-    public Class getAttributeType(String attributeName) throws BuildException {
-        Class at = (Class) attributeTypes.get(attributeName);
+    public Class<?> getAttributeType(String attributeName) throws BuildException {
+        Class<?> at = attributeTypes.get(attributeName);
         if (at == null) {
             throw new UnsupportedAttributeException("Class "
                     + bean.getName() + " doesn't support the \""
@@ -938,7 +939,7 @@ public final class IntrospectionHelper {
      * @return an enumeration of the names of the attributes supported by the introspected class.
      * @see #getAttributeMap
      */
-    public Enumeration getAttributes() {
+    public Enumeration<String> getAttributes() {
         return attributeSetters.keys();
     }
 
@@ -949,9 +950,9 @@ public final class IntrospectionHelper {
      *         unmodifiable map. Can be empty, but never <code>null</code>.
      * @since Ant 1.6.3
      */
-    public Map getAttributeMap() {
+    public Map<String, Class<?>> getAttributeMap() {
         return attributeTypes.isEmpty()
-            ? Collections.EMPTY_MAP : Collections.unmodifiableMap(attributeTypes);
+            ? Collections.<String, Class<?>> emptyMap() : Collections.unmodifiableMap(attributeTypes);
     }
 
     /**
@@ -962,7 +963,7 @@ public final class IntrospectionHelper {
      *         by the introspected class.
      * @see #getNestedElementMap
      */
-    public Enumeration getNestedElements() {
+    public Enumeration<String> getNestedElements() {
         return nestedTypes.keys();
     }
 
@@ -974,9 +975,9 @@ public final class IntrospectionHelper {
      *         unmodifiable map. Can be empty, but never <code>null</code>.
      * @since Ant 1.6.3
      */
-    public Map getNestedElementMap() {
+    public Map<String, Class<?>> getNestedElementMap() {
         return nestedTypes.isEmpty()
-            ? Collections.EMPTY_MAP : Collections.unmodifiableMap(nestedTypes);
+            ? Collections.<String, Class<?>> emptyMap() : Collections.unmodifiableMap(nestedTypes);
     }
 
     /**
@@ -996,9 +997,9 @@ public final class IntrospectionHelper {
      *         always appear first. Can be empty, but never <code>null</code>.
      * @since Ant 1.6.3
      */
-    public List getExtensionPoints() {
+    public List<Method> getExtensionPoints() {
         return addTypeMethods.isEmpty()
-                ? Collections.EMPTY_LIST : Collections.unmodifiableList(addTypeMethods);
+                ? Collections.<Method> emptyList() : Collections.unmodifiableList(addTypeMethods);
     }
 
     /**
@@ -1035,12 +1036,12 @@ public final class IntrospectionHelper {
      *         if no appropriate conversion is available.
      */
     private AttributeSetter createAttributeSetter(final Method m,
-                                                  Class arg,
+                                                  Class<?> arg,
                                                   final String attrName) {
         // use wrappers for primitive classes, e.g. int and
         // Integer are treated identically
-        final Class reflectedArg = PRIMITIVE_TYPE_MAP.containsKey(arg)
-            ? (Class) PRIMITIVE_TYPE_MAP.get(arg) : arg;
+        final Class<?> reflectedArg = PRIMITIVE_TYPE_MAP.containsKey(arg)
+            ? PRIMITIVE_TYPE_MAP.get(arg) : arg;
 
         // Object.class - it gets handled differently by AttributeSetter
         if (java.lang.Object.class == reflectedArg) {
@@ -1163,15 +1164,15 @@ public final class IntrospectionHelper {
         // This is used (deliberately) for all primitives/wrappers other than
         // char, boolean, and long.
         boolean includeProject;
-        Constructor c;
+        Constructor<?> c;
         try {
             // First try with Project.
-            c = reflectedArg.getConstructor(new Class[] {Project.class, String.class});
+            c = reflectedArg.getConstructor(Project.class, String.class);
             includeProject = true;
         } catch (NoSuchMethodException nme) {
             // OK, try without.
             try {
-                c = reflectedArg.getConstructor(new Class[] {String.class});
+                c = reflectedArg.getConstructor(String.class);
                 includeProject = false;
             } catch (NoSuchMethodException nme2) {
                 // Well, no matching constructor.
@@ -1179,7 +1180,7 @@ public final class IntrospectionHelper {
             }
         }
         final boolean finalIncludeProject = includeProject;
-        final Constructor finalConstructor = c;
+        final Constructor<?> finalConstructor = c;
 
         return new AttributeSetter(m, arg) {
             public void set(Project p, Object parent, String value)
@@ -1212,40 +1213,25 @@ public final class IntrospectionHelper {
     }
 
     private AttributeSetter getEnumSetter(
-        final Class reflectedArg, final Method m, Class arg) {
-        Class enumClass = null;
-        try {
-            enumClass = Class.forName("java.lang.Enum");
-        } catch (ClassNotFoundException e) {
-            //ignore
-        }
-        if (enumClass != null && enumClass.isAssignableFrom(reflectedArg)) {
+        final Class<?> reflectedArg, final Method m, Class<?> arg) {
+        if (reflectedArg.isEnum()) {
             return new AttributeSetter(m, arg) {
                 public void set(Project p, Object parent, String value)
                     throws InvocationTargetException, IllegalAccessException,
                     BuildException {
+                    Enum<?> setValue;
                     try {
-                        m.invoke(
-                            parent, new Object[] {
-                                reflectedArg.getMethod(
-                                    "valueOf", new Class[] {String.class}).
-                                invoke(null, new Object[] {value})});
-                    } catch (InvocationTargetException x) {
+                        @SuppressWarnings({ "unchecked", "rawtypes" })
+                        Enum<?> enumValue = Enum.valueOf((Class<? extends Enum>) reflectedArg,
+                                value);
+                        setValue = enumValue;
+                    } catch (IllegalArgumentException e) {
                         //there is specific logic here for the value
                         // being out of the allowed set of enumerations.
-                        if (x.getTargetException() instanceof IllegalArgumentException) {
-                            throw new BuildException(
-                                "'" + value + "' is not a permitted value for "
+                        throw new BuildException("'" + value + "' is not a permitted value for "
                                 + reflectedArg.getName());
-                        }
-                        //only if the exception is not an IllegalArgument do we
-                        // request the
-                        //BuildException via extractBuildException():
-                        throw extractBuildException(x);
-                    } catch (Exception x) {
-                        //any other failure of invoke() to work.
-                        throw new BuildException(x);
                     }
+                    m.invoke(parent, setValue);
                 }
             };
         }
@@ -1433,10 +1419,10 @@ public final class IntrospectionHelper {
         static final int ADD = 1;
         static final int ADD_CONFIGURED = 2;
 
-        private Constructor constructor;
+        private Constructor<?> constructor;
         private int behavior; // ADD or ADD_CONFIGURED
 
-        AddNestedCreator(Method m, Constructor c, int behavior) {
+        AddNestedCreator(Method m, Constructor<?> c, int behavior) {
             super(m);
             this.constructor = c;
             this.behavior = behavior;
@@ -1481,15 +1467,15 @@ public final class IntrospectionHelper {
      */
     private abstract static class AttributeSetter {
         private Method method; // the method called to set the attribute
-        private Class type;
-        protected AttributeSetter(Method m, Class type) {
+        private Class<?> type;
+        protected AttributeSetter(Method m, Class<?> type) {
             method = m;
             this.type = type;
         }
         void setObject(Project p, Object parent, Object value)
                 throws InvocationTargetException, IllegalAccessException, BuildException {
             if (type != null) {
-                Class useType = type;
+                Class<?> useType = type;
                 if (type.isPrimitive()) {
                     if (value == null) {
                         throw new BuildException(
@@ -1497,7 +1483,7 @@ public final class IntrospectionHelper {
                             + getPropertyName(method.getName(), "set")
                             + " to null on " + parent);
                     }
-                    useType = (Class) PRIMITIVE_TYPE_MAP.get(type);
+                    useType = PRIMITIVE_TYPE_MAP.get(type);
                 }
                 if (value == null || useType.isInstance(value)) {
                     method.invoke(parent, new Object[] {value});
@@ -1589,7 +1575,7 @@ public final class IntrospectionHelper {
      * @param method the <code>Method</code> to insert.
      */
     private void insertAddTypeMethod(Method method) {
-        Class argClass = method.getParameterTypes()[0];
+        Class<?> argClass = method.getParameterTypes()[0];
         final int size = addTypeMethods.size();
         for (int c = 0; c < size; ++c) {
             Method current = (Method) addTypeMethods.get(c);
@@ -1615,17 +1601,17 @@ public final class IntrospectionHelper {
      * @param methods the <code>List</code> of methods to search.
      * @return a matching <code>Method</code>; null if none found.
      */
-    private Method findMatchingMethod(Class paramClass, List methods) {
+    private Method findMatchingMethod(Class<?> paramClass, List<Method> methods) {
         if (paramClass == null) {
             return null;
         }
-        Class matchedClass = null;
+        Class<?> matchedClass = null;
         Method matchedMethod = null;
 
         final int size = methods.size();
         for (int i = 0; i < size; ++i) {
-            Method method = (Method) methods.get(i);
-            Class  methodClass = method.getParameterTypes()[0];
+            Method method = methods.get(i);
+            Class<?> methodClass = method.getParameterTypes()[0];
             if (methodClass.isAssignableFrom(paramClass)) {
                 if (matchedClass == null) {
                     matchedClass = methodClass;
@@ -1661,19 +1647,19 @@ public final class IntrospectionHelper {
      *
      */
     private AntTypeDefinition findRestrictedDefinition(
-        ComponentHelper helper, String componentName, List methods) {
+        ComponentHelper helper, String componentName, List<Method> methods) {
         AntTypeDefinition definition = null;
-        Class matchedDefinitionClass = null;
+        Class<?> matchedDefinitionClass = null;
 
-        List definitions = helper.getRestrictedDefinitions(componentName);
+        List<AntTypeDefinition> definitions = helper.getRestrictedDefinitions(componentName);
         if (definitions == null) {
             return null;
         }
         synchronized (definitions) {
             final int size = definitions.size();
             for (int i = 0; i < size; ++i) {
-                AntTypeDefinition d = (AntTypeDefinition) definitions.get(i);
-                Class exposedClass = d.getExposedClass(helper.getProject());
+                AntTypeDefinition d = definitions.get(i);
+                Class<?> exposedClass = d.getExposedClass(helper.getProject());
                 if (exposedClass == null) {
                     continue;
                 }
@@ -1695,7 +1681,7 @@ public final class IntrospectionHelper {
     }
 
     private MethodAndObject createRestricted(
-        ComponentHelper helper, String elementName, List addTypeMethods) {
+        ComponentHelper helper, String elementName, List<Method> addTypeMethods) {
 
         Project project = helper.getProject();
 
@@ -1723,8 +1709,8 @@ public final class IntrospectionHelper {
     }
 
     private MethodAndObject createTopLevel(
-        ComponentHelper helper, String elementName, List methods) {
-        Class clazz = helper.getComponentClass(elementName);
+        ComponentHelper helper, String elementName, List<Method> methods) {
+        Class<?> clazz = helper.getComponentClass(elementName);
         if (clazz == null) {
             return null;
         }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/Location.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/Location.java?rev=1375137&r1=1375136&r2=1375137&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/Location.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/Location.java Mon Aug 20 17:49:13 2012
@@ -29,6 +29,7 @@ import org.xml.sax.Locator;
  *
  */
 public class Location implements Serializable {
+    private static final long serialVersionUID = 1L;
 
     /** Name of the file. */
     private final String fileName;