diff options
Diffstat (limited to 'testing')
6 files changed, 89 insertions, 97 deletions
diff --git a/testing/src/org/aspectj/internal/tools/ant/taskdefs/Ajctest.java b/testing/src/org/aspectj/internal/tools/ant/taskdefs/Ajctest.java index c3c93729c..2502bca0d 100644 --- a/testing/src/org/aspectj/internal/tools/ant/taskdefs/Ajctest.java +++ b/testing/src/org/aspectj/internal/tools/ant/taskdefs/Ajctest.java @@ -123,19 +123,19 @@ public class Ajctest extends Task implements PropertyChangeListener { //fields private String testId = NO_TESTID; - private List args = new Vector(); - private List testsets = new Vector(); + private List<Argument> args = new Vector<>(); + private List<Testset> testsets = new Vector<>(); private Path classpath; private Path internalclasspath; private File destdir; private File dir; private File errorfile; - private List testclasses = new Vector(); + private List<Run> testclasses = new Vector<>(); private boolean nocompile; private Ajdoc ajdoc = null; private boolean noclean; private boolean noverify; - private List depends = new Vector(); + private List<String> depends = new Vector<>(); //end-fields public Argfile createArgfile() { @@ -321,7 +321,7 @@ public class Ajctest extends Task implements PropertyChangeListener { public static class Argument { private String name; - private List values = new Vector(); + private List<String> values = new Vector<>(); private boolean always = true; final boolean isj; public Argument(boolean isj) { @@ -332,14 +332,14 @@ public class Ajctest extends Task implements PropertyChangeListener { ("-" + (str.startsWith("J") ? str.substring(1) : str)); } public void setValues(String str) { - values = new Vector(); + values = new Vector<>(); StringTokenizer tok = new StringTokenizer(str, ", ", false); while (tok.hasMoreTokens()) { values.add(tok.nextToken().trim()); } } public void setValue(String value) { - (values = new Vector()).add(value); + (values = new Vector<>()).add(value); } public void setAlways(boolean always) { this.always = always; @@ -401,30 +401,30 @@ public class Ajctest extends Task implements PropertyChangeListener { } public class Testset extends FileSet { - private List argfileNames = new Vector(); - public List argfiles; - public List files; - public List args = new Vector(); + private List<Argfile> argfileNames = new Vector<>(); + public List<File> argfiles; + public List<File> files; + public List<Argument> args = new Vector<>(); public String classname; private boolean havecludes = false; - private List testclasses = new Vector(); + private List<Run> testclasses = new Vector<>(); private Path classpath; private Path internalclasspath; private Ajdoc ajdoc = null; private boolean fork = false; private boolean noclean; - private List depends = new Vector(); + private List<String> depends = new Vector<>(); public String toString() { String str = ""; if (files.size() > 0) { str += "files:" + "\n"; - for (Iterator i = files.iterator(); i.hasNext();) { + for (Iterator<File> i = files.iterator(); i.hasNext();) { str += "\t" + i.next() + "\n"; } } if (argfiles.size() > 0) { str += "argfiles:" + "\n"; - for (Iterator i = argfiles.iterator(); i.hasNext();) { + for (Iterator<File> i = argfiles.iterator(); i.hasNext();) { str += "\t" + i.next() + "\n"; } } @@ -578,10 +578,10 @@ public class Ajctest extends Task implements PropertyChangeListener { public void resolve() throws BuildException { if (dir != null) this.setDir(dir); File src = getDir(project); - argfiles = new Vector(); - files = new Vector(); - for(Iterator iter = argfileNames.iterator(); iter.hasNext();) { - String name = ((Argfile)iter.next()).name; + argfiles = new Vector<>(); + files = new Vector<>(); + for(Iterator<Argfile> iter = argfileNames.iterator(); iter.hasNext();) { + String name = iter.next().name; File argfile = new File(src, name); if (check(argfile, name, location)) argfiles.add(argfile); } @@ -610,8 +610,8 @@ public class Ajctest extends Task implements PropertyChangeListener { this.ajdoc = Ajctest.this.ajdoc; } if (this.fork) { - for (Iterator i = this.testclasses.iterator(); i.hasNext();) { - ((Run)i.next()).setFork(fork); + for (Iterator<Run> i = this.testclasses.iterator(); i.hasNext();) { + i.next().setFork(fork); } } if (!this.noclean) { @@ -687,40 +687,36 @@ public class Ajctest extends Task implements PropertyChangeListener { } - private void log(String space, List list, String title) { + private void log(String space, List<?> list, String title) { if (list == null || list.size() < 1) return; log(space + title); - for (Iterator i = list.iterator(); i.hasNext();) { + for (Iterator<?> i = list.iterator(); i.hasNext();) { log(space + " " + i.next()); } } - private void execute(Testset testset, List args) throws BuildException { + private void execute(Testset testset, List<Arg> args) throws BuildException { if (testset.files.size() > 0) { log("\tfiles:"); - for (Iterator i = testset.files.iterator(); - i.hasNext();) { + for (Iterator<File> i = testset.files.iterator(); i.hasNext();) { log("\t " + i.next()); } } if (testset.argfiles.size() > 0) { log("\targfiles:"); - for (Iterator i = testset.argfiles.iterator(); - i.hasNext();) { + for (Iterator<File> i = testset.argfiles.iterator(); i.hasNext();) { log("\t " + i.next()); } } if (args.size() > 0) { log("\targs:"); - for (Iterator i = args.iterator(); - i.hasNext();) { + for (Iterator<Arg> i = args.iterator(); i.hasNext();) { log("\t " + i.next()); } } if (testset.testclasses.size() > 0) { log("\tclasses:"); - for (Iterator i = testset.testclasses.iterator(); - i.hasNext();) { + for (Iterator<Run> i = testset.testclasses.iterator(); i.hasNext();) { log("\t " + i.next()); } } @@ -731,7 +727,7 @@ public class Ajctest extends Task implements PropertyChangeListener { } delete(workingdir); make(workingdir); - for (Iterator i = testset.depends.iterator(); i.hasNext();) { + for (Iterator<String> i = testset.depends.iterator(); i.hasNext();) { String target = i.next()+""; // todo: capture failures here? project.executeTarget(target); @@ -788,9 +784,8 @@ public class Ajctest extends Task implements PropertyChangeListener { -1, "run"); } else if (!isSet("norun")) { - for (Iterator i = testset.testclasses.iterator(); - i.hasNext();) { - Run testclass = (Run)i.next(); + for (Iterator<Run> i = testset.testclasses.iterator(); i.hasNext();) { + Run testclass = i.next(); log("\ttest..." + testclass.classname()); if (null != destdir) { testclass.setClassesDir(destdir.getAbsolutePath()); @@ -812,27 +807,26 @@ public class Ajctest extends Task implements PropertyChangeListener { prepare(); log(testsets.size() + " testset" + s(testsets), Project.MSG_VERBOSE); - Map testsetToArgcombo = new HashMap(); - List argcombos = new Vector(); - for (Iterator iter = testsets.iterator(); iter.hasNext();) { - Testset testset = (Testset)iter.next(); + Map<Testset,List<List<Arg>>> testsetToArgcombo = new HashMap<>(); + List<Integer> argcombos = new Vector<>(); + for (Testset testset: testsets) { testset.resolve(); - List bothargs = new Vector(args); + List<Argument> bothargs = new Vector<>(args); bothargs.addAll(testset.args); - List argcombo = argcombo(bothargs); + List<List<Arg>> argcombo = argcombo(bothargs); argcombos.add(new Integer(argcombo.size())); testsetToArgcombo.put(testset, argcombo); } while (!testsetToArgcombo.isEmpty()) { int _ = 1; - for (Iterator iter = testsets.iterator(); iter.hasNext(); _++) { - Testset testset = (Testset)iter.next(); - List argcombo = (List)testsetToArgcombo.get(testset); + for (Iterator<Testset> iter = testsets.iterator(); iter.hasNext(); _++) { + Testset testset = iter.next(); + List<List<Arg>> argcombo = testsetToArgcombo.get(testset); if (argcombo.size() == 0) { testsetToArgcombo.remove(testset); continue; } - List args = (List)argcombo.remove(0); + List<Arg> args = argcombo.remove(0); final String startStr = "Testset " + _ + " of " + testsets.size(); String str = startStr + " / Combo " + _ + " of " + argcombos.size(); log("---------- " + str + " ----------"); @@ -1085,7 +1079,7 @@ public class Ajctest extends Task implements PropertyChangeListener { // } private static List allErrors = new Vector(); - private List errors = new Vector(); + private List<Failure> errors = new Vector<>(); private void post(Testset testset, List args, String msgs, int exit, String type) { @@ -1290,11 +1284,11 @@ public class Ajctest extends Task implements PropertyChangeListener { } } - private List argcombo(List arguments) { - List combos = new Vector(); - List always = new Vector(); - for (Iterator iter = arguments.iterator(); iter.hasNext();) { - Argument arg = (Argument)iter.next(); + private List<List<Arg>> argcombo(List<Argument> arguments) { + List<Argument> combos = new Vector<>(); + List<Arg> always = new Vector<>(); + for (Iterator<Argument> iter = arguments.iterator(); iter.hasNext();) { + Argument arg = iter.next(); if (arg.values.size() == 0) arg.values.add(""); if (!arg.always && !arg.values.contains(null)) arg.values.add(null); if (arg.values.size() > 0) { @@ -1303,11 +1297,11 @@ public class Ajctest extends Task implements PropertyChangeListener { always.add(new Arg(arg.name, arg.values.get(0)+"", arg.isj)); } } - List argcombo = combinations(combos); - for (Iterator iter = always.iterator(); iter.hasNext();) { - Arg arg = (Arg)iter.next(); - for (Iterator comboiter = argcombo.iterator(); comboiter.hasNext();) { - ((List)comboiter.next()).add(arg); + List<List<Arg>> argcombo = combinations(combos); + for (Iterator<Arg> iter = always.iterator(); iter.hasNext();) { + Arg arg = iter.next(); + for (Iterator<List<Arg>> comboiter = argcombo.iterator(); comboiter.hasNext();) { + comboiter.next().add(arg); } } return argcombo; @@ -1624,16 +1618,16 @@ public class Ajctest extends Task implements PropertyChangeListener { log("done handling " + t); } - private List combinations(List arglist) { - List result = new Vector(); - result.add(new Vector()); - for (Iterator iter = arglist.iterator(); iter.hasNext();) { - Argument arg = (Argument)iter.next(); + private List<List<Arg>> combinations(List<Argument> arglist) { + List<List<Arg>> result = new Vector<>(); + result.add(new Vector<Arg>()); + for (Iterator<Argument> iter = arglist.iterator(); iter.hasNext();) { + Argument arg = iter.next(); int N = result.size(); for (int i = 0; i < N; i++) { - List to = (List)result.remove(0); - for (Iterator valiter = arg.values.iterator(); valiter.hasNext();) { - List newlist = new Vector(to); + List<Arg> to = result.remove(0); + for (Iterator<String> valiter = arg.values.iterator(); valiter.hasNext();) { + List<Arg> newlist = new Vector<>(to); Object val = valiter.next(); if (val != null) newlist.add(new Arg(arg.name, val+"", arg.isj)); result.add(newlist); diff --git a/testing/src/org/aspectj/internal/tools/ant/taskdefs/MainWrapper.java b/testing/src/org/aspectj/internal/tools/ant/taskdefs/MainWrapper.java index 55d8dbed1..6ce22df24 100644 --- a/testing/src/org/aspectj/internal/tools/ant/taskdefs/MainWrapper.java +++ b/testing/src/org/aspectj/internal/tools/ant/taskdefs/MainWrapper.java @@ -81,8 +81,8 @@ public class MainWrapper { // access classname from jvm arg classname = System.getProperty(PROP_NAME); // this will fail if the class is not available from this classloader - Class cl = Class.forName(classname); - final Class[] argTypes = new Class[] {String[].class}; + Class<?> cl = Class.forName(classname); + final Class<?>[] argTypes = new Class[] {String[].class}; // will fail if no main method main = cl.getMethod("main", argTypes); if (!Modifier.isStatic(main.getModifiers())) { diff --git a/testing/src/org/aspectj/testing/harness/bridge/AbstractRunSpec.java b/testing/src/org/aspectj/testing/harness/bridge/AbstractRunSpec.java index d45037aac..4e61a512c 100644 --- a/testing/src/org/aspectj/testing/harness/bridge/AbstractRunSpec.java +++ b/testing/src/org/aspectj/testing/harness/bridge/AbstractRunSpec.java @@ -257,7 +257,7 @@ abstract public class AbstractRunSpec implements IRunSpec { // --------------- (String) paths /** @return ArrayList of String paths */ - public ArrayList getPathsList() { + public ArrayList<String> getPathsList() { return makeList(paths); } @@ -572,7 +572,7 @@ abstract public class AbstractRunSpec implements IRunSpec { */ protected void writeChildren(XMLWriter out) { if (0 < children.size()) { - for (Iterator iter = children.iterator(); iter.hasNext();) { + for (Iterator<IRunSpec> iter = children.iterator(); iter.hasNext();) { IXmlWritable self = (IXmlWritable) iter.next(); self.writeXml(out); } @@ -583,7 +583,7 @@ abstract public class AbstractRunSpec implements IRunSpec { public void printAll(PrintStream out, String prefix) { out.println(prefix + toString()); - for (Iterator iter = children.iterator(); iter.hasNext();) { + for (Iterator<IRunSpec> iter = children.iterator(); iter.hasNext();) { AbstractRunSpec child = (AbstractRunSpec) iter.next(); // IRunSpec child.printAll(out, prefix + " "); } @@ -614,7 +614,7 @@ abstract public class AbstractRunSpec implements IRunSpec { addListCount("options", options, result); addListCount("paths", paths, result); // XXXXXunused addListCount("sourceLocations", sourceLocations, result); - List messagesList = messages.getUnmodifiableListView(); + List<IMessage> messagesList = messages.getUnmodifiableListView(); addListCount("messages", messagesList, result); return result.toString().trim(); @@ -634,7 +634,7 @@ abstract public class AbstractRunSpec implements IRunSpec { addListEntries("options", options, result); addListEntries("paths", paths, result); // XXXXXunused addListEntries("sourceLocations", sourceLocations, result); - List messagesList = messages.getUnmodifiableListView(); + List<IMessage> messagesList = messages.getUnmodifiableListView(); addListEntries("messages", messagesList, result); return result.toString(); @@ -683,7 +683,7 @@ abstract public class AbstractRunSpec implements IRunSpec { spec.xmlNames = ((AbstractRunSpec.XMLNames) xmlNames.clone()); } - private static void addListCount(String name, List list, StringBuffer sink) { + private static void addListCount(String name, List<?> list, StringBuffer sink) { int size = list.size(); if ((null != list) && (0 < size)) { sink.append(" " + size + " "); @@ -691,7 +691,7 @@ abstract public class AbstractRunSpec implements IRunSpec { } } - private static void addListEntries(String name, List list, StringBuffer sink) { + private static void addListEntries(String name, List<?> list, StringBuffer sink) { if ((null != list) && (0 < list.size())) { sink.append(" " + list.size() + " "); sink.append(name); diff --git a/testing/src/org/aspectj/testing/harness/bridge/AjcMessageHandler.java b/testing/src/org/aspectj/testing/harness/bridge/AjcMessageHandler.java index 1b147ebc4..f4a88c3b2 100644 --- a/testing/src/org/aspectj/testing/harness/bridge/AjcMessageHandler.java +++ b/testing/src/org/aspectj/testing/harness/bridge/AjcMessageHandler.java @@ -135,8 +135,8 @@ public class AjcMessageHandler extends MessageHandler { /** Generate differences between expected and actual errors and warnings */ public CompilerDiffs getCompilerDiffs() { if (null == diffs) { - final List expected; - final List actual; + final List<IMessage> expected; + final List<IMessage> actual; if (!ignoreWarnings) { expected = expectedMessages.getUnmodifiableListView(); actual = this.getUnmodifiableListView(); @@ -269,7 +269,7 @@ public class AjcMessageHandler extends MessageHandler { private IMessage[] getMessagesWithoutExpectedFails() { IMessage[] result = super.getMessages(null, true); // remove all expected fail+ (COSTLY) - ArrayList list = new ArrayList(); + ArrayList<IMessage> list = new ArrayList<>(); int leftToFilter = numExpectedFailed; for (int i = 0; i < result.length; i++) { if ((0 == leftToFilter) diff --git a/testing/src/org/aspectj/testing/harness/bridge/DirChanges.java b/testing/src/org/aspectj/testing/harness/bridge/DirChanges.java index a57dde62d..13281607b 100644 --- a/testing/src/org/aspectj/testing/harness/bridge/DirChanges.java +++ b/testing/src/org/aspectj/testing/harness/bridge/DirChanges.java @@ -469,25 +469,25 @@ public class DirChanges { boolean fastFail; /** relative paths (String) of expected files added */ - final ArrayList added; + final ArrayList<String> added; /** relative paths (String) of expected files removed/deleted */ - final ArrayList removed; + final ArrayList<String> removed; /** relative paths (String) of expected files updated/changed */ - final ArrayList updated; + final ArrayList<String> updated; /** relative paths (String) of expected files NOT * added, removed, or changed * XXX unchanged unimplemented */ - final ArrayList unchanged; + final ArrayList<String> unchanged; public Spec() { - added = new ArrayList(); - removed = new ArrayList(); - updated = new ArrayList(); - unchanged = new ArrayList(); + added = new ArrayList<>(); + removed = new ArrayList<>(); + updated = new ArrayList<>(); + unchanged = new ArrayList<>(); } /** @@ -595,13 +595,13 @@ public class DirChanges { * @param out XMLWriter output sink * @param dirChanges List of DirChanges.Spec to write */ - public static void writeXml(XMLWriter out, List dirChanges) { + public static void writeXml(XMLWriter out, List<DirChanges.Spec> dirChanges) { if (LangUtil.isEmpty(dirChanges)) { return; } LangUtil.throwIaxIfNull(out, "out"); - for (Iterator iter = dirChanges.iterator(); iter.hasNext();) { - DirChanges.Spec spec = (DirChanges.Spec) iter.next(); + for (Iterator<DirChanges.Spec> iter = dirChanges.iterator(); iter.hasNext();) { + DirChanges.Spec spec = iter.next(); if (null == spec) { continue; } diff --git a/testing/src/org/aspectj/testing/harness/bridge/FlatSuiteReader.java b/testing/src/org/aspectj/testing/harness/bridge/FlatSuiteReader.java index 5de765d1b..8d75d5620 100644 --- a/testing/src/org/aspectj/testing/harness/bridge/FlatSuiteReader.java +++ b/testing/src/org/aspectj/testing/harness/bridge/FlatSuiteReader.java @@ -17,7 +17,6 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; -import java.util.Iterator; import java.util.List; import org.aspectj.bridge.AbortException; @@ -151,7 +150,7 @@ public class FlatSuiteReader implements SFileReader.Maker { throw new AbortException("expected sources at " + reader); } - ArrayList exp = new ArrayList(); + ArrayList<Message> exp = new ArrayList<>(); // !compile || noerrors || className {runOption..} String first = words[0]; if ("!compile".equals(first)) { @@ -290,10 +289,9 @@ public class FlatSuiteReader implements SFileReader.Maker { } result.description = input; - ArrayList newOptions = new ArrayList(); - ArrayList optionsCopy = result.getOptionsList(); - for (Iterator iter = optionsCopy.iterator(); iter.hasNext();) { - String option = (String) iter.next(); + ArrayList<String> newOptions = new ArrayList<>(); + ArrayList<String> optionsCopy = result.getOptionsList(); + for (String option: optionsCopy) { if (option.startsWith("-")) { newOptions.add("!" + option.substring(1)); } else { @@ -325,9 +323,9 @@ public class FlatSuiteReader implements SFileReader.Maker { * @param lastFile default file for source location if the input does not specify * @return List */ - private List makeMessages(// XXX weak - also support expected exceptions, etc. + private List<Message> makeMessages(// XXX weak - also support expected exceptions, etc. Kind kind, String[] words, int start, File lastFile) { - ArrayList result = new ArrayList(); + ArrayList<Message> result = new ArrayList<>(); for (int i = start; i < words.length; i++) { ISourceLocation sl = BridgeUtil.makeSourceLocation(words[i], lastFile); @@ -340,7 +338,7 @@ public class FlatSuiteReader implements SFileReader.Maker { result.add(new Message(text, kind, null, sl)); } } - return (0 == result.size() ? Collections.EMPTY_LIST : result); + return (0 == result.size() ? Collections.<Message>emptyList() : result); } /** |