| @@ -55,7 +55,7 @@ public class Javac12 extends DefaultCompilerAdapter { | |||
| // Create an instance of the compiler, redirecting output to | |||
| // the project log | |||
| Class<?> c = Class.forName(CLASSIC_COMPILER_CLASSNAME); | |||
| Constructor cons = c.getConstructor(OutputStream.class, String.class); | |||
| Constructor<?> cons = c.getConstructor(OutputStream.class, String.class); | |||
| Object compiler = cons.newInstance(logstr, "javac"); | |||
| // Call the compile() method | |||
| @@ -335,7 +335,7 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||
| if ("org.apache.xalan.transformer.TransformerImpl" //NOSONAR | |||
| .equals(transformer.getClass().getName())) { | |||
| try { | |||
| final Class traceSupport = | |||
| final Class<?> traceSupport = | |||
| Class.forName("org.apache.tools.ant.taskdefs.optional." | |||
| + "Xalan2TraceSupport", true, | |||
| Thread.currentThread() | |||
| @@ -389,7 +389,7 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||
| tfactory = TransformerFactory.newInstance(); | |||
| } else { | |||
| try { | |||
| Class clazz = null; | |||
| Class<?> clazz = null; | |||
| try { | |||
| clazz = | |||
| Class.forName(factoryName, true, | |||
| @@ -382,7 +382,7 @@ public class XMLValidateTask extends Task { | |||
| reader = createDefaultReaderOrParser(); | |||
| } else { | |||
| Class readerClass = null; | |||
| Class<?> readerClass = null; | |||
| try { | |||
| // load the parser class | |||
| if (classpath != null) { | |||
| @@ -80,8 +80,9 @@ public class AntStructureTest { | |||
| private int elementCalled = 0; | |||
| private Project p; | |||
| public void printHead(PrintWriter out, Project p, Hashtable tasks, | |||
| Hashtable types) { | |||
| public void printHead(PrintWriter out, Project p, | |||
| Hashtable<String, Class<?>> tasks, | |||
| Hashtable<String, Class<?>> types) { | |||
| assertTrue(!headCalled); | |||
| assertTrue(!targetCalled); | |||
| assertTrue(!tailCalled); | |||
| @@ -96,7 +97,7 @@ public class AntStructureTest { | |||
| targetCalled = true; | |||
| } | |||
| public void printElementDecl(PrintWriter out, Project p, String name, | |||
| Class element) { | |||
| Class<?> element) { | |||
| assertTrue(headCalled); | |||
| assertTrue(targetCalled); | |||
| assertTrue(!tailCalled); | |||
| @@ -265,10 +265,10 @@ public class JarTest { | |||
| try { | |||
| buildRule.executeTarget("testIndexTests"); | |||
| archive = new ZipFile(new File(getOutputDir(), tempJar)); | |||
| Enumeration e = archive.entries(); | |||
| Enumeration<? extends ZipEntry> e = archive.entries(); | |||
| int numberOfIndexLists = 0; | |||
| while (e.hasMoreElements()) { | |||
| ZipEntry ze = (ZipEntry) e.nextElement(); | |||
| ZipEntry ze = e.nextElement(); | |||
| if (ze.getName().equals("META-INF/INDEX.LIST")) { | |||
| numberOfIndexLists++; | |||
| } | |||
| @@ -319,16 +319,16 @@ public class ManifestTest { | |||
| buildRule.executeTarget("testOrder1"); | |||
| Manifest manifest = getManifest(expandedManifest); | |||
| Enumeration e = manifest.getSectionNames(); | |||
| String section1 = (String) e.nextElement(); | |||
| String section2 = (String) e.nextElement(); | |||
| Enumeration<String> e = manifest.getSectionNames(); | |||
| String section1 = e.nextElement(); | |||
| String section2 = e.nextElement(); | |||
| assertEquals("First section name unexpected", "Test1", section1); | |||
| assertEquals("Second section name unexpected", "Test2", section2); | |||
| Manifest.Section section = manifest.getSection("Test1"); | |||
| e = section.getAttributeKeys(); | |||
| String attr1Key = (String) e.nextElement(); | |||
| String attr2Key = (String) e.nextElement(); | |||
| String attr1Key = e.nextElement(); | |||
| String attr2Key = e.nextElement(); | |||
| String attr1 = section.getAttribute(attr1Key).getName(); | |||
| String attr2 = section.getAttribute(attr2Key).getName(); | |||
| assertEquals("First attribute name unexpected", "TestAttr1", attr1); | |||
| @@ -343,16 +343,16 @@ public class ManifestTest { | |||
| buildRule.executeTarget("testOrder2"); | |||
| Manifest manifest = getManifest(expandedManifest); | |||
| Enumeration e = manifest.getSectionNames(); | |||
| String section1 = (String) e.nextElement(); | |||
| String section2 = (String) e.nextElement(); | |||
| Enumeration<String> e = manifest.getSectionNames(); | |||
| String section1 = e.nextElement(); | |||
| String section2 = e.nextElement(); | |||
| assertEquals("First section name unexpected", "Test2", section1); | |||
| assertEquals("Second section name unexpected", "Test1", section2); | |||
| Manifest.Section section = manifest.getSection("Test1"); | |||
| e = section.getAttributeKeys(); | |||
| String attr1Key = (String) e.nextElement(); | |||
| String attr2Key = (String) e.nextElement(); | |||
| String attr1Key = e.nextElement(); | |||
| String attr2Key = e.nextElement(); | |||
| String attr1 = section.getAttribute(attr1Key).getName(); | |||
| String attr2 = section.getAttribute(attr2Key).getName(); | |||
| assertEquals("First attribute name unexpected", "TestAttr2", attr1); | |||
| @@ -136,7 +136,7 @@ public class TypeAdapterTest { | |||
| throw new BuildException(message); | |||
| } | |||
| } | |||
| public void checkProxyClass(Class proxyClass) { | |||
| public void checkProxyClass(Class<?> proxyClass) { | |||
| getExecuteMethod(proxyClass); | |||
| } | |||
| @@ -24,7 +24,9 @@ import java.io.FileInputStream; | |||
| import java.io.IOException; | |||
| import java.util.Enumeration; | |||
| import java.util.Hashtable; | |||
| import java.util.Map; | |||
| import java.util.Properties; | |||
| import java.util.Set; | |||
| import java.util.Vector; | |||
| import org.apache.tools.ant.BuildFileRule; | |||
| @@ -145,10 +147,10 @@ public class XmlPropertyTest { | |||
| */ | |||
| private void doTest(String msg, boolean keepRoot, boolean collapse, | |||
| boolean semantic, boolean include, boolean localRoot) throws IOException { | |||
| Enumeration iter = | |||
| Enumeration<File> iter = | |||
| getFiles(new File(System.getProperty("root"), "src/etc/testcases/taskdefs/xmlproperty/inputs")); | |||
| while (iter.hasMoreElements()) { | |||
| File inputFile = (File) iter.nextElement(); | |||
| File inputFile = iter.nextElement(); | |||
| // What's the working directory? If local, then its the | |||
| // folder of the input file. Otherwise, its the "current" dir.. | |||
| File workingDir; | |||
| @@ -209,11 +211,9 @@ public class XmlPropertyTest { | |||
| private static void ensureProperties(String msg, File inputFile, | |||
| File workingDir, Project p, | |||
| Properties properties) { | |||
| Hashtable xmlproperties = p.getProperties(); | |||
| Hashtable<String, Object> xmlproperties = p.getProperties(); | |||
| // Every key identified by the Properties must have been loaded. | |||
| Enumeration<?> propertyKeyEnum = properties.propertyNames(); | |||
| while (propertyKeyEnum.hasMoreElements()) { | |||
| String currentKey = propertyKeyEnum.nextElement().toString(); | |||
| for (String currentKey : properties.stringPropertyNames()) { | |||
| String assertMsg = msg + "-" + inputFile.getName() | |||
| + " Key=" + currentKey; | |||
| @@ -266,24 +266,20 @@ public class XmlPropertyTest { | |||
| /** | |||
| * Debugging method to print the properties in the given hashtable | |||
| */ | |||
| private static void printProperties(Hashtable xmlproperties) { | |||
| Enumeration keyEnum = xmlproperties.keys(); | |||
| while (keyEnum.hasMoreElements()) { | |||
| String currentKey = keyEnum.nextElement().toString(); | |||
| System.out.println(currentKey + " = " | |||
| + xmlproperties.get(currentKey)); | |||
| private static void printProperties(Hashtable<Object, Object> xmlproperties) { | |||
| for (Map.Entry<Object, Object> entry : xmlproperties.entrySet()) { | |||
| System.out.println(entry.getKey() + " = " + entry.getValue()); | |||
| } | |||
| } | |||
| /** | |||
| * Ensure all references loaded by the project are valid. | |||
| */ | |||
| private static void ensureReferences (String msg, File inputFile, | |||
| Hashtable references) { | |||
| Enumeration referenceKeyEnum = references.keys(); | |||
| while(referenceKeyEnum.hasMoreElements()){ | |||
| String currentKey = referenceKeyEnum.nextElement().toString(); | |||
| Object currentValue = references.get(currentKey); | |||
| private static void ensureReferences(String msg, File inputFile, | |||
| Hashtable<String, Object> references) { | |||
| for (Map.Entry<String, Object> entry : references.entrySet()) { | |||
| String currentKey = entry.getKey(); | |||
| Object currentValue = entry.getValue(); | |||
| if (!(currentValue instanceof Path) && !(currentValue instanceof String) | |||
| && !currentKey.startsWith("ant.")) { | |||
| @@ -337,7 +333,7 @@ public class XmlPropertyTest { | |||
| * Retrieve a list of xml files in the specified folder | |||
| * and below. | |||
| */ | |||
| private static Enumeration getFiles (final File startingDir) { | |||
| private static Enumeration<File> getFiles (final File startingDir) { | |||
| Vector<File> result = new Vector<>(); | |||
| getFiles(startingDir, result); | |||
| return result.elements(); | |||
| @@ -65,7 +65,7 @@ public class DependTest { | |||
| FileUtilities.rollbackTimestamps(new File(buildRule.getProject().getProperty("classes.dir")), 5); | |||
| buildRule.executeTarget("testdirect"); | |||
| Hashtable files = getResultFiles(); | |||
| Hashtable<String, String> files = getResultFiles(); | |||
| assertEquals("Depend did not leave correct number of files", 3, | |||
| files.size()); | |||
| assertTrue("Result did not contain A.class", | |||
| @@ -86,7 +86,7 @@ public class DependTest { | |||
| FileUtilities.rollbackTimestamps(new File(buildRule.getProject().getProperty("classes.dir")), 5); | |||
| buildRule.executeTarget("testclosure"); | |||
| Hashtable files = getResultFiles(); | |||
| Hashtable<String, String> files = getResultFiles(); | |||
| assertTrue("Depend did not leave correct number of files", | |||
| files.size() <= 2); | |||
| assertTrue("Result did not contain D.class", | |||
| @@ -159,7 +159,7 @@ public class DependTest { | |||
| * @return a Hashtable containing the names of the files in the result | |||
| * fileset | |||
| */ | |||
| private Hashtable getResultFiles() { | |||
| private Hashtable<String, String> getResultFiles() { | |||
| FileSet resultFileSet = buildRule.getProject().getReference(RESULT_FILESET); | |||
| DirectoryScanner scanner = resultFileSet.getDirectoryScanner(buildRule.getProject()); | |||
| Hashtable<String, String> files = new Hashtable<>(); | |||
| @@ -92,7 +92,7 @@ public class JUnitReportTest { | |||
| try { | |||
| assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0); | |||
| } finally { | |||
| FileUtils.getFileUtils().close(reportStream); | |||
| FileUtils.close(reportStream); | |||
| } | |||
| } | |||
| @@ -478,7 +478,7 @@ public class FTPTest { | |||
| * to parse the log output. | |||
| */ | |||
| private class CountLogListener extends DefaultLogger { | |||
| private Vector lastMatchGroups = null; | |||
| private Vector<String> lastMatchGroups = null; | |||
| private RegexpMatcher matcher = new RegexpMatcherFactory().newRegexpMatcher(); | |||
| /** | |||
| @@ -514,7 +514,7 @@ public class FTPTest { | |||
| if (this.lastMatchGroups == null) { | |||
| return -1; | |||
| } | |||
| return Integer.parseInt((String) this.lastMatchGroups.get(1)); | |||
| return Integer.parseInt(this.lastMatchGroups.get(1)); | |||
| } | |||
| } | |||
| @@ -153,7 +153,7 @@ public class FilterSetTest { | |||
| buildRule.executeTarget("test-nested-filtersets"); | |||
| FilterSet fs = buildRule.getProject().getReference("1"); | |||
| Hashtable filters = fs.getFilterHash(); | |||
| Hashtable<String, String> filters = fs.getFilterHash(); | |||
| assertEquals(1, filters.size()); | |||
| assertEquals("value1", filters.get("token1")); | |||
| @@ -175,7 +175,7 @@ public class MapperTest { | |||
| String[] targets = fileNameMapper.mapFileName("fromfilename"); | |||
| assertNotNull("no filenames mapped", targets); | |||
| assertEquals("wrong number of filenames mapped", 3, targets.length); | |||
| List list = Arrays.asList(targets); | |||
| List<String> list = Arrays.asList(targets); | |||
| assertTrue("cannot find expected target \"tofilename\"", | |||
| list.contains("tofilename")); | |||
| assertTrue("cannot find expected target \"fromfilename\"", | |||
| @@ -20,7 +20,7 @@ package org.apache.tools.ant.types.selectors; | |||
| import java.util.Comparator; | |||
| public class MockComparator implements Comparator { | |||
| public class MockComparator implements Comparator<Object> { | |||
| public int compare(Object o1, Object o2) { | |||
| return 0; | |||
| @@ -408,7 +408,7 @@ public class ModifiedSelectorTest { | |||
| String value2 = "value2"; | |||
| // given cache must be empty | |||
| Iterator it1 = cache.iterator(); | |||
| Iterator<String> it1 = cache.iterator(); | |||
| assertFalse("Cache is not empty", it1.hasNext()); | |||
| // cache must return a stored value | |||
| @@ -418,8 +418,8 @@ public class ModifiedSelectorTest { | |||
| assertEquals("cache returned wrong value", value2, cache.get(key2)); | |||
| // test the iterator | |||
| Iterator it2 = cache.iterator(); | |||
| Object returned = it2.next(); | |||
| Iterator<String> it2 = cache.iterator(); | |||
| String returned = it2.next(); | |||
| boolean ok = (key1.equals(returned) || key2.equals(returned)); | |||
| String msg = "Iterator returned unexpected value." | |||
| + " key1.equals(returned)=" + key1.equals(returned) | |||
| @@ -430,7 +430,7 @@ public class ModifiedSelectorTest { | |||
| // clear the cache | |||
| cache.delete(); | |||
| Iterator it3 = cache.iterator(); | |||
| Iterator<String> it3 = cache.iterator(); | |||
| assertFalse("Cache is not empty", it3.hasNext()); | |||
| } | |||
| @@ -19,6 +19,7 @@ | |||
| package org.apache.tools.ant.util; | |||
| import java.io.IOException; | |||
| import java.net.URL; | |||
| import java.util.Enumeration; | |||
| import org.apache.tools.ant.BuildException; | |||
| @@ -46,7 +47,7 @@ public class ClasspathUtilsTest { | |||
| @Test | |||
| public void testOnlyOneInstance() { | |||
| Enumeration enumeration; | |||
| Enumeration<URL> enumeration; | |||
| ClassLoader c = ClasspathUtils.getUniqueClassLoaderForPath(p, null, false); | |||
| try { | |||
| enumeration = c.getResources( | |||
| @@ -46,7 +46,7 @@ public class LinkedHashtableTest { | |||
| public void testClone() { | |||
| h.put(K1, V1); | |||
| Hashtable h2 = (Hashtable) h.clone(); | |||
| Hashtable<Object, Object> h2 = (Hashtable) h.clone(); | |||
| assertTrue(h2 instanceof LinkedHashtable); | |||
| assertTrue(h2.containsKey(K1)); | |||
| } | |||
| @@ -130,13 +130,13 @@ public class LinkedHashtableTest { | |||
| @Test | |||
| public void testEntrySet() { | |||
| multiSetup(); | |||
| Iterator i = h.entrySet().iterator(); | |||
| Iterator<Map.Entry<Object, Object>> i = h.entrySet().iterator(); | |||
| assertTrue(i.hasNext()); | |||
| Map.Entry e = (Map.Entry) i.next(); | |||
| Map.Entry<Object, Object> e = i.next(); | |||
| assertSame(K1, e.getKey()); | |||
| assertSame(V1, e.getValue()); | |||
| assertTrue(i.hasNext()); | |||
| e = (Map.Entry) i.next(); | |||
| e = i.next(); | |||
| assertSame(K2, e.getKey()); | |||
| assertSame(V2, e.getValue()); | |||
| assertFalse(i.hasNext()); | |||
| @@ -147,7 +147,7 @@ public class LinkedHashtableTest { | |||
| h.put(K2, V2); | |||
| } | |||
| private static void assertKeys(Iterator i) { | |||
| private static void assertKeys(Iterator<Object> i) { | |||
| assertTrue(i.hasNext()); | |||
| assertSame(K1, i.next()); | |||
| assertTrue(i.hasNext()); | |||
| @@ -155,7 +155,7 @@ public class LinkedHashtableTest { | |||
| assertFalse(i.hasNext()); | |||
| } | |||
| private static void assertValues(Iterator i) { | |||
| private static void assertValues(Iterator<Object> i) { | |||
| assertTrue(i.hasNext()); | |||
| assertSame(V1, i.next()); | |||
| assertTrue(i.hasNext()); | |||
| @@ -80,7 +80,7 @@ public class VectorSetTest { | |||
| v.add(O); | |||
| Object o = v.clone(); | |||
| assertTrue(o instanceof VectorSet); | |||
| VectorSet<Object> vs = (VectorSet) o; | |||
| VectorSet<Object> vs = (VectorSet<Object>) o; | |||
| assertEquals(1, vs.size()); | |||
| assertTrue(vs.contains(O)); | |||
| } | |||
| @@ -78,7 +78,7 @@ public abstract class RegexpMatcherTest { | |||
| @Test | |||
| public void testGroups() { | |||
| reg.setPattern("aaaa"); | |||
| Vector v = reg.getGroups("xaaaa"); | |||
| Vector<String> v = reg.getGroups("xaaaa"); | |||
| assertEquals("No parens -> no extra groups", 1, v.size()); | |||
| assertEquals("Trivial match with no parens", "aaaa", | |||
| v.elementAt(0)); | |||
| @@ -102,7 +102,7 @@ public abstract class RegexpMatcherTest { | |||
| @Test | |||
| public void testBugzillaReport14619() { | |||
| reg.setPattern("^(.*)/src/((.*/)*)([a-zA-Z0-9_\\.]+)\\.java$"); | |||
| Vector v = reg.getGroups("de/tom/src/Google.java"); | |||
| Vector<String> v = reg.getGroups("de/tom/src/Google.java"); | |||
| assertEquals(5, v.size()); | |||
| assertEquals("de/tom", v.elementAt(1)); | |||
| assertEquals("", v.elementAt(2)); | |||
| @@ -603,26 +603,26 @@ public class MailMessageTest { | |||
| try { | |||
| msg.from(from); | |||
| Enumeration e; | |||
| Enumeration<String> e; | |||
| e = replyToList.elements(); | |||
| while (e.hasMoreElements()) { | |||
| msg.replyto(e.nextElement().toString()); | |||
| msg.replyto(e.nextElement()); | |||
| } | |||
| e = toList.elements(); | |||
| while (e.hasMoreElements()) { | |||
| msg.to(e.nextElement().toString()); | |||
| msg.to(e.nextElement()); | |||
| } | |||
| e = ccList.elements(); | |||
| while (e.hasMoreElements()) { | |||
| msg.cc(e.nextElement().toString()); | |||
| msg.cc(e.nextElement()); | |||
| } | |||
| e = bccList.elements(); | |||
| while (e.hasMoreElements()) { | |||
| msg.bcc(e.nextElement().toString()); | |||
| msg.bcc(e.nextElement()); | |||
| } | |||
| if (subject != null) { | |||
| @@ -200,9 +200,9 @@ public class UTF8ZipFilesTest { | |||
| try { | |||
| zf = new ZipFile(file, encoding, false); | |||
| Enumeration e = zf.getEntries(); | |||
| Enumeration<ZipEntry> e = zf.getEntries(); | |||
| while (e.hasMoreElements()) { | |||
| ZipEntry ze = (ZipEntry) e.nextElement(); | |||
| ZipEntry ze = e.nextElement(); | |||
| if (ze.getName().endsWith("sser.txt")) { | |||
| assertUnicodeName(ze, OIL_BARREL_TXT, encoding); | |||