diff options
author | Andy Clement <aclement@pivotal.io> | 2016-11-07 13:04:55 -0800 |
---|---|---|
committer | Andy Clement <aclement@pivotal.io> | 2016-11-07 13:04:55 -0800 |
commit | de34df77ea7f7372894cf1e2352766118a798e98 (patch) | |
tree | e0d75970e19c61af1ba204810ee1ebebbd1e8166 /build | |
parent | 64c97807a20105644f604fe9b5263acdb63bd41d (diff) | |
download | aspectj-de34df77ea7f7372894cf1e2352766118a798e98.tar.gz aspectj-de34df77ea7f7372894cf1e2352766118a798e98.zip |
Upgraded to new JDT compiler - neon.1 and a bit
Diffstat (limited to 'build')
12 files changed, 133 insertions, 139 deletions
diff --git a/build/.isJava5 b/build/.isJava5 new file mode 100644 index 000000000..136d06384 --- /dev/null +++ b/build/.isJava5 @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/build/src/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java b/build/src/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java index c1323bb58..253e49fb1 100644 --- a/build/src/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java +++ b/build/src/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java @@ -84,7 +84,7 @@ public class AntBuilder extends Builder { /** * Ensure targets exist for this module and all antecedants, so topoSort can work. */ - private static void makeTargetsForResult(final Result result, final Hashtable targets) { + private static void makeTargetsForResult(final Result result, final Hashtable<String,Target> targets) { final String resultTargetName = resultToTargetName(result); Target target = (Target) targets.get(resultTargetName); if (null == target) { @@ -196,7 +196,7 @@ public class AntBuilder extends Builder { return copy; } - protected void dumpMinFile(Result result, File classesDir, List errors) { + protected void dumpMinFile(Result result, File classesDir, List<String> errors) { String name = result.getName() + "-empty"; File minFile = new File(classesDir, name); FileWriter fw = null; @@ -211,8 +211,8 @@ public class AntBuilder extends Builder { } - protected boolean compile(Result result, File classesDir, boolean useExistingClasses, List errors) { - + @Override + protected boolean compile(Result result, File classesDir, boolean useExistingClasses, List<String> errors) { if (!classesDir.exists() && !classesDir.mkdirs()) { errors.add("compile - unable to create " + classesDir); return false; @@ -224,8 +224,9 @@ public class AntBuilder extends Builder { Path path = new Path(project); boolean hasSourceDirectories = false; boolean isJava5Compile = false; - for (Iterator iter = result.getSrcDirs().iterator(); iter.hasNext();) { - File file = (File) iter.next(); + for (File file: result.getSrcDirs()) { +// for (Iterator iter = result.getSrcDirs().iterator(); iter.hasNext();) { +// File file = (File) iter.next(); path.createPathElement().setLocation(file); if (!isJava5Compile && (Util.Constants.JAVA5_SRC.equals(file.getName()) || Util.Constants.JAVA5_TESTSRC.equals(file.getName()) || new File( @@ -268,8 +269,8 @@ public class AntBuilder extends Builder { javac.setTarget("1.1"); // 1.1 class files - Javac in 1.4 uses 1.4 javac.setSource("1.3"); } else { - javac.setSource("1.5"); - javac.setTarget("1.5"); + javac.setSource("1.8"); + javac.setTarget("1.8"); } // compile boolean passed = false; @@ -330,7 +331,8 @@ public class AntBuilder extends Builder { * Merge classes directory and any merge jars into module jar with any specified manifest file. META-INF directories are * excluded. */ - protected boolean assemble(Result result, File classesDir, List errors) { + @Override + protected boolean assemble(Result result, File classesDir, List<String> errors) { if (!buildingEnabled) { return false; } @@ -400,18 +402,18 @@ public class AntBuilder extends Builder { * @see org.aspectj.internal.tools.build.Builder#buildAntecedants(Module) */ protected Result[] getAntecedantResults(Result moduleResult) { - Hashtable targets = new Hashtable(); + Hashtable<String,Target> targets = new Hashtable<>(); makeTargetsForResult(moduleResult, targets); String targetName = resultToTargetName(moduleResult); // bug: doc says topoSort returns String, but returns Target - Collection result = project.topoSort(targetName, targets); + Collection<Target> result = project.topoSort(targetName, targets); // fyi, we don't rely on topoSort to detect cycles - see buildAll int size = result.size(); if (0 == result.size()) { return new Result[0]; } - ArrayList toReturn = new ArrayList(); - for (Iterator iter = result.iterator(); iter.hasNext();) { + ArrayList<String> toReturn = new ArrayList<>(); + for (Iterator<Target> iter = result.iterator(); iter.hasNext();) { Target target = (Target) iter.next(); String name = target.getName(); if (null == name) { @@ -450,11 +452,10 @@ public class AntBuilder extends Builder { zip.setDestFile(result.getOutputFile()); ZipFileSet zipfileset = null; final Module module = result.getModule(); - List known = result.findJarRequirements(); + List<File> known = result.findJarRequirements(); removeLibraryFilesToSkip(module, known); // -- merge any antecedents, less any manifest - for (Iterator iter = known.iterator(); iter.hasNext();) { - File jarFile = (File) iter.next(); + for (File jarFile: known) { zipfileset = new ZipFileSet(); zipfileset.setProject(project); zipfileset.setSrc(jarFile); @@ -541,8 +542,7 @@ public class AntBuilder extends Builder { /** @return true if aspectjrt.jar is on classpath */ private static boolean runtimeJarOnClasspath(Result result) { - for (Iterator iter = result.getLibJars().iterator(); iter.hasNext();) { - File file = (File) iter.next(); + for (File file: result.getLibJars()) { if ("aspectjrt.jar".equals(file.getName())) { return true; } @@ -582,6 +582,7 @@ public class AntBuilder extends Builder { * @param runtimeJar the Path to the aspectjrt.jar * @return javac or another Task invoking the AspectJ compiler */ + @SuppressWarnings("unchecked") static Task aspectJTask(Javac javac, Path toolsJar, Path runtimeJar) { Object task = null; String url = null; diff --git a/build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java b/build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java index 0cefa7952..819673cff 100644 --- a/build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java +++ b/build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java @@ -54,7 +54,7 @@ public class Checklics extends MatchingTask { public static final String EPL_CPL_IBM_PARC_XEROX_OTHERS_TAG = "epl-cpl-ibm|parc|xerox|vmware|others"; public static final String DEFAULT = EPL_CPL_IBM_PARC_XEROX_OTHERS_TAG; - static final Map LICENSES; // unmodifiable Map + static final Map<String,License> LICENSES; // unmodifiable Map static { final String CONTRIBUTORS = "Contributors"; @@ -82,7 +82,7 @@ public class Checklics extends MatchingTask { License MPL_ONLY = new License(MPL_ONLY_TAG, LIC_MPL); License MPL_PARC = new License(MPL_PARC_TAG, LIC_MPL, PARC); License PARC_COPYRIGHT = new License(PARC_COPYRIGHT_TAG, null, PARC); - LICENSES = new Hashtable(); + LICENSES = new Hashtable<>(); LICENSES.put(APL.tag, APL); LICENSES.put(MPL.tag, MPL); LICENSES.put(MPL_PARC.tag, MPL_PARC); @@ -458,11 +458,11 @@ class HeaderInfo { /** last line of license */ public final boolean hasLicense; - public HeaderInfo(File file, int lastLine, List years, boolean hasLicense) { + public HeaderInfo(File file, int lastLine, List<String> years, boolean hasLicense) { this.lastLine = lastLine; this.file = file; this.hasLicense = hasLicense; - List newYears = new ArrayList(); + List<String> newYears = new ArrayList<>(); newYears.addAll(years); Collections.sort(newYears); this.years = Collections.unmodifiableList(newYears); @@ -610,7 +610,7 @@ class Header { } public static HeaderInfo checkFile(final File file) { - ArrayList years = new ArrayList(); + ArrayList<String> years = new ArrayList<>(); int endLine = 0; BufferedReader input = null; int lineNum = 0; @@ -647,7 +647,7 @@ class Header { * * @return true if this line has end-of-comment */ - private static boolean checkLine(String line, ArrayList years) { + private static boolean checkLine(String line, ArrayList<String> years) { if ((null == line) || (0 == line.length())) { return false; } diff --git a/build/src/org/aspectj/internal/tools/ant/taskdefs/ConditionalTask.java b/build/src/org/aspectj/internal/tools/ant/taskdefs/ConditionalTask.java index 99ab1ab44..7a9092352 100644 --- a/build/src/org/aspectj/internal/tools/ant/taskdefs/ConditionalTask.java +++ b/build/src/org/aspectj/internal/tools/ant/taskdefs/ConditionalTask.java @@ -25,9 +25,9 @@ public abstract class ConditionalTask extends Task { public final static String TRUE = "true"; - private List ifs; - protected List ifs() { - return ifs != null ? ifs : (ifs = new Vector()); + private List<If> ifs; + protected List<If> ifs() { + return ifs != null ? ifs : (ifs = new Vector<If>()); } public If createIf() { @@ -166,9 +166,9 @@ public abstract class ConditionalTask extends Task { return getFalses().size() == 0; } - protected List getFalses() { - Iterator iter = ifs().iterator(); - List result = new Vector(); + protected List<String> getFalses() { + Iterator<If> iter = ifs().iterator(); + List<String> result = new Vector<>(); while (iter.hasNext()) { If next = (If) iter.next(); String name = next.getName(); diff --git a/build/src/org/aspectj/internal/tools/build/Builder.java b/build/src/org/aspectj/internal/tools/build/Builder.java index 2bd49ac61..4fe47ced4 100644 --- a/build/src/org/aspectj/internal/tools/build/Builder.java +++ b/build/src/org/aspectj/internal/tools/build/Builder.java @@ -104,14 +104,14 @@ public abstract class Builder { private static final String SKIP_LIBRARIES_KEY = "skip.libraries"; /** List (String) names of libraries to skip during assembly */ - private static final List SKIP_LIBRARIES; + private static final List<String> SKIP_LIBRARIES; private static final String ERROR_KEY = "error loading properties"; private static final Properties PROPS; static { PROPS = new Properties(); - List skips = Collections.EMPTY_LIST; + List<String> skips = Collections.emptyList(); String resourcePattern = "**/*.txt,**/*.rsc,**/*.gif,**/*.properties"; String allPattern = "**/*"; String binarySourcePattern = "**/*.rsc,**/*.gif,**/*.jar,**/*.zip"; @@ -149,7 +149,7 @@ public abstract class Builder { if ((null == text) || (0 == text.length())) { return Collections.EMPTY_LIST; } - List strings = new ArrayList(); + List<String> strings = new ArrayList<>(); StringTokenizer tok = new StringTokenizer(text, ","); while (tok.hasMoreTokens()) { String token = tok.nextToken().trim(); @@ -275,13 +275,13 @@ public abstract class Builder { return buildProduct(buildSpec); } Result result = specifyResultFor(buildSpec); - ArrayList errors = new ArrayList(); + ArrayList<String> errors = new ArrayList<>(); try { return buildAll(result, errors); } finally { if (0 < errors.size()) { String label = "error building " + buildSpec + ": "; - for (Iterator iter = errors.iterator(); iter.hasNext();) { + for (Iterator<String> iter = errors.iterator(); iter.hasNext();) { String m = label + iter.next(); handler.error(m); } @@ -340,7 +340,7 @@ public abstract class Builder { */ protected final boolean buildAll(Result result, List errors) { Result[] buildList = skipUptodate(getAntecedantResults(result)); - ArrayList doneList = new ArrayList(); + ArrayList<String> doneList = new ArrayList<>(); if ((null != buildList) && (0 < buildList.length)) { if (isLogging()) { handler.log("modules to build: " + Arrays.asList(buildList)); @@ -371,7 +371,7 @@ public abstract class Builder { * the List sink for errors, if any * @return false after successful build, when module jar should exist */ - protected final boolean buildOnly(Result result, List errors) { + protected final boolean buildOnly(Result result, List<String> errors) { if (!result.outOfDate()) { return true; } @@ -545,7 +545,7 @@ public abstract class Builder { * deliverables. */ protected ProductModule[] discoverModules(File productDir, Modules modules) { - final ArrayList found = new ArrayList(); + final ArrayList<File> found = new ArrayList<>(); FileFilter filter = new FileFilter() {// empty jar files public boolean accept(File file) { if ((null != file) && file.canRead() @@ -557,9 +557,8 @@ public abstract class Builder { } }; Util.visitFiles(productDir, filter); - ArrayList results = new ArrayList(); - for (Iterator iter = found.iterator(); iter.hasNext();) { - File file = (File) iter.next(); + ArrayList<ProductModule> results = new ArrayList<>(); + for (File file: found) { String jarName = moduleAliasFor(file.getName().toLowerCase()); if (jarName.endsWith(".jar") || jarName.endsWith(".zip")) { // XXXFileLiteral jarName = jarName.substring(0, jarName.length() - 4); @@ -625,7 +624,7 @@ public abstract class Builder { * the List to add error messages to */ abstract protected boolean compile(Result result, File classesDir, - boolean useExistingClasses, List errors); + boolean useExistingClasses, List<String> errors); /** * Assemble the module distribution from the classesDir, saving String @@ -634,7 +633,7 @@ public abstract class Builder { * @see #removeLibraryFilesToSkip(Module, File) */ abstract protected boolean assemble(Result result, File classesDir, - List errors); + List<String> errors); /** * Assemble the module distribution from the classesDir and all diff --git a/build/src/org/aspectj/internal/tools/build/Module.java b/build/src/org/aspectj/internal/tools/build/Module.java index 02209e22e..8df660e2a 100644 --- a/build/src/org/aspectj/internal/tools/build/Module.java +++ b/build/src/org/aspectj/internal/tools/build/Module.java @@ -68,13 +68,13 @@ public class Module { } /** @return all source files under srcDir */ - private static Iterator sourceFiles(File srcDir) { - ArrayList result = new ArrayList(); + private static Iterator<File> sourceFiles(File srcDir) { + ArrayList<File> result = new ArrayList<>(); sourceFiles(srcDir, result); return result.iterator(); } - private static void sourceFiles(File srcDir, List result) { + private static void sourceFiles(File srcDir, List<File> result) { if ((null == srcDir) || !srcDir.canRead() || !srcDir.isDirectory()) { return; } @@ -88,9 +88,8 @@ public class Module { } } - private static void addIfNew(List source, List sink) { - for (Iterator iter = source.iterator(); iter.hasNext();) { - Object item = iter.next(); + private static void addIfNew(List<File> source, List<File> sink) { + for (File item: source) { if (!sink.contains(item)) { sink.add(item); } @@ -102,7 +101,7 @@ public class Module { * * @see findKnownJarAntecedants() */ - static void doFindJarRequirements(Result result, List known) { + static void doFindJarRequirements(Result result, List<File> known) { Util.iaxIfNull(result, "result"); Util.iaxIfNull(known, "known"); addIfNew(result.getLibJars(), known); @@ -170,25 +169,25 @@ public class Module { private final File moduleJar; /** File list of library jars */ - private final List libJars; + private final List<File> libJars; - /** String list of classpath variables */ - private final List classpathVariables; + /** List of classpath variables */ + private final List<String> classpathVariables; /** - * File list of library jars exported to clients (duplicates some libJars + * List of library jars exported to clients (duplicates some libJars * entries) */ - private final List exportedLibJars; + private final List<File> exportedLibJars; /** File list of source directories */ - private final List srcDirs; + private final List<File> srcDirs; /** properties from the modules {name}.properties file */ private final Properties properties; - /** Module list of required modules */ - private final List requiredModules; + /** List of required modules */ + private final List<Module> requiredModules; /** logger */ private final Messager messager; @@ -200,11 +199,11 @@ public class Module { Util.iaxIfNull(name, "name"); Util.iaxIfNull(modules, "modules"); this.moduleDir = moduleDir; - this.libJars = new ArrayList(); - this.exportedLibJars = new ArrayList(); - this.requiredModules = new ArrayList(); - this.srcDirs = new ArrayList(); - this.classpathVariables = new ArrayList(); + this.libJars = new ArrayList<>(); + this.exportedLibJars = new ArrayList<>(); + this.requiredModules = new ArrayList<>(); + this.srcDirs = new ArrayList<>(); + this.classpathVariables = new ArrayList<>(); this.properties = new Properties(); this.name = name; this.modules = modules; @@ -239,10 +238,10 @@ public class Module { } final long time = outputFile.lastModified(); File file; - for (Iterator iter = result.getSrcDirs().iterator(); iter.hasNext();) { - File srcDir = (File) iter.next(); - for (Iterator srcFiles = sourceFiles(srcDir); srcFiles.hasNext();) { - file = (File) srcFiles.next(); + for (Iterator<File> iter = result.getSrcDirs().iterator(); iter.hasNext();) { + File srcDir = iter.next(); + for (Iterator<File> srcFiles = sourceFiles(srcDir); srcFiles.hasNext();) { + file = srcFiles.next(); if (outOfDate(time, file)) { return true; } @@ -284,23 +283,27 @@ public class Module { : (kind.normal ? release : test); } - List srcDirs(Result result) { + List<File> srcDirs(Result result) { myResult(result); return srcDirs; } - List libJars(Result result) { + + List<File> libJars(Result result) { myResult(result); return libJars; } - List classpathVariables(Result result) { + + List<String> classpathVariables(Result result) { myResult(result); return classpathVariables; } - List exportedLibJars(Result result) { + + List<File> exportedLibJars(Result result) { myResult(result); return exportedLibJars; } - List requiredModules(Result result) { + + List<Module> requiredModules(Result result) { myResult(result); return requiredModules; } @@ -610,7 +613,7 @@ public class Module { String[] tokenize(String line) { final String DELIM = " \n\t\\<>\"="; StringTokenizer st = new StringTokenizer(line, DELIM, true); - ArrayList result = new ArrayList(); + ArrayList<String> result = new ArrayList<>(); StringBuffer quote = new StringBuffer(); boolean inQuote = false; while (st.hasMoreTokens()) { diff --git a/build/src/org/aspectj/internal/tools/build/Modules.java b/build/src/org/aspectj/internal/tools/build/Modules.java index 49391fe68..ca2b50aac 100644 --- a/build/src/org/aspectj/internal/tools/build/Modules.java +++ b/build/src/org/aspectj/internal/tools/build/Modules.java @@ -24,7 +24,7 @@ import java.util.Hashtable; */ public class Modules { - private final Hashtable modules = new Hashtable(); + private final Hashtable<String,Module> modules = new Hashtable<>(); public final File baseDir; public final File jarDir; private final Messager handler; diff --git a/build/src/org/aspectj/internal/tools/build/Result.java b/build/src/org/aspectj/internal/tools/build/Result.java index 672ba561b..3b5a4e141 100644 --- a/build/src/org/aspectj/internal/tools/build/Result.java +++ b/build/src/org/aspectj/internal/tools/build/Result.java @@ -40,7 +40,7 @@ public class Result { private static final Kind[] KINDS = { RELEASE, TEST, RELEASE_ALL, TEST_ALL }; - private static final HashMap nameToResult = new HashMap(); + private static final HashMap<String,Result> nameToResult = new HashMap<>(); public static boolean isTestingJar(String name) { name = name.toLowerCase(); @@ -141,25 +141,25 @@ public class Result { /** path to output jar - may not exist */ private final File outputFile; - /** list of required Result */ - private final List requiredResults; + /** List of required Result */ + private final List<Result> requiredResults; - /** File list of library jars */ - private final List libJars; + /** List of library jars */ + private final List<File> libJars; - /** String list of classpath variables */ - private final List classpathVariables; + /** List of classpath variables */ + private final List<String> classpathVariables; transient String toLongString; /** - * File list of library jars exported to clients (duplicates some libJars + * List of library jars exported to clients (duplicates some libJars * entries) */ - private final List exportedLibJars; + private final List<File> exportedLibJars; - /** File list of source directories */ - private final List srcDirs; + /** List of source directories */ + private final List<File> srcDirs; /** true if this has calculated List fields. */ private boolean requiredDone; @@ -179,11 +179,11 @@ public class Result { Result(Kind kind, Module module, File jarDir) { this.kind = kind; this.module = module; - this.libJars = new ArrayList(); - this.exportedLibJars = new ArrayList(); - this.srcDirs = new ArrayList(); - this.classpathVariables = new ArrayList(); - this.requiredResults = new ArrayList(); + this.libJars = new ArrayList<>(); + this.exportedLibJars = new ArrayList<>(); + this.srcDirs = new ArrayList<>(); + this.classpathVariables = new ArrayList<>(); + this.requiredResults = new ArrayList<>(); String name = module.name; if (!kind.normal) { name += "-test"; @@ -218,14 +218,14 @@ public class Result { } /** @return List (File) of jar's required */ - public List findJarRequirements() { - ArrayList result = new ArrayList(); + public List<File> findJarRequirements() { + ArrayList<File> result = new ArrayList<>(); Module.doFindJarRequirements(this, result); return result; } /** @return unmodifiable List of String classpath variables */ - public List getClasspathVariables() { + public List<String> getClasspathVariables() { return safeList(classpathVariables); } @@ -238,14 +238,14 @@ public class Result { /** * @return unmodifiable list of exported library files, guaranteed readable */ - public List getExportedLibJars() { + public List<File> getExportedLibJars() { return safeList(exportedLibJars); } /** * @return unmodifiable list of required library files, guaranteed readable */ - public List getLibJars() { + public List<File> getLibJars() { requiredDone(); return safeList(libJars); } @@ -258,7 +258,7 @@ public class Result { // return safeList(merges); // } /** @return unmodifiable list of source directories, guaranteed readable */ - public List getSrcDirs() { + public List<File> getSrcDirs() { return safeList(srcDirs); } @@ -283,12 +283,12 @@ public class Result { return name; } - private List safeList(List l) { + private <T> List<T> safeList(List<T> l) { requiredDone(); return Collections.unmodifiableList(l); } - private Result[] safeResults(List list) { + private Result[] safeResults(List<Result> list) { requiredDone(); if (null == list) { return new Result[0]; @@ -300,8 +300,8 @@ public class Result { srcDirs.addAll(getModule().srcDirs(this)); if (getKind().normal) { // trim testing source directories - for (ListIterator iter = srcDirs.listIterator(); iter.hasNext();) { - File srcDir = (File) iter.next(); + for (ListIterator<File> iter = srcDirs.listIterator(); iter.hasNext();) { + File srcDir = iter.next(); if (isTestingDir(srcDir.getName())) { iter.remove(); } @@ -313,8 +313,8 @@ public class Result { libJars.addAll(getModule().libJars(this)); if (getKind().normal && !isTestingModule(getModule())) { // trim testing libraries - for (ListIterator iter = libJars.listIterator(); iter.hasNext();) { - File libJar = (File) iter.next(); + for (ListIterator<File> iter = libJars.listIterator(); iter.hasNext();) { + File libJar = iter.next(); if (isTestingJar(libJar.getName())) { iter.remove(); } @@ -348,10 +348,9 @@ public class Result { assertKind(RELEASE); } // externally-required: - List modules = module.requiredModules(this); + List<Module> modules = module.requiredModules(this); final boolean adoptTests = !kind.normal || isTestingModule(module); - for (Iterator iter = modules.iterator(); iter.hasNext();) { - Module required = (Module) iter.next(); + for (Module required: modules) { if (adoptTests) { // testing builds can rely on other release and test results requiredResults.add(required.getResult(TEST)); diff --git a/build/src/org/aspectj/internal/tools/build/SampleGatherer.java b/build/src/org/aspectj/internal/tools/build/SampleGatherer.java index f95b43b5b..a9d29af6b 100644 --- a/build/src/org/aspectj/internal/tools/build/SampleGatherer.java +++ b/build/src/org/aspectj/internal/tools/build/SampleGatherer.java @@ -268,10 +268,8 @@ class Sample { public static final String ASPECTJ_TEAM = "The AspectJ Team"; /** sort by anchorName, file path, and start/end location */ - static Comparator NAME_SOURCE_COMPARER = new Comparator() { - public int compare(Object lhs, Object rhs) { - Sample left = (Sample) lhs; - Sample right = (Sample) rhs; + static Comparator<Sample> NAME_SOURCE_COMPARER = new Comparator<Sample>() { + public int compare(Sample left, Sample right) { if (null == left) { return (null == right ? 0 : -1); } @@ -295,10 +293,8 @@ class Sample { }; /** sort by author, then NAME_SOURCE_COMPARER */ - static Comparator AUTHOR_NAME_SOURCE_COMPARER = new Comparator() { - public int compare(Object lhs, Object rhs) { - Sample left = (Sample) lhs; - Sample right = (Sample) rhs; + static Comparator<Sample> AUTHOR_NAME_SOURCE_COMPARER = new Comparator<Sample>() { + public int compare(Sample left, Sample right) { if (null == left) { return (null == right ? 0 : -1); } @@ -309,7 +305,7 @@ class Sample { if (0 != result) { return result; } - return NAME_SOURCE_COMPARER.compare(lhs, rhs); + return NAME_SOURCE_COMPARER.compare(left,right); } }; @@ -395,7 +391,7 @@ class Sample { * type-safe Collection of samples. */ class Samples { - private ArrayList samples = new ArrayList(); + private ArrayList<Sample> samples = new ArrayList<>(); int size() { return samples.size(); } @@ -405,12 +401,12 @@ class Samples { /** * @return List copy, sorted by Sample.NAME_SOURCE_COMPARER */ - List getSortedSamples() { + List<Sample> getSortedSamples() { return getSortedSamples(Sample.NAME_SOURCE_COMPARER); } - List getSortedSamples(Comparator comparer) { - ArrayList result = new ArrayList(); + List<Sample> getSortedSamples(Comparator<Sample> comparer) { + ArrayList<Sample> result = new ArrayList<>(); result.addAll(samples); Collections.sort(result, comparer); return result; @@ -961,7 +957,7 @@ class SampleUtil { } public static String[] splitAnchorName(String anchorName) { - ArrayList result = new ArrayList(); + ArrayList<String> result = new ArrayList<>(); int start = 0; int loc = anchorName.indexOf("-", start); String next; diff --git a/build/testsrc/org/aspectj/build/BuildModuleTests.java b/build/testsrc/org/aspectj/build/BuildModuleTests.java index bfc6b58cc..073cf0f39 100644 --- a/build/testsrc/org/aspectj/build/BuildModuleTests.java +++ b/build/testsrc/org/aspectj/build/BuildModuleTests.java @@ -27,7 +27,6 @@ import java.io.FileFilter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.StringTokenizer; @@ -62,7 +61,7 @@ public class BuildModuleTests extends TestCase { return null; // use permissive default } - final static List SOURCE_NAMES = Collections.unmodifiableList( + final static List<String> SOURCE_NAMES = Collections.unmodifiableList( Arrays.asList(new String[]{"src", "testsrc", "java5-src", "java5-testsrc", "aspectj-src"})); /** @@ -70,9 +69,8 @@ public class BuildModuleTests extends TestCase { * @return */ private static File[] findSourceRoots(File moduleDir) { - ArrayList result = new ArrayList(); - for (Iterator iter = SOURCE_NAMES.iterator(); iter.hasNext();) { - String name = (String) iter.next(); + ArrayList<File> result = new ArrayList<>(); + for (String name: SOURCE_NAMES) { File srcDir = new File(moduleDir, name); if (srcDir.canRead() && srcDir.isDirectory()) { result.add(srcDir); @@ -219,12 +217,12 @@ public class BuildModuleTests extends TestCase { */ static class UnknownFileCheck implements FileFilter { private static final UnknownFileCheck SINGLETON = new UnknownFileCheck(); - private static final ArrayList STATIC_ERRORS = new ArrayList(); + private static final ArrayList<String> STATIC_ERRORS = new ArrayList<>(); // Builder.BINARY_SOURCE_PATTERN and Builder.RESOURCE_PATTERN - public static final List KNOWN_SUFFIXES; + public static final List<String> KNOWN_SUFFIXES; static { - List suffixes = new ArrayList(); + List<String> suffixes = new ArrayList<>(); // sources from org.aspectj.util.FileUtil.SOURCE_SUFFIXES suffixes.add(".aj"); suffixes.add(".java"); @@ -278,8 +276,7 @@ public class BuildModuleTests extends TestCase { return false; } // to do not accepting uppercase suffixes... - for (Iterator iter = KNOWN_SUFFIXES.iterator(); iter.hasNext();) { - String suffix = (String) iter.next(); + for (String suffix: KNOWN_SUFFIXES) { if (name.endsWith(suffix)) { return false; } @@ -287,7 +284,7 @@ public class BuildModuleTests extends TestCase { return true; } - void unknownFiles(File dir, ArrayList results) { + void unknownFiles(File dir, ArrayList<File> results) { File[] files = dir.listFiles(this); for (int j = 0; j < files.length; j++) { File file = files[j]; diff --git a/build/testsrc/org/aspectj/internal/build/BuildModuleTest.java b/build/testsrc/org/aspectj/internal/build/BuildModuleTest.java index d513c1b71..d0dfb55f2 100644 --- a/build/testsrc/org/aspectj/internal/build/BuildModuleTest.java +++ b/build/testsrc/org/aspectj/internal/build/BuildModuleTest.java @@ -80,7 +80,7 @@ public class BuildModuleTest extends TestCase { } } - ArrayList tempFiles = new ArrayList(); + ArrayList<File> tempFiles = new ArrayList<>(); private File jarDir; private boolean deleteJars; boolean building; // must be enabled for tests to run diff --git a/build/testsrc/org/aspectj/internal/build/ModulesTest.java b/build/testsrc/org/aspectj/internal/build/ModulesTest.java index c482950c6..0478c44c2 100644 --- a/build/testsrc/org/aspectj/internal/build/ModulesTest.java +++ b/build/testsrc/org/aspectj/internal/build/ModulesTest.java @@ -41,7 +41,7 @@ import org.aspectj.internal.tools.build.Result.Kind; * */ public class ModulesTest extends TestCase { - public static final List /*String*/ MODULE_NAMES; + public static final List<String> MODULE_NAMES; private static final File BASE_DIR = new File(".."); static { String[] names = { @@ -49,7 +49,7 @@ public class ModulesTest extends TestCase { "bridge", "loadtime", "loadtime5", "org.aspectj.ajdt.core", "runtime", "taskdefs", "testing-client", "testing-util", "tests", "util", "weaver"}; - List list = Arrays.asList(names); + List<String> list = Arrays.asList(names); MODULE_NAMES = Collections.unmodifiableList(list); } @@ -80,7 +80,7 @@ public class ModulesTest extends TestCase { protected void tearDown() throws Exception { super.tearDown(); - for (Iterator iter = tempFiles.iterator(); iter.hasNext();) { + for (Iterator<File> iter = tempFiles.iterator(); iter.hasNext();) { File file = (File) iter.next(); if (!ModulesTest.delete(file)) { System.err.println("warning: ModulesTest unable to delete " + file); @@ -101,9 +101,8 @@ public class ModulesTest extends TestCase { } public void testAllModulesCreation() { - ArrayList badModules = new ArrayList(); - for (Iterator iter = MODULE_NAMES.iterator(); iter.hasNext();) { - String name = (String) iter.next(); + ArrayList<Module> badModules = new ArrayList<>(); + for (String name: MODULE_NAMES) { File dir = new File(BASE_DIR, name); if (dir.isDirectory()) { File classpath = new File(dir, ".classpath"); @@ -118,8 +117,7 @@ public class ModulesTest extends TestCase { } if (!badModules.isEmpty()) { StringBuffer sb = new StringBuffer(); - for (Iterator iter = badModules.iterator(); iter.hasNext();) { - Module module = (Module) iter.next(); + for (Module module: badModules) { System.err.println(module.toLongString()); sb.append("\n"); sb.append(module); |