diff options
author | Andy Clement <aclement@pivotal.io> | 2017-09-21 10:48:59 -0700 |
---|---|---|
committer | Andy Clement <aclement@pivotal.io> | 2017-09-21 10:48:59 -0700 |
commit | 26712118bad08e60c66237e6aa2cfbd6f275cbbe (patch) | |
tree | 64531f485c94c9f6e7f1acb8506bf51cc8343cf1 | |
parent | 39b70af69b0b086f82da8ac032de5e5a5e0cdc45 (diff) | |
parent | 6d6738cfece6328027916681e67e54225531db38 (diff) | |
download | aspectj-26712118bad08e60c66237e6aa2cfbd6f275cbbe.tar.gz aspectj-26712118bad08e60c66237e6aa2cfbd6f275cbbe.zip |
Bring Java9 branch in line with 1.8.11 progress
124 files changed, 1483 insertions, 604 deletions
diff --git a/ajde/src/org/aspectj/ajde/Ajde.java b/ajde/src/org/aspectj/ajde/Ajde.java index bd1e77f42..2e25e50fc 100644 --- a/ajde/src/org/aspectj/ajde/Ajde.java +++ b/ajde/src/org/aspectj/ajde/Ajde.java @@ -101,7 +101,7 @@ public class Ajde { INSTANCE.compilerConfig = compilerConfig; INSTANCE.uiBuildMsgHandler = uiBuildMessageHandler; INSTANCE.buildProgressMonitor = monitor; - INSTANCE.asm = AsmManager.createNewStructureModel(Collections.EMPTY_MAP); + INSTANCE.asm = AsmManager.createNewStructureModel(Collections.<File,String>emptyMap()); INSTANCE.iconRegistry = iconRegistry; INSTANCE.ideUIAdapter = ideUIAdapter; diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java index 42e8254cc..144b4e478 100644 --- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java +++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java @@ -14,12 +14,8 @@ import java.io.File; import java.util.List; -import org.aspectj.util.FileUtil; import org.aspectj.util.LangUtil; -//import com.sun.org.apache.xml.internal.serializer.utils.Utils; - - /** * A long way to go until full coverage, but this is the place to add more. * diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/MethodGen.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/MethodGen.java index 59cf7397e..3938beb35 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/MethodGen.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/MethodGen.java @@ -880,9 +880,19 @@ public class MethodGen extends FieldGenOrMethodGen { } /** - * Compute maximum number of local variables. + * Compute maximum number of local variables based on the parameter count and bytecode usage of variables. */ public void setMaxLocals() { + setMaxLocals(false); + } + + /** + * Compute maximum number of local variables. + * + * @param respectLocalVariableTable if true and the local variable table indicates more are in use + * than the code suggests, respect the higher value from the local variable table data. + */ + public void setMaxLocals(boolean respectLocalVariableTable) { if (il != null) { int max = isStatic() ? 0 : 1; @@ -903,10 +913,13 @@ public class MethodGen extends FieldGenOrMethodGen { } } } - - maxLocals = max; + if (!respectLocalVariableTable || max > maxLocals) { + maxLocals = max; + } } else { - maxLocals = 0; + if (!respectLocalVariableTable) { + maxLocals = 0; + } } } @@ -1069,7 +1082,7 @@ public class MethodGen extends FieldGenOrMethodGen { /** * Return a list of AnnotationGen objects representing parameter annotations */ - public List getAnnotationsOnParameter(int i) { + public List<AnnotationGen> getAnnotationsOnParameter(int i) { ensureExistingParameterAnnotationsUnpacked(); if (!hasParameterAnnotations || i > parameterTypes.length) { return null; diff --git a/bcel-builder/src/org/aspectj/apache/bcel/util/NonCachingClassLoaderRepository.java b/bcel-builder/src/org/aspectj/apache/bcel/util/NonCachingClassLoaderRepository.java index 7a8c06224..a53b9dc35 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/util/NonCachingClassLoaderRepository.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/util/NonCachingClassLoaderRepository.java @@ -85,7 +85,7 @@ public class NonCachingClassLoaderRepository implements Repository { private static java.lang.ClassLoader bootClassLoader = null; private final ClassLoaderReference loaderRef; - private final Map<String, JavaClass> loadedClasses = new SoftHashMap(); // CLASSNAME X JAVACLASS + private final Map<String, JavaClass> loadedClasses = new SoftHashMap(); public static class SoftHashMap extends AbstractMap { private Map<Object, SpecialValue> map; @@ -96,10 +96,10 @@ public class NonCachingClassLoaderRepository implements Repository { } public SoftHashMap() { - this(new HashMap()); + this(new HashMap<Object,SpecialValue>()); } - public SoftHashMap(Map map, boolean b) { + public SoftHashMap(Map<Object,SpecialValue> map, boolean b) { this(map); } diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ParameterAnnotationsTest.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ParameterAnnotationsTest.java index 7dd83ddb7..093a4b6e4 100644 --- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ParameterAnnotationsTest.java +++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ParameterAnnotationsTest.java @@ -262,7 +262,7 @@ public class ParameterAnnotationsTest extends BcelTestCase { mg = new MethodGen(m,clg.getClassName(),clg.getConstantPool()); List<Attribute> as = mg.getAttributes(); assertTrue("Should be 2 (RIPA and RVPA) but there are "+mg.getAttributes().size(),mg.getAttributes().size()==2); - List l = mg.getAnnotationsOnParameter(0); + List<AnnotationGen> l = mg.getAnnotationsOnParameter(0); assertTrue("Should be 2 annotations on first parameter but there is only "+l.size()+":"+l.toString(), l.size()==2); assertTrue("Should be 0 but there are "+mg.getAttributes().size(),mg.getAttributes().size()==0); diff --git a/bridge/src/org/aspectj/bridge/Version.java b/bridge/src/org/aspectj/bridge/Version.java index 028cdd96d..835127c75 100644 --- a/bridge/src/org/aspectj/bridge/Version.java +++ b/bridge/src/org/aspectj/bridge/Version.java @@ -37,13 +37,13 @@ public class Version { * Time text set by build script using SIMPLE_DATE_FORMAT. * (if DEVELOPMENT version, invalid) */ - public static final String time_text = ""; + public static final String time_text = "Friday Nov 18, 2016 at 16:34:52 GMT"; /** * time in seconds-since-... format, used by programmatic clients. * (if DEVELOPMENT version, NOTIME) */ - private static long time = -1; // -1 = uninitialized + private static long time = -1; // -1 == uninitialized /** format used by build script to set time_text */ public static final String SIMPLE_DATE_FORMAT = "EEEE MMM d, yyyy 'at' HH:mm:ss z"; diff --git a/bridge/src/org/aspectj/bridge/context/PinpointingMessageHandler.java b/bridge/src/org/aspectj/bridge/context/PinpointingMessageHandler.java index d9465c322..c54ff6789 100644 --- a/bridge/src/org/aspectj/bridge/context/PinpointingMessageHandler.java +++ b/bridge/src/org/aspectj/bridge/context/PinpointingMessageHandler.java @@ -102,15 +102,14 @@ public class PinpointingMessageHandler implements IMessageHandler { public Throwable getThrown() { return delegate.getThrown();} public ISourceLocation getSourceLocation() { return delegate.getSourceLocation();} public String getDetails() { return delegate.getDetails();} - public List getExtraSourceLocations() { return delegate.getExtraSourceLocations();} + public List<ISourceLocation> getExtraSourceLocations() { return delegate.getExtraSourceLocations();} } - - private static class MessageIssued extends RuntimeException { - private static final long serialVersionUID = 1L; - public String getMessage() { - return "message issued..."; - } - } + private static class MessageIssued extends RuntimeException { + private static final long serialVersionUID = 1L; + public String getMessage() { + return "message issued..."; + } + } } 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..aeb9b11b7 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,14 +224,20 @@ 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(); + boolean isJava8Compile = false; + 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( - file.getParent(), ".isJava5").exists())) { + && (Util.Constants.JAVA5_SRC.equals(file.getName()) || + Util.Constants.JAVA5_TESTSRC.equals(file.getName()) || + new File(file.getParent(), ".isJava5").exists())) { isJava5Compile = true; } + if (new File(file.getParent(),".isJava8").exists()) { + isJava8Compile = true; + } if (!hasSourceDirectories) { hasSourceDirectories = true; } @@ -268,8 +274,14 @@ 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"); + if (isJava8Compile) { + javac.setSource("1.8"); + javac.setTarget("1.8"); + } else { + // min + javac.setSource("1.6"); + javac.setTarget("1.6"); + } } // compile boolean passed = false; @@ -330,7 +342,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 +413,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 +463,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 +553,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 +593,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..c05ee23ba 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); @@ -338,7 +338,8 @@ public class Checklics extends MatchingTask { public static class License { /** acceptable years for copyright prefix to company - append " " */ static final String[] YEARS = // remove older after license xfer? - new String[] { "2002 ", "2003 ", "2004 ", "2005", "2006", "2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014", "2015", "2001 ", "2000 ", + new String[] { "2002 ", "2003 ", "2004 ", "2005", "2006", "2007", "2008", + "2009", "2010", "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2001 ", "2000 ", "1999 " }; public final String tag; public final String license; @@ -458,11 +459,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 +611,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 +648,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..6c2e63dc4 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); @@ -198,7 +196,7 @@ public class BuildModuleTests extends TestCase { // separate check to verify all file types (suffixes) are known if (!"testsrc".equals(srcDir.getName())) { - ArrayList unknownFiles = new ArrayList(); + ArrayList<File> unknownFiles = new ArrayList<>(); UnknownFileCheck.SINGLETON.unknownFiles(srcDir, unknownFiles); if (!unknownFiles.isEmpty()) { String s = "unknown files (see readme-build-module.html to " @@ -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..c06e678e2 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 @@ -343,7 +343,7 @@ public class BuildModuleTest extends TestCase { try { zipFile = new ZipFile(weaverAllJar); Enumeration e = zipFile.entries(); - ArrayList entryNames = new ArrayList(); + ArrayList<String> entryNames = new ArrayList<>(); while (e.hasMoreElements()) { ZipEntry entry = (ZipEntry) e.nextElement(); String name = entry.getName(); diff --git a/build/testsrc/org/aspectj/internal/build/ModulesTest.java b/build/testsrc/org/aspectj/internal/build/ModulesTest.java index c482950c6..51a58142a 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); } @@ -72,7 +72,7 @@ public class ModulesTest extends TestCase { } } - ArrayList tempFiles = new ArrayList(); + ArrayList<File> tempFiles = new ArrayList<>(); public ModulesTest(String name) { super(name); @@ -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); diff --git a/docs/dist/doc/README-1810.html b/docs/dist/doc/README-1810.html new file mode 100644 index 000000000..73e88069b --- /dev/null +++ b/docs/dist/doc/README-1810.html @@ -0,0 +1,48 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> <head> +<title>AspectJ 1.8.10 Readme</title> +<style type="text/css"> +<!-- + P { margin-left: 20px; } + PRE { margin-left: 20px; } + LI { margin-left: 20px; } + H4 { margin-left: 20px; } + H3 { margin-left: 10px; } +--> +</style> +</head> + +<body> +<div align="right"><small> +© Copyright 2016 Contributors. +All rights reserved. +</small></div> + +<h1>AspectJ 1.8.10 Readme</h1> + +<p>The full list of resolved issues in 1.8.10 is available +<a href="https://bugs.eclipse.org/bugs/buglist.cgi?query_format=advanced;bug_status=RESOLVED;bug_status=VERIFIED;bug_status=CLOSED;product=AspectJ;target_milestone=1.8.10;">here</a></h2>.</p> + +<ul> +<li>1.8.10 available 9-Dec-2016 +</ul> + +<h2>Notable changes</h2> + +<h4>JDT Upgrade</h4> +<p>The JDT compiler inside AspectJ has been upgraded to the Eclipse Neon.2 level (JDT commit #75dbfad0).</p> + +<h4>Java8</h4> +<p>The Eclipse JDT compiler embedded inside AspectJ now requires Java 8, so that is the minimum required level to compile sources with AspectJ. +However, if only doing weaving and no compilation then it is possible to use Java 7. + +<h4>Annotation style around advice and proceed (<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=500035">Bug 500035</a>)</h4> +<p>A long standing issue that has been lurking in the handling of arguments passed to proceed for annotation style +aspects has been fixed. If, at a joinpoint where 'this'/'target' differ (for example at some call joinpoints), the pointcut +bound either 'this' or 'target' (but not both), then the system would still expect the advice to pass both 'this' and 'target' into the proceed +call. With the fix here you only need to pass what you bind. So if you bind only 'this' you don't need to pass 'target' (and vice versa). +This will affect users that have been working around this quirk by passing both 'this' and 'target'. That isn't necessary anymore. +This fix is in aspectjrt.jar so you will need to be using the 1.8.10 version of aspectjrt.jar at runtime to pickup this change. +<!-- ============================== --> +</body> +</html> diff --git a/docs/dist/doc/index.html b/docs/dist/doc/index.html index 513dc12db..b42262a1a 100644 --- a/docs/dist/doc/index.html +++ b/docs/dist/doc/index.html @@ -138,7 +138,8 @@ <tr> <td>README's </td> <td>Changes and porting guide for AspectJ - <a href="README-189.html">1.8.8</a>, + <a href="README-1810.html">1.8.10</a>, + <a href="README-189.html">1.8.9</a>, <a href="README-188.html">1.8.8</a>, <a href="README-187.html">1.8.7</a>, <a href="README-186.html">1.8.6</a>, diff --git a/lib/aspectj/lib/aspectjrt.jar b/lib/aspectj/lib/aspectjrt.jar Binary files differindex 536f947e6..ef06aa7fd 100644 --- a/lib/aspectj/lib/aspectjrt.jar +++ b/lib/aspectj/lib/aspectjrt.jar diff --git a/lib/bcel/bcel-src.zip b/lib/bcel/bcel-src.zip Binary files differdeleted file mode 100644 index 867d115a4..000000000 --- a/lib/bcel/bcel-src.zip +++ /dev/null diff --git a/lib/bcel/bcel-verifier-src.zip b/lib/bcel/bcel-verifier-src.zip Binary files differdeleted file mode 100644 index 9d58d629c..000000000 --- a/lib/bcel/bcel-verifier-src.zip +++ /dev/null diff --git a/lib/bcel/bcel-verifier.jar b/lib/bcel/bcel-verifier.jar Binary files differdeleted file mode 100644 index f2305a98a..000000000 --- a/lib/bcel/bcel-verifier.jar +++ /dev/null diff --git a/lib/bcel/bcel.jar b/lib/bcel/bcel.jar Binary files differdeleted file mode 100644 index 6cc389190..000000000 --- a/lib/bcel/bcel.jar +++ /dev/null diff --git a/lib/build/build.jar b/lib/build/build.jar Binary files differindex d08b25042..8a6f93714 100644 --- a/lib/build/build.jar +++ b/lib/build/build.jar diff --git a/lib/build/build.old.jar b/lib/build/build.old.jar Binary files differnew file mode 100644 index 000000000..d08b25042 --- /dev/null +++ b/lib/build/build.old.jar diff --git a/lib/test/aspectjrt.jar b/lib/test/aspectjrt.jar Binary files differindex 536f947e6..ef06aa7fd 100644 --- a/lib/test/aspectjrt.jar +++ b/lib/test/aspectjrt.jar diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/messages.properties b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/messages.properties index e6e2cff5f..afdc56f35 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/messages.properties +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/messages.properties @@ -5,7 +5,7 @@ org/aspectj/weaver/XlintDefault.properties for the default behavior and a template to copy. ### AspectJ-specific messages compiler.name = AspectJ Compiler 1.9.0 -compiler.version = Eclipse Compiler BETA_JAVA9_3798415d74984, 3.13 +compiler.version = Eclipse Compiler BETA_JAVA9_062ac5d7a6bf9(Sep2017), 3.13 compiler.copyright = diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java index 5bf9946da..70083874f 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java @@ -188,6 +188,7 @@ public class AccessForInlineVisitor extends ASTVisitor { } FieldBinding ret = new InlineAccessFieldBinding(inAspect, binding, m); inAspect.accessForInline.put(m, ret); + System.out.println(">>"+m); return ret; } diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java index 162bd7bc9..8db8e6076 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java @@ -65,7 +65,7 @@ public class AdviceDeclaration extends AjMethodDeclaration { public int adviceSequenceNumberInType; public MethodBinding proceedMethodBinding; // set during this.resolveStaments, referenced by Proceed - public List proceedCalls = new ArrayList(2); // populated during Proceed.findEnclosingAround + public List<Proceed> proceedCalls = new ArrayList<Proceed>(2); // populated during Proceed.findEnclosingAround private boolean proceedInInners; private ResolvedMember[] proceedCallSignatures; diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeFieldBinding.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeFieldBinding.java index 14f08f79a..c71d8e821 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeFieldBinding.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeFieldBinding.java @@ -60,6 +60,9 @@ public class InterTypeFieldBinding extends FieldBinding { // System.out.println("receiver: " + receiverType + ", " + invocationType); ReferenceBinding declaringType = declaringClass; + if (invocationType == null) // static import call + return !isPrivate() && scope.getCurrentPackage() == receiverType.getPackage(); + // FIXME asc what about parameterized types and private ITD generic fields on interfaces? // Don't work with a raw type, work with the generic type diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMemberFinder.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMemberFinder.java index 97221b2aa..9784710f4 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMemberFinder.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMemberFinder.java @@ -16,8 +16,10 @@ package org.aspectj.ajdt.internal.compiler.lookup; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Set; import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation; import org.aspectj.org.eclipse.jdt.core.compiler.IProblem; @@ -298,7 +300,7 @@ public class InterTypeMemberFinder implements IMemberFinder { return orig; } - List ret = new ArrayList(Arrays.asList(orig)); + Set<MethodBinding> ret = new HashSet<MethodBinding>(Arrays.asList(orig)); // System.err.println("declared method: " + ret + " inters = " + interTypeMethods); for (int i = 0, len = interTypeMethods.size(); i < len; i++) { diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BinaryFormsTestCase.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BinaryFormsTestCase.java index f5ce49600..7da775d70 100644 --- a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BinaryFormsTestCase.java +++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BinaryFormsTestCase.java @@ -32,7 +32,7 @@ public class BinaryFormsTestCase extends CommandTestCase { public void testJar1() throws IOException { String library = getSandboxName() + "/lib.jar"; - List<String> args = new ArrayList(); + List<String> args = new ArrayList<>(); args.add("-outjar"); args.add(library); diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjCompilerOptionsTest.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjCompilerOptionsTest.java index 818bee537..1e94e300a 100644 --- a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjCompilerOptionsTest.java +++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjCompilerOptionsTest.java @@ -46,9 +46,9 @@ public class AjCompilerOptionsTest extends TestCase { assertFalse(options.generateEmacsSymFiles); assertFalse(options.noAtAspectJProcessing); - Map map = options.getMap(); + Map<String,String> map = options.getMap(); assertEquals(CompilerOptions.WARNING,map.get(AjCompilerOptions.OPTION_ReportInvalidAbsoluteTypeName)); - assertEquals(CompilerOptions.IGNORE,map.get(AjCompilerOptions.OPTION_ReportInvalidWildcardTypeName)); + assertEquals(CompilerOptions.WARNING,map.get(AjCompilerOptions.OPTION_ReportInvalidWildcardTypeName)); assertEquals(CompilerOptions.WARNING,map.get(AjCompilerOptions.OPTION_ReportUnresolvableMember)); assertEquals(CompilerOptions.WARNING,map.get(AjCompilerOptions.OPTION_ReportTypeNotExposedToWeaver)); assertEquals(CompilerOptions.IGNORE,map.get(AjCompilerOptions.OPTION_ReportShadowNotInStructure)); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/World.java b/org.aspectj.matcher/src/org/aspectj/weaver/World.java index 31b978028..8af6cc528 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/World.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/World.java @@ -1293,7 +1293,7 @@ public abstract class World implements Dump.INode { if (!memoryProfiling) { return; } - Reference r = null; + Reference<? extends ResolvedType> r = null; while ((r=rq.poll()) != null) { collectedTypes++; } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ArgsPointcut.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ArgsPointcut.java index 4898a92b5..56b1a4dc5 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ArgsPointcut.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ArgsPointcut.java @@ -57,7 +57,7 @@ public class ArgsPointcut extends NameBindingPointcut { return arguments; } - public Pointcut parameterizeWith(Map typeVariableMap, World w) { + public Pointcut parameterizeWith(Map<String,UnresolvedType> typeVariableMap, World w) { ArgsPointcut ret = new ArgsPointcut(this.arguments.parameterizeWith(typeVariableMap, w)); ret.copyLocationFrom(this); return ret; @@ -114,7 +114,6 @@ public class ArgsPointcut extends NameBindingPointcut { argumentsToMatchAgainst = argsSubset; } } - return argumentsToMatchAgainst; } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareParents.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareParents.java index c11967fca..cf6ffbaab 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareParents.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareParents.java @@ -319,9 +319,9 @@ public class DeclareParents extends Declare { } ResolvedType newParentGenericType = newParent.getGenericType(); - Iterator iter = typeToVerify.getDirectSupertypes(); + Iterator<ResolvedType> iter = typeToVerify.getDirectSupertypes(); while (iter.hasNext()) { - ResolvedType supertype = (ResolvedType) iter.next(); + ResolvedType supertype = iter.next(); if (((supertype.isRawType() && newParent.isParameterizedType()) || (supertype.isParameterizedType() && newParent .isRawType())) && newParentGenericType.equals(supertype.getGenericType())) { diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegate.java b/org.aspectj.matcher/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegate.java index 6110e6ceb..2aa83c957 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegate.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegate.java @@ -23,6 +23,7 @@ import java.util.Collections; import org.aspectj.weaver.AjAttribute.WeaverVersionInfo; import org.aspectj.weaver.AnnotationAJ; import org.aspectj.weaver.AnnotationTargetKind; +import org.aspectj.weaver.ConcreteTypeMunger; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ReferenceType; import org.aspectj.weaver.ReferenceTypeDelegate; @@ -34,6 +35,7 @@ import org.aspectj.weaver.UnresolvedType; import org.aspectj.weaver.WeakClassLoaderReference; import org.aspectj.weaver.WeaverStateInfo; import org.aspectj.weaver.World; +import org.aspectj.weaver.patterns.Declare; import org.aspectj.weaver.patterns.PerClause; /** @@ -62,7 +64,7 @@ public class ReflectionBasedReferenceTypeDelegate implements ReferenceTypeDelega public ReflectionBasedReferenceTypeDelegate() { } - public void initialize(ReferenceType aType, Class aClass, ClassLoader aClassLoader, World aWorld) { + public void initialize(ReferenceType aType, Class<?> aClass, ClassLoader aClassLoader, World aWorld) { this.myClass = aClass; this.resolvedType = aType; this.world = aWorld; @@ -302,22 +304,12 @@ public class ReflectionBasedReferenceTypeDelegate implements ReferenceTypeDelega return null; } - /* - * (non-Javadoc) - * - * @see org.aspectj.weaver.ReferenceTypeDelegate#getDeclares() - */ - public Collection getDeclares() { - // no declares - return Collections.EMPTY_SET; + public Collection<Declare> getDeclares() { + return Collections.emptySet(); } - /* - * @see org.aspectj.weaver.ReferenceTypeDelegate#getTypeMungers() - */ - public Collection getTypeMungers() { - // no type mungers - return Collections.EMPTY_SET; + public Collection<ConcreteTypeMunger> getTypeMungers() { + return Collections.emptySet(); } /* @@ -363,29 +355,14 @@ public class ReflectionBasedReferenceTypeDelegate implements ReferenceTypeDelega return null; } - /* - * (non-Javadoc) - * - * @see org.aspectj.weaver.ReferenceTypeDelegate#getResolvedTypeX() - */ public ReferenceType getResolvedTypeX() { return this.resolvedType; } - /* - * (non-Javadoc) - * - * @see org.aspectj.weaver.ReferenceTypeDelegate#doesNotExposeShadowMungers() - */ public boolean doesNotExposeShadowMungers() { return false; } - /* - * (non-Javadoc) - * - * @see org.aspectj.weaver.ReferenceTypeDelegate#getDeclaredGenericSignature() - */ public String getDeclaredGenericSignature() { // no generic sig in 1.4 return null; diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/tools/AbstractTrace.java b/org.aspectj.matcher/src/org/aspectj/weaver/tools/AbstractTrace.java index c736de886..52217f880 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/tools/AbstractTrace.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/tools/AbstractTrace.java @@ -166,11 +166,11 @@ public abstract class AbstractTrace implements Trace { } } - protected String formatArray (Object obj) { + protected String formatArray(Object obj) { return obj.getClass().getComponentType().getName() + "[" + Array.getLength(obj) + "]"; } - protected String formatCollection (Collection c) { + protected String formatCollection(Collection<?> c) { return c.getClass().getName() + "(" + c.size() + ")"; } diff --git a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/VisitorTestCase.java b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/VisitorTestCase.java index 40d39359e..7fd131528 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/VisitorTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/VisitorTestCase.java @@ -15,7 +15,6 @@ import junit.framework.TestCase; import java.util.HashSet; import java.util.Set; -import java.util.Iterator; import java.io.LineNumberReader; import java.io.FileReader; @@ -28,8 +27,8 @@ import org.aspectj.weaver.patterns.TypePattern; */ public class VisitorTestCase extends TestCase { - private Set pointcuts = new HashSet(); - private Set typePatterns = new HashSet(); + private Set<String> pointcuts = new HashSet<>(); + private Set<String> typePatterns = new HashSet<>(); protected void setUp() throws Exception { super.setUp(); @@ -41,7 +40,7 @@ public class VisitorTestCase extends TestCase { rt.close(); } - private void feed(LineNumberReader r, Set set) throws Exception { + private void feed(LineNumberReader r, Set<String> set) throws Exception { for (String line = r.readLine(); line != null; line = r.readLine()) { set.add(line); } @@ -51,8 +50,7 @@ public class VisitorTestCase extends TestCase { if (pointcuts.isEmpty()) { fail("Empty pointcuts file!"); } - for (Iterator iterator = pointcuts.iterator(); iterator.hasNext();) { - String pointcut = (String) iterator.next(); + for (String pointcut: pointcuts) { try { DumpPointcutVisitor.check(pointcut); } catch (Throwable t) { @@ -66,8 +64,7 @@ public class VisitorTestCase extends TestCase { if (typePatterns.isEmpty()) { fail("Empty typePatterns file!"); } - for (Iterator iterator = typePatterns.iterator(); iterator.hasNext();) { - String tp = (String) iterator.next(); + for (String tp: typePatterns) { try { TypePattern p = new PatternParser(tp).parseTypePattern(); DumpPointcutVisitor.check(p, true); diff --git a/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip b/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip Binary files differdeleted file mode 100644 index 8780c1822..000000000 --- a/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip +++ /dev/null diff --git a/org.eclipse.jdt.core/jdtcore-for-aspectj.jar b/org.eclipse.jdt.core/jdtcore-for-aspectj.jar Binary files differdeleted file mode 100644 index 0582957c4..000000000 --- a/org.eclipse.jdt.core/jdtcore-for-aspectj.jar +++ /dev/null diff --git a/runtime/src/org/aspectj/runtime/reflect/JoinPointImpl.java b/runtime/src/org/aspectj/runtime/reflect/JoinPointImpl.java index cae6cf577..69bff1e3c 100644 --- a/runtime/src/org/aspectj/runtime/reflect/JoinPointImpl.java +++ b/runtime/src/org/aspectj/runtime/reflect/JoinPointImpl.java @@ -197,9 +197,17 @@ class JoinPointImpl implements ProceedingJoinPoint { } else { // need to replace the target, and it is different to this, whether // that means replacing state[0] or state[1] depends on whether - // the join point has a this - firstArgumentIndexIntoAdviceBindings = (hasThis ? 1 : 0) + 1; - state[hasThis ? 1 : 0] = adviceBindings[hasThis ? 1 : 0]; + // the join point has a this + + // This previous variant doesn't seem to cope with only binding target at a joinpoint + // which has both this and target. It forces you to supply this even if you didn't bind + // it. +// firstArgumentIndexIntoAdviceBindings = (hasThis ? 1 : 0) + 1; +// state[hasThis ? 1 : 0] = adviceBindings[hasThis ? 1 : 0]; + + int targetPositionInAdviceBindings = (hasThis && bindsThis) ? 1 : 0; + firstArgumentIndexIntoAdviceBindings = ((hasThis&&bindsThis)?1:0)+((hasTarget&&bindsTarget&&!thisTargetTheSame)?1:0); + state[hasThis ? 1 : 0] = adviceBindings[targetPositionInAdviceBindings]; } } else { // leave state[0]/state[1] alone, they are OK diff --git a/testing-client/.isJava5 b/testing-client/.isJava5 new file mode 100644 index 000000000..136d06384 --- /dev/null +++ b/testing-client/.isJava5 @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/testing-client/src/org/aspectj/testing/Tester.java b/testing-client/src/org/aspectj/testing/Tester.java index afd37a492..500c4c363 100644 --- a/testing-client/src/org/aspectj/testing/Tester.java +++ b/testing-client/src/org/aspectj/testing/Tester.java @@ -51,10 +51,10 @@ public class Tester { private static Set notes; /** <code>List</code> to hold events submitted. */ - private static List actualEvents = new ArrayList(); + private static List<String> actualEvents = new ArrayList<>(); /** <code>List</code> to hold events we expect. */ - private static List expectedEvents = new ArrayList(); + private static List<String> expectedEvents = new ArrayList<>(); static { setBASEDIR(new File(".")); @@ -103,8 +103,8 @@ public class Tester { /** XXX deprecated #clear() */ public static void clearEvents() { - actualEvents = new ArrayList(); - expectedEvents = new ArrayList(); + actualEvents = new ArrayList<>(); + expectedEvents = new ArrayList<>(); } @@ -707,10 +707,10 @@ public class Tester { } /** @return String[] of differences '{un}expected msg "..." {not} found' */ - private static String[] diffIgnoreDups(Collection set, String[] expected, String msg, + private static String[] diffIgnoreDups(Collection<String> set, String[] expected, String msg, boolean ignoreDups) { - ArrayList result = new ArrayList(); - ArrayList actual = new ArrayList(set); + ArrayList<String> result = new ArrayList<>(); + ArrayList<String> actual = new ArrayList<>(set); BitSet hits = new BitSet(); for (int i = 0; i < expected.length; i++) { if (!actual.remove(expected[i])) { @@ -722,8 +722,7 @@ public class Tester { } } } - for (Iterator iter = actual.iterator(); iter.hasNext();) { - String act = (String) iter.next(); + for (String act: actual) { result.add(" unexpected " + msg + " \"" + act + "\" found"); } return (String[]) result.toArray(new String[0]); diff --git a/testing-client/src/org/aspectj/testing/server/TestServer.java b/testing-client/src/org/aspectj/testing/server/TestServer.java index b7b0d762b..12e8d097e 100644 --- a/testing-client/src/org/aspectj/testing/server/TestServer.java +++ b/testing-client/src/org/aspectj/testing/server/TestServer.java @@ -32,7 +32,7 @@ public class TestServer implements Runnable { private boolean exitOnError = true; private File workingDirectory; private ClassLoader rootLoader; - private Map loaders = new HashMap(); + private Map<String,ClassLoader> loaders = new HashMap<>(); private String mainClass = "UnknownClass"; private String mainLoader = "UnknownLoader"; @@ -75,7 +75,7 @@ public class TestServer implements Runnable { if (parent == null) error("No such loader: " + parentName); } - List urlList = new ArrayList(); + List<URL> urlList = new ArrayList<>(); st = new StringTokenizer(classpath,";"); while (st.hasMoreTokens()) { String fileName = st.nextToken(); @@ -93,7 +93,7 @@ public class TestServer implements Runnable { } private void createRootLoader () throws IOException { - List urlList = new ArrayList(); + List<URL> urlList = new ArrayList(); /* Sandbox */ URL url = workingDirectory.getCanonicalFile().toURL(); diff --git a/testing-client/testsrc/org/aspectj/testing/TesterTest.java b/testing-client/testsrc/org/aspectj/testing/TesterTest.java index c2fceb81a..d538a63f7 100644 --- a/testing-client/testsrc/org/aspectj/testing/TesterTest.java +++ b/testing-client/testsrc/org/aspectj/testing/TesterTest.java @@ -167,8 +167,8 @@ public class TesterTest extends TestCase { * @author isberg */ public static class MyTestReporter implements IMessageHandler { - public ArrayList failures = new ArrayList(); - public ArrayList passes = new ArrayList(); + public ArrayList<IMessage> failures = new ArrayList<>(); + public ArrayList<IMessage> passes = new ArrayList<>(); public void clear() { failures.clear(); @@ -188,9 +188,8 @@ public class TesterTest extends TestCase { return gotItem(failures, substring); } - boolean gotItem(List list, String substring) { - for (Iterator iterator = list.iterator(); iterator.hasNext(); ) { - IMessage element = (IMessage) iterator.next(); + boolean gotItem(List<IMessage> list, String substring) { + for (IMessage element: list) { String s = element.getMessage(); if ((null != s) && (-1 != s.indexOf(substring))) { return true; diff --git a/testing/newsrc/org/aspectj/testing/XMLBasedAjcTestCase.java b/testing/newsrc/org/aspectj/testing/XMLBasedAjcTestCase.java index 6705a5847..18b9233dc 100644 --- a/testing/newsrc/org/aspectj/testing/XMLBasedAjcTestCase.java +++ b/testing/newsrc/org/aspectj/testing/XMLBasedAjcTestCase.java @@ -24,10 +24,6 @@ import java.util.List; import java.util.Map; import java.util.Stack; -import junit.extensions.TestSetup; -import junit.framework.Test; -import junit.framework.TestSuite; - import org.apache.commons.digester.Digester; import org.aspectj.apache.bcel.classfile.Attribute; import org.aspectj.apache.bcel.classfile.JavaClass; @@ -39,6 +35,12 @@ import org.aspectj.apache.bcel.util.SyntheticRepository; import org.aspectj.tools.ajc.AjcTestCase; import org.aspectj.tools.ajc.CompilationResult; import org.aspectj.util.FileUtil; +import org.aspectj.weaver.ResolvedMember; +import org.aspectj.weaver.ResolvedType; + +import junit.extensions.TestSetup; +import junit.framework.Test; +import junit.framework.TestSuite; /** * Root class for all Test suites that are based on an AspectJ XML test suite file. Extends AjcTestCase allowing a mix of @@ -463,5 +465,23 @@ public abstract class XMLBasedAjcTestCase extends AjcTestCase { return new File(getClass().getResource(resourceName).getFile()); } + protected Method findMethod(JavaClass jc, String string) { + for (Method m : jc.getMethods()) { + if (m.getName().equals(string)) { + return m; + } + } + return null; + } + + protected ResolvedMember findMethod(ResolvedType outerType, String string) { + for (ResolvedMember method: outerType.getDeclaredMethods()) { + if (method.getName().equals(string)) { + return method; + } + } + return null; + } + } 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..8fb274176 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,29 +807,28 @@ 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); + int testsetCounter = 1; + for (Iterator<Testset> iter = testsets.iterator(); iter.hasNext(); testsetCounter++) { + 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); - final String startStr = "Testset " + _ + " of " + testsets.size(); - String str = startStr + " / Combo " + _ + " of " + argcombos.size(); + List<Arg> args = argcombo.remove(0); + final String startStr = "Testset " + testsetCounter + " of " + testsets.size(); + String str = startStr + " / Combo " + testsetCounter + " of " + argcombos.size(); log("---------- " + str + " ----------"); execute(testset, args); } @@ -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); } /** diff --git a/tests/bugs1810/500035/Code.java b/tests/bugs1810/500035/Code.java new file mode 100644 index 000000000..58e738da4 --- /dev/null +++ b/tests/bugs1810/500035/Code.java @@ -0,0 +1,30 @@ +import org.aspectj.lang.annotation.*; +import org.aspectj.lang.*; + +@Aspect +public class Code { + + @Around(value = "args(regex, replacement) && target(targetObject) " + + "&& call(public String String.replaceFirst(String, String)) " +//, argNames = "proceedingJoinPoint,targetObject,regex,replacement,thisJoinPoint" +) + public String replaceFirstAspect(ProceedingJoinPoint proceedingJoinPoint, String targetObject, String regex, String replacement) throws Throwable { +System.out.println("targetObject = "+targetObject); +System.out.println("regex = "+regex); +System.out.println("replacement = "+replacement); + String returnObject = (String) proceedingJoinPoint.proceed(new Object[]{ targetObject, regex, replacement}); + return returnObject; + } + + + public static void main(String []argv) { + new Code().run(); + } + + public void run() { + String s = "hello"; + s = s.replaceFirst("l","7"); + System.out.println(s); + } + +} diff --git a/tests/bugs1810/500035/Code2.java b/tests/bugs1810/500035/Code2.java new file mode 100644 index 000000000..23eddce7e --- /dev/null +++ b/tests/bugs1810/500035/Code2.java @@ -0,0 +1,30 @@ +import org.aspectj.lang.annotation.*; +import org.aspectj.lang.*; + +@Aspect +public class Code2 { + + @Around(value = "args(regex, replacement) && target(targetObject) " + + "&& call(public String String.replaceFirst(String, String)) && this(c)" +//, argNames = "proceedingJoinPoint,targetObject,regex,replacement,thisJoinPoint" +) + public String replaceFirstAspect(ProceedingJoinPoint proceedingJoinPoint, Code2 c, String targetObject, String regex, String replacement) throws Throwable { +System.out.println("targetObject = "+targetObject); +System.out.println("regex = "+regex); +System.out.println("replacement = "+replacement); + String returnObject = (String) proceedingJoinPoint.proceed(new Object[]{ c, targetObject, regex, replacement}); + return returnObject; + } + + + public static void main(String []argv) { + new Code2().run(); + } + + public void run() { + String s = "hello"; + s = s.replaceFirst("l","8"); + System.out.println(s); + } + +} diff --git a/tests/bugs1810/500035/Code3.java b/tests/bugs1810/500035/Code3.java new file mode 100644 index 000000000..48f672991 --- /dev/null +++ b/tests/bugs1810/500035/Code3.java @@ -0,0 +1,76 @@ +import org.aspectj.lang.annotation.*; +import org.aspectj.lang.*; + +@Aspect +public class Code3 { + + @Around(value = "args(s) && target(targeto) && call(* Foo.run1(String))") + public void first(ProceedingJoinPoint proceedingJoinPoint, Foo targeto, String s) throws Throwable { + System.out.println("first: binding target, just passing everything through: target=Foo(1)"); + proceedingJoinPoint.proceed(new Object[]{ targeto, s}); + } + + @Around(value = "args(s) && this(thiso) && target(targeto) && call(* run2(String))") + public void second(ProceedingJoinPoint proceedingJoinPoint, Foo thiso, Foo targeto, String s) throws Throwable { + System.out.println("second: binding this and target, just passing everything through: this=Foo(0) target=Foo(1)"); + proceedingJoinPoint.proceed(new Object[]{ thiso, targeto, s}); + } + + @Around(value = "args(s) && this(thiso) && call(* run3(String))") + public void third(ProceedingJoinPoint proceedingJoinPoint, Foo thiso, String s) throws Throwable { + System.out.println("third: binding this, just passing everything through: this=Foo(0)"); + proceedingJoinPoint.proceed(new Object[]{ thiso, s}); + } + + @Around(value = "args(s) && this(thiso) && call(* run4(String))") + public void fourth(ProceedingJoinPoint proceedingJoinPoint, Foo thiso, String s) throws Throwable { + System.out.println("fourth: binding this, switching from Foo(0) to Foo(3)"); + proceedingJoinPoint.proceed(new Object[]{ new Foo(3), s}); + } + + @Around(value = "args(s) && target(targeto) && call(* run5(String))") + public void fifth(ProceedingJoinPoint proceedingJoinPoint, Foo targeto, String s) throws Throwable { + System.out.println("fifth: binding target, switching from Foo(1) to Foo(4)"); + proceedingJoinPoint.proceed(new Object[]{ new Foo(4), s}); + } + + @Around(value = "args(s) && this(thiso) && target(targeto) && call(* run6(String))") + public void sixth(ProceedingJoinPoint proceedingJoinPoint, Foo thiso, Foo targeto, String s) throws Throwable { + System.out.println("sixth: binding this and target, switching them around (before this=Foo(0) target=Foo(1))"); + proceedingJoinPoint.proceed(new Object[]{ targeto, thiso, s}); + } + + public static void main(String []argv) { + new Foo(0).execute1(); + new Foo(0).execute2(); + new Foo(0).execute3(); + new Foo(0).execute4(); + new Foo(0).execute5(); + new Foo(0).execute6(); + } +} + +class Foo { + int i; + public Foo(int i) { + this.i = i; + } + + public void execute1() { new Foo(1).run1("abc"); } + public void execute2() { new Foo(1).run2("abc"); } + public void execute3() { new Foo(1).run3("abc"); } + public void execute4() { new Foo(1).run4("abc"); } + public void execute5() { new Foo(1).run5("abc"); } + public void execute6() { new Foo(1).run6("abc"); } + + public void run1(String s) { System.out.println("Executing run("+s+") on "+this.toString()); } + public void run2(String s) { System.out.println("Executing run("+s+") on "+this.toString()); } + public void run3(String s) { System.out.println("Executing run("+s+") on "+this.toString()); } + public void run4(String s) { System.out.println("Executing run("+s+") on "+this.toString()); } + public void run5(String s) { System.out.println("Executing run("+s+") on "+this.toString()); } + public void run6(String s) { System.out.println("Executing run("+s+") on "+this.toString()); } + + public String toString() { + return ("Foo(i="+i+")"); + } +} diff --git a/tests/bugs1810/500035/Code4.java b/tests/bugs1810/500035/Code4.java new file mode 100644 index 000000000..176ce2011 --- /dev/null +++ b/tests/bugs1810/500035/Code4.java @@ -0,0 +1,35 @@ +import org.aspectj.lang.annotation.*; +import org.aspectj.lang.*; + +public aspect Code4 { + + void around(Foo targeto, String s): call(* Foo.run(String)) && args(s) && target(targeto) { + System.out.println("first: binding target, just passing everything through"); + proceed(targeto, s); + } + + public static void main(String []argv) { + new Foo(0).execute(); + } +} + +class Foo { + int i; + public Foo(int i) { + this.i = i; + } + + public void execute() { + Foo f1 = new Foo(1); + Foo f2 = new Foo(2); + f1.run("abc"); + } + + public void run(String s) { + System.out.println("Executing run("+s+") on "+this.toString()); + } + + public String toString() { + return ("Foo(i="+i+")"); + } +} diff --git a/tests/bugs1810/501656/ApplicationException.java b/tests/bugs1810/501656/ApplicationException.java new file mode 100644 index 000000000..5392eeaef --- /dev/null +++ b/tests/bugs1810/501656/ApplicationException.java @@ -0,0 +1,9 @@ +package com.myapp; + +public class ApplicationException extends Exception { + private static final long serialVersionUID = 1L; + + public ApplicationException(String message) { + super(message); + } +} diff --git a/tests/bugs1810/501656/ApplicationExceptionHandler.java b/tests/bugs1810/501656/ApplicationExceptionHandler.java new file mode 100644 index 000000000..bd96e1c27 --- /dev/null +++ b/tests/bugs1810/501656/ApplicationExceptionHandler.java @@ -0,0 +1,17 @@ +package com.myapp.aspect; + +import org.aspectj.lang.annotation.AfterThrowing; +import org.aspectj.lang.annotation.Aspect; + +import com.myapp.ApplicationException; + +@Aspect +public abstract class ApplicationExceptionHandler<EX extends ApplicationException> { + @AfterThrowing( + pointcut = "execution(* com.myapp.*.facade.*.*(..))", + throwing = "exception" +, argNames="exception" + ) + public abstract void handleFacadeException(EX exception); + +} diff --git a/tests/bugs1810/501656/Code.java b/tests/bugs1810/501656/Code.java new file mode 100644 index 000000000..c8e603a9e --- /dev/null +++ b/tests/bugs1810/501656/Code.java @@ -0,0 +1,4 @@ +public abstract class Code { + public void m(String str1) {} + public abstract void m2(String str2); +} diff --git a/tests/bugs1810/501656/out/com/myapp/ApplicationException.class b/tests/bugs1810/501656/out/com/myapp/ApplicationException.class Binary files differnew file mode 100644 index 000000000..fbbbdda19 --- /dev/null +++ b/tests/bugs1810/501656/out/com/myapp/ApplicationException.class diff --git a/tests/bugs1810/502807/TestCollectors.java b/tests/bugs1810/502807/TestCollectors.java new file mode 100644 index 000000000..323fb76ce --- /dev/null +++ b/tests/bugs1810/502807/TestCollectors.java @@ -0,0 +1,36 @@ +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Collectors; + +public class TestCollectors { + Set<Integer> ids; + + public TestCollectors(Set<Inner> inners) { + ids = inners.stream().collect(Collectors.toList(Inner::getId)); +// ids = inners.stream().map(Inner::getId).collect(Collectors.toSet()); + } + + public static void main() { + Set<Inner> inners = new HashSet<>(); + inners.add(new Inner(1, "a")); + inners.add(new Inner(1, "a")); + + new TestCollectors(inners); + } + + + public static class Inner { + private int id; + private String name; + + public Inner(int id, String name) { + this.id = id; + this.name = name; + } + + public int getId() { return id; } + + public String getName() { return name; } + } +} + diff --git a/tests/bugs1810/508661/A_yes.java b/tests/bugs1810/508661/A_yes.java new file mode 100644 index 000000000..9920f069a --- /dev/null +++ b/tests/bugs1810/508661/A_yes.java @@ -0,0 +1,8 @@ +public class A_yes { + @CacheMethodResult + public void m() { + System.out.println("A_yes.m()"); + Class[] itfs = A_yes.class.getInterfaces(); + System.out.println("A_yes has interface? "+((itfs==null||itfs.length==0)?"no":itfs[0].getName())); + } +} diff --git a/tests/bugs1810/508661/B_no.java b/tests/bugs1810/508661/B_no.java new file mode 100644 index 000000000..e65d63377 --- /dev/null +++ b/tests/bugs1810/508661/B_no.java @@ -0,0 +1,7 @@ +class B_no { + public void m() { + System.out.println("B_no.m()"); + Class[] itfs = B_no.class.getInterfaces(); + System.out.println("B_no has interface? "+((itfs==null||itfs.length==0)?"no":itfs[0].getName())); + } +} diff --git a/tests/bugs1810/508661/CacheMethodResult.java b/tests/bugs1810/508661/CacheMethodResult.java new file mode 100644 index 000000000..fd919bd5b --- /dev/null +++ b/tests/bugs1810/508661/CacheMethodResult.java @@ -0,0 +1,4 @@ +import java.lang.annotation.*; + +@Retention(RetentionPolicy.RUNTIME) +@interface CacheMethodResult {} diff --git a/tests/bugs1810/508661/CacheMethodResultAspect.java b/tests/bugs1810/508661/CacheMethodResultAspect.java new file mode 100644 index 000000000..d7626a917 --- /dev/null +++ b/tests/bugs1810/508661/CacheMethodResultAspect.java @@ -0,0 +1,10 @@ +aspect CacheMethodResultAspect perthis(cache()) { + + pointcut cache() : execution(@CacheMethodResult * *.*(..)); + + Object around() : cache() { + System.out.println("around: "+thisJoinPointStaticPart.getSignature()); + return proceed(); + } +} + diff --git a/tests/bugs1810/508661/Run.java b/tests/bugs1810/508661/Run.java new file mode 100644 index 000000000..176e5a499 --- /dev/null +++ b/tests/bugs1810/508661/Run.java @@ -0,0 +1,6 @@ +public class Run { + public static void main(String []argv) { + new A_yes().m(); + new B_no().m(); + } +} diff --git a/tests/bugs1810/508661/aop.xml b/tests/bugs1810/508661/aop.xml new file mode 100644 index 000000000..5b89e6614 --- /dev/null +++ b/tests/bugs1810/508661/aop.xml @@ -0,0 +1,10 @@ +<!DOCTYPE aspectj PUBLIC "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd"> +<aspectj> + <weaver> + </weaver> + + <aspects> + <aspect name="CacheMethodResultAspect" /> + </aspects> + +</aspectj> diff --git a/tests/bugs1810/ambig/Code.java b/tests/bugs1810/ambig/Code.java new file mode 100644 index 000000000..dab8d6f09 --- /dev/null +++ b/tests/bugs1810/ambig/Code.java @@ -0,0 +1,8 @@ +import java.util.List; + +aspect F { void A.xx(List<String> x) { xx(null);this.xx(null);};} +class A {} +class B extends A { void xx(List<String> x) { xx(null); this.xx(null); super.xx(null); }} +class C implements D { public void xx(List<String> x) { xx(null); new A().xx(null); new B().xx(null); }} +interface D { void xx(List<String> x); } +class E { void foo() { new B().xx(null); new A() {}.xx(null); } } diff --git a/tests/bugs1810/ambig/X.java b/tests/bugs1810/ambig/X.java new file mode 100644 index 000000000..6f0a73d97 --- /dev/null +++ b/tests/bugs1810/ambig/X.java @@ -0,0 +1,13 @@ +import java.util.List; + +aspect F { + void A.xx(List<String> x) { } +} +class A { + //void xx(List<String> x) {} +} +class E { + void foo() { + new A() {}.xx(null); + } +} diff --git a/tests/bugs1811/509235/Code.java b/tests/bugs1811/509235/Code.java new file mode 100644 index 000000000..be7bb10e0 --- /dev/null +++ b/tests/bugs1811/509235/Code.java @@ -0,0 +1,17 @@ +public class Code { + public static void main(String []argv) { + foo("fooname"); + bar("crap","barname"); + } + + public static void foo(String username) {} + + public static void bar(String a, String username) { } +} + +aspect X { + before(String username): (execution(public static * foo(..)) && args(username,..)) || + (execution(public static * bar(..)) && args(*,username,..)) { + System.out.println("username = "+username); + } +} diff --git a/tests/bugs1811/509235/Code2.java b/tests/bugs1811/509235/Code2.java new file mode 100644 index 000000000..67765c1cb --- /dev/null +++ b/tests/bugs1811/509235/Code2.java @@ -0,0 +1,17 @@ +public class Code2 { + public static void main(String []argv) { + foo("fooname"); + bar("crap","barname"); + } + + public static void foo(String username) {} + + public static void bar(String a, String username) { } +} + +aspect X { + before(String username): (execution(public static * foo(..)) && args(username)) || + (execution(public static * bar(..)) && args(*,username)) { + System.out.println("username = "+username); + } +} diff --git a/tests/bugs1811/parameterizedWithInner/Code.java b/tests/bugs1811/parameterizedWithInner/Code.java new file mode 100644 index 000000000..182a01d88 --- /dev/null +++ b/tests/bugs1811/parameterizedWithInner/Code.java @@ -0,0 +1,20 @@ +public class Code { + public static void main(String []argv) { + } +} + +class Outer<T> { + class Inner { + T t; + Inner(T t) { + this.t =t ; + } + } + + public Inner m() {return null;} + public Outer<String>.Inner m2() { + Outer<String> os = new Outer<String>(); + return os.new Inner("foo"); + } + public Outer<?>.Inner m3() {return null;} +} diff --git a/tests/multiIncremental/pr404345/base/src/org/Constants.java b/tests/multiIncremental/pr404345/base/src/org/Constants.java new file mode 100644 index 000000000..c09fdf3db --- /dev/null +++ b/tests/multiIncremental/pr404345/base/src/org/Constants.java @@ -0,0 +1,5 @@ +package org; + +public class Constants { + public static final String MISSING="missing"; +} diff --git a/tests/multiIncremental/pr404345/base/src/org/FetchProfile.java b/tests/multiIncremental/pr404345/base/src/org/FetchProfile.java new file mode 100644 index 000000000..5ad345d35 --- /dev/null +++ b/tests/multiIncremental/pr404345/base/src/org/FetchProfile.java @@ -0,0 +1,16 @@ +package org; + +public @interface FetchProfile { + String name(); + FetchProfile.FetchOverride[] fetchOverrides(); + + @interface FetchOverride { + Class<?> entity(); + String association() default ""; + } +} + +//@FetchProfiles({ +//@FetchProfile(name = FetchProfileName.LOCATION, fetchOverrides = { +// @FetchProfile.FetchOverride(entity = Location.class, association = Location.PROPERTY_SYSTEMSTATE), +// @FetchProfile.FetchOverride(entity = Location.class, association = Location.PROPERTY_KEYVAULT) }), diff --git a/tests/multiIncremental/pr404345/base/src/org/FetchProfileName.java b/tests/multiIncremental/pr404345/base/src/org/FetchProfileName.java new file mode 100644 index 000000000..b7d9af0c7 --- /dev/null +++ b/tests/multiIncremental/pr404345/base/src/org/FetchProfileName.java @@ -0,0 +1,5 @@ +package org; + +public class FetchProfileName { + public static final String LOCATION="missing"; +} diff --git a/tests/multiIncremental/pr404345/base/src/org/FetchProfiles.java b/tests/multiIncremental/pr404345/base/src/org/FetchProfiles.java new file mode 100644 index 000000000..bba90b09c --- /dev/null +++ b/tests/multiIncremental/pr404345/base/src/org/FetchProfiles.java @@ -0,0 +1,10 @@ +package org; + +public @interface FetchProfiles { + FetchProfile[] value(); +} + +//@FetchProfiles({ +//@FetchProfile(name = FetchProfileName.LOCATION, fetchOverrides = { +// @FetchProfile.FetchOverride(entity = Location.class, association = Location.PROPERTY_SYSTEMSTATE), +// @FetchProfile.FetchOverride(entity = Location.class, association = Location.PROPERTY_KEYVAULT) }),
\ No newline at end of file diff --git a/tests/multiIncremental/pr404345/base/src/org/package-info.java b/tests/multiIncremental/pr404345/base/src/org/package-info.java new file mode 100644 index 000000000..c1e4ee1b8 --- /dev/null +++ b/tests/multiIncremental/pr404345/base/src/org/package-info.java @@ -0,0 +1,9 @@ +//@FetchProfiles({ + @FetchProfile(name = FetchProfileName.LOCATION, fetchOverrides = { +// @FetchProfile.FetchOverride(entity = Location.class, association = Location.PROPERTY_SYSTEMSTATE), + @FetchProfile.FetchOverride(entity = Location.class, association = Location.PROPERTY_KEYVAULT) +}) +//}) +package org; + + diff --git a/tests/multiIncremental/pr404345/inc1/src/org/Constants.java b/tests/multiIncremental/pr404345/inc1/src/org/Constants.java new file mode 100644 index 000000000..851d68292 --- /dev/null +++ b/tests/multiIncremental/pr404345/inc1/src/org/Constants.java @@ -0,0 +1,3 @@ +package org; +class Constants { +} diff --git a/tests/multiIncremental/pr404345/inc1/src/org/FetchProfileName.java b/tests/multiIncremental/pr404345/inc1/src/org/FetchProfileName.java new file mode 100644 index 000000000..b7d9af0c7 --- /dev/null +++ b/tests/multiIncremental/pr404345/inc1/src/org/FetchProfileName.java @@ -0,0 +1,5 @@ +package org; + +public class FetchProfileName { + public static final String LOCATION="missing"; +} diff --git a/tests/multiIncremental/pr404345/inc2/src/org/package-info.java b/tests/multiIncremental/pr404345/inc2/src/org/package-info.java new file mode 100644 index 000000000..9ffa9f10f --- /dev/null +++ b/tests/multiIncremental/pr404345/inc2/src/org/package-info.java @@ -0,0 +1,2 @@ +@Foo(Constants.MISSING) +package org; diff --git a/tests/src/org/aspectj/systemtest/AllTests18.java b/tests/src/org/aspectj/systemtest/AllTests18.java index 2eadcb823..9c2387b0d 100644 --- a/tests/src/org/aspectj/systemtest/AllTests18.java +++ b/tests/src/org/aspectj/systemtest/AllTests18.java @@ -13,6 +13,7 @@ package org.aspectj.systemtest; import org.aspectj.systemtest.ajc180.AllTestsAspectJ180; import org.aspectj.systemtest.ajc181.AllTestsAspectJ181; import org.aspectj.systemtest.ajc1810.AllTestsAspectJ1810; +import org.aspectj.systemtest.ajc1811.AllTestsAspectJ1811; import org.aspectj.systemtest.ajc182.AllTestsAspectJ182; import org.aspectj.systemtest.ajc183.AllTestsAspectJ183; import org.aspectj.systemtest.ajc184.AllTestsAspectJ184; @@ -30,6 +31,7 @@ public class AllTests18 { public static Test suite() { TestSuite suite = new TestSuite("AspectJ System Test Suite - 1.8"); // $JUnit-BEGIN$ + suite.addTest(AllTestsAspectJ1811.suite()); suite.addTest(AllTestsAspectJ1810.suite()); suite.addTest(AllTestsAspectJ189.suite()); suite.addTest(AllTestsAspectJ188.suite()); diff --git a/tests/src/org/aspectj/systemtest/ajc150/AnnotationBinding.java b/tests/src/org/aspectj/systemtest/ajc150/AnnotationBinding.java index 63cebdb06..466567641 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/AnnotationBinding.java +++ b/tests/src/org/aspectj/systemtest/ajc150/AnnotationBinding.java @@ -18,6 +18,7 @@ import junit.framework.Test; import org.aspectj.asm.AsmManager; import org.aspectj.asm.IHierarchy; import org.aspectj.asm.IProgramElement; +import org.aspectj.asm.IRelationship; import org.aspectj.asm.internal.Relationship; import org.aspectj.testing.XMLBasedAjcTestCase; @@ -313,7 +314,7 @@ public class AnnotationBinding extends XMLBasedAjcTestCase { "declare @method: int A.m() : @Fruit(\"orange\")"); assertTrue("Couldn't find 'declare @method' element in the tree", ipe != null); - List l = asm.getRelationshipMap().get(ipe); + List<IRelationship> l = asm.getRelationshipMap().get(ipe); assertTrue("Should have a relationship but does not ", l.size() > 0); ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.DECLARE_ANNOTATION_AT_METHOD, @@ -343,7 +344,7 @@ public class AnnotationBinding extends XMLBasedAjcTestCase { "declare @field: int A.i : @Fruit(\"orange\")"); assertTrue("Couldn't find 'declare @type' element in the tree", ipe != null); - List l = asm.getRelationshipMap().get(ipe); + List<IRelationship> l = asm.getRelationshipMap().get(ipe); assertTrue("Should have a relationship but does not ", l.size() > 0); ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.DECLARE_ANNOTATION_AT_FIELD, @@ -375,7 +376,7 @@ public class AnnotationBinding extends XMLBasedAjcTestCase { "declare @constructor: A.new(java.lang.String) : @Fruit(\"pear\")"); assertTrue("Couldn't find 'declare @constructor' element in the tree", ipe != null); - List l = asm.getRelationshipMap().get(ipe); + List<IRelationship> l = asm.getRelationshipMap().get(ipe); assertTrue("Should have a relationship but does not ", l.size() > 0); ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.DECLARE_ANNOTATION_AT_CONSTRUCTOR, diff --git a/tests/src/org/aspectj/systemtest/ajc150/GenericITDsDesign.java b/tests/src/org/aspectj/systemtest/ajc150/GenericITDsDesign.java index dfedf65a0..6209298c1 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/GenericITDsDesign.java +++ b/tests/src/org/aspectj/systemtest/ajc150/GenericITDsDesign.java @@ -15,6 +15,7 @@ import org.aspectj.apache.bcel.util.ClassPath; import org.aspectj.apache.bcel.util.SyntheticRepository; import org.aspectj.testing.XMLBasedAjcTestCase; import org.aspectj.tools.ajc.Ajc; +import org.aspectj.weaver.ConcreteTypeMunger; import org.aspectj.weaver.CrosscuttingMembers; import org.aspectj.weaver.ReferenceType; import org.aspectj.weaver.ResolvedMember; @@ -75,12 +76,12 @@ public class GenericITDsDesign extends XMLBasedAjcTestCase { .equals(sig)); } - public List /* BcelTypeMunger */getTypeMunger(String classname) { + public List<ConcreteTypeMunger> getTypeMunger(String classname) { ClassPath cp = new ClassPath(ajc.getSandboxDirectory() + File.pathSeparator + System.getProperty("java.class.path")); recentWorld = new BcelWorld(cp.toString()); ReferenceType resolvedType = (ReferenceType) recentWorld.resolve(classname); CrosscuttingMembers cmembers = resolvedType.collectCrosscuttingMembers(true); - List tmungers = cmembers.getTypeMungers(); + List<ConcreteTypeMunger> tmungers = cmembers.getTypeMungers(); return tmungers; } @@ -100,9 +101,9 @@ public class GenericITDsDesign extends XMLBasedAjcTestCase { return null; } - public Hashtable getMeTheFields(String classname) { + public Hashtable<String,Field> getMeTheFields(String classname) { JavaClass theClass = getClassFromDisk(ajc, classname); - Hashtable retval = new Hashtable(); + Hashtable<String,Field> retval = new Hashtable<>(); org.aspectj.apache.bcel.classfile.Field[] fs = theClass.getFields(); for (int i = 0; i < fs.length; i++) { Field field = fs[i]; @@ -206,7 +207,7 @@ public class GenericITDsDesign extends XMLBasedAjcTestCase { // Verifying what gets into a class targetted with a field ITD public void testDesignF() { runTest("generic itds - design F"); - Hashtable fields = getMeTheFields("C"); + Hashtable<String,Field> fields = getMeTheFields("C"); // Declared in src as: List C.list1; and List<Z> C<Z>.list2; Field list1 = (Field) fields.get("list1");// ajc$interField$$list1"); @@ -229,7 +230,7 @@ public class GenericITDsDesign extends XMLBasedAjcTestCase { // Verifying what gets into a class when an interface it implements was targetted with a field ITD public void testDesignG() { runTest("generic itds - design G"); - Hashtable fields = getMeTheFields("C"); + Hashtable<String,Field> fields = getMeTheFields("C"); // The ITDs are targetting an interface. That interface is generic and is parameterized with // 'String' when implemented in the class C. This means the fields that make it into C should diff --git a/tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java b/tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java index 21efa3328..ff08047d1 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java @@ -5,11 +5,8 @@ import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.util.HashSet; -import java.util.Iterator; import java.util.Set; -import junit.framework.Test; - import org.aspectj.apache.bcel.classfile.Attribute; import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.Signature; @@ -19,6 +16,8 @@ import org.aspectj.testing.XMLBasedAjcTestCase; import org.aspectj.tools.ajc.Ajc; import org.aspectj.util.LangUtil; +import junit.framework.Test; + public class GenericsTests extends XMLBasedAjcTestCase { /*========================================== @@ -875,11 +874,11 @@ public class GenericsTests extends XMLBasedAjcTestCase { * bridge methods have been created. */ public void checkMethodsExist(String classname,String[] methods) { - Set methodsFound = new HashSet(); + Set<String> methodsFound = new HashSet<>(); StringBuffer debugString = new StringBuffer(); try { ClassLoader cl = new URLClassLoader(new URL[]{ajc.getSandboxDirectory().toURL()}); - Class clz = Class.forName(classname,false,cl); + Class<?> clz = Class.forName(classname,false,cl); java.lang.reflect.Method[] ms = clz.getDeclaredMethods(); if (ms!=null) { for (int i =0;i<ms.length;i++) { @@ -905,8 +904,7 @@ public class GenericsTests extends XMLBasedAjcTestCase { } StringBuffer unexpectedMethods = new StringBuffer(); if (!methodsFound.isEmpty()) { - for (Iterator iter = methodsFound.iterator(); iter.hasNext();) { - String element = (String) iter.next(); + for (String element: methodsFound) { unexpectedMethods.append("[").append(element).append("]"); } fail("These methods weren't expected: "+unexpectedMethods); @@ -924,7 +922,7 @@ public class GenericsTests extends XMLBasedAjcTestCase { return false; } try { - final Class[] noparms = new Class[0]; + final Class<?>[] noparms = new Class[0]; java.lang.reflect.Method isBridge = java.lang.reflect.Method.class.getMethod("isBridge", noparms); Boolean result = (Boolean) isBridge.invoke(m, new Object[0]); @@ -959,7 +957,6 @@ public class GenericsTests extends XMLBasedAjcTestCase { public static void checkOneSignatureAttribute(Ajc ajc,String classname) { JavaClass clazz = getClass(ajc,classname); - Signature sigAttr = null; Attribute[] attrs = clazz.getAttributes(); int signatureCount = 0; StringBuffer sb = new StringBuffer(); @@ -981,7 +978,7 @@ public class GenericsTests extends XMLBasedAjcTestCase { sigAttr.getSignature().equals(sig)); } - private static String stringify(Class[] clazzes) { + private static String stringify(Class<?>[] clazzes) { if (clazzes==null) return ""; StringBuffer sb = new StringBuffer(); for (int i = 0; i < clazzes.length; i++) { diff --git a/tests/src/org/aspectj/systemtest/ajc151/NewarrayJoinpointTests.java b/tests/src/org/aspectj/systemtest/ajc151/NewarrayJoinpointTests.java index 4b21319d0..9c92f8488 100644 --- a/tests/src/org/aspectj/systemtest/ajc151/NewarrayJoinpointTests.java +++ b/tests/src/org/aspectj/systemtest/ajc151/NewarrayJoinpointTests.java @@ -17,6 +17,7 @@ import junit.framework.Test; import org.aspectj.asm.AsmManager; import org.aspectj.asm.IProgramElement; +import org.aspectj.asm.IRelationship; import org.aspectj.testing.XMLBasedAjcTestCase; /* @@ -102,14 +103,14 @@ public class NewarrayJoinpointTests extends XMLBasedAjcTestCase { runTest("structure model"); IProgramElement ipe = AsmManager.lastActiveStructureModel.getHierarchy().findElementForType("", "Five"); assertTrue("Couldnt find 'Five' type in the model", ipe != null); - List kids = ipe.getChildren(); + List<IProgramElement> kids = ipe.getChildren(); assertTrue("Couldn't find 'main' method in the 'Five' type", kids != null && kids.size() == 1); - List codenodes = ((IProgramElement) kids.get(0)).getChildren(); + List<IProgramElement> codenodes = ((IProgramElement) kids.get(0)).getChildren(); assertTrue("Couldn't find nodes below 'main' method", codenodes != null && codenodes.size() == 1); IProgramElement arrayCtorCallNode = (IProgramElement) codenodes.get(0); String exp = "constructor-call(void java.lang.Integer[].<init>(int))"; assertTrue("Expected '" + exp + "' but found " + arrayCtorCallNode.toString(), arrayCtorCallNode.toString().equals(exp)); - List rels = AsmManager.lastActiveStructureModel.getRelationshipMap().get(arrayCtorCallNode); + List<IRelationship> rels = AsmManager.lastActiveStructureModel.getRelationshipMap().get(arrayCtorCallNode); assertTrue("Should have a relationship from the ctorcall node, but didn't find one?", rels != null && rels.size() == 1); } diff --git a/tests/src/org/aspectj/systemtest/ajc152/SynchronizationTransformTests.java b/tests/src/org/aspectj/systemtest/ajc152/SynchronizationTransformTests.java index 64fa5a174..922f4c5b4 100644 --- a/tests/src/org/aspectj/systemtest/ajc152/SynchronizationTransformTests.java +++ b/tests/src/org/aspectj/systemtest/ajc152/SynchronizationTransformTests.java @@ -181,9 +181,8 @@ public class SynchronizationTransformTests extends XMLBasedAjcTestCase { private LazyMethodGen getMethod(String typename, String methodname) { BcelObjectType type = getBcelObjectFor(typename); LazyClassGen lcg = type.getLazyClassGen(); - List /* LazyMethodGen */methods = lcg.getMethodGens(); - for (Iterator iter = methods.iterator(); iter.hasNext();) { - LazyMethodGen element = (LazyMethodGen) iter.next(); + List<LazyMethodGen> methods = lcg.getMethodGens(); + for (LazyMethodGen element: methods) { if (element.getName().equals(methodname)) { return element; } @@ -234,7 +233,7 @@ public class SynchronizationTransformTests extends XMLBasedAjcTestCase { // Load the file in fr = new BufferedReader(new FileReader(f)); String line = null; - List originalFileContents = new ArrayList(); + List<String> originalFileContents = new ArrayList<>(); while ((line = fr.readLine()) != null) originalFileContents.add(line); String[] fileContents = (String[]) originalFileContents.toArray(new String[] {}); @@ -256,10 +255,10 @@ public class SynchronizationTransformTests extends XMLBasedAjcTestCase { } } - private String stringify(List l) { + private String stringify(List<String> l) { StringBuffer result = new StringBuffer(); - for (Iterator iter = l.iterator(); iter.hasNext();) { - String str = (String) iter.next(); + for (Iterator<String> iter = l.iterator(); iter.hasNext();) { + String str = iter.next(); result.append(str); result.append("\n"); } diff --git a/tests/src/org/aspectj/systemtest/ajc160/SanityTests.java b/tests/src/org/aspectj/systemtest/ajc160/SanityTests.java index 5d0462c99..45eac49ce 100644 --- a/tests/src/org/aspectj/systemtest/ajc160/SanityTests.java +++ b/tests/src/org/aspectj/systemtest/ajc160/SanityTests.java @@ -94,6 +94,7 @@ public class SanityTests extends org.aspectj.testing.XMLBasedAjcTestCase { // } /* For the specified class, check that each method has a stackmap attribute */ + @SuppressWarnings("unused") private void checkStackMapExistence(String classname, String toIgnore) throws ClassNotFoundException { toIgnore = "_" + (toIgnore == null ? "" : toIgnore) + "_"; JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname); diff --git a/tests/src/org/aspectj/systemtest/ajc1610/NewFeatures.java b/tests/src/org/aspectj/systemtest/ajc1610/NewFeatures.java index b9de3dff7..588d71186 100644 --- a/tests/src/org/aspectj/systemtest/ajc1610/NewFeatures.java +++ b/tests/src/org/aspectj/systemtest/ajc1610/NewFeatures.java @@ -31,6 +31,7 @@ public class NewFeatures extends org.aspectj.testing.XMLBasedAjcTestCase { } } + @SuppressWarnings("unused") public void testMakeSJPOptimizationCollapsedSJPYes14() { this.runTest("makeSJP optimization - Collapsed SJP - Yes 1.4"); try { diff --git a/tests/src/org/aspectj/systemtest/ajc163/Ajc163Tests.java b/tests/src/org/aspectj/systemtest/ajc163/Ajc163Tests.java index 224f695ef..15abc8921 100644 --- a/tests/src/org/aspectj/systemtest/ajc163/Ajc163Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc163/Ajc163Tests.java @@ -11,7 +11,6 @@ package org.aspectj.systemtest.ajc163; import java.io.File; -import java.util.Iterator; import java.util.List; import junit.framework.Test; @@ -174,9 +173,8 @@ public class Ajc163Tests extends org.aspectj.testing.XMLBasedAjcTestCase { if (whereToLook.getSourceLocation() != null && whereToLook.getSourceLocation().getLine() == line) { return whereToLook; } - List kids = whereToLook.getChildren(); - for (Iterator iterator = kids.iterator(); iterator.hasNext();) { - IProgramElement object = (IProgramElement) iterator.next(); + List<IProgramElement> kids = whereToLook.getChildren(); + for (IProgramElement object: kids) { if (object.getSourceLocation() != null && object.getSourceLocation().getLine() == line) { return object; } diff --git a/tests/src/org/aspectj/systemtest/ajc180/AllTestsAspectJ180.java b/tests/src/org/aspectj/systemtest/ajc180/AllTestsAspectJ180.java index 6feff4445..453c057eb 100644 --- a/tests/src/org/aspectj/systemtest/ajc180/AllTestsAspectJ180.java +++ b/tests/src/org/aspectj/systemtest/ajc180/AllTestsAspectJ180.java @@ -10,8 +10,6 @@ *******************************************************************************/ package org.aspectj.systemtest.ajc180; -import org.aspectj.systemtest.ajc181.Ajc181Tests; - import junit.framework.Test; import junit.framework.TestSuite; diff --git a/tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java b/tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java index cff7a3b7b..37896b42f 100644 --- a/tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java @@ -12,28 +12,58 @@ package org.aspectj.systemtest.ajc1810; import java.io.File; -import junit.framework.Test; - import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.classfile.Attribute; -import org.aspectj.apache.bcel.classfile.Constant; -import org.aspectj.apache.bcel.classfile.ConstantClass; -import org.aspectj.apache.bcel.classfile.ConstantPool; -import org.aspectj.apache.bcel.classfile.ConstantUtf8; -import org.aspectj.apache.bcel.classfile.InnerClass; -import org.aspectj.apache.bcel.classfile.InnerClasses; import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.testing.XMLBasedAjcTestCase; +import junit.framework.Test; + /** * @author Andy Clement */ public class Ajc1810Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + public void testBinding_508661() { + runTest("various ltw"); + } + + public void testBinding_500035() { + runTest("ataspectj binding"); + } + + public void testBinding_500035_2() { + runTest("ataspectj binding 2"); + } + + public void testBinding_500035_3() { + runTest("ataspectj binding 3 -XnoInline"); + } + + public void testBinding_500035_4() { + runTest("ataspectj binding 4"); + } + + public void testGenericsException_501656() { + runTest("generics exception"); + } + + public void testAIOOBE_502807() { + runTest("unexpected aioobe"); + } + public void testInvokeDynamic_490315() { runTest("indy"); } + public void testAmbigMessage17() throws Exception { + runTest("ambiguous message - 17"); + } + + public void testAmbigMessage18() throws Exception { + runTest("ambiguous message - 18"); + } + // http://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.6 public void testInnerClassesAttributeStructure_493554() throws Exception { runTest("pertarget"); diff --git a/tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml b/tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml index dd4237d22..0171f5b55 100644 --- a/tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml +++ b/tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml @@ -2,6 +2,88 @@ <suite> + <ajc-test dir="bugs1810/508661" title="various ltw"> + <compile options="-1.8" files="CacheMethodResult.java A_yes.java B_no.java Run.java" outjar="classes.jar"/> + <compile options="-1.8 -Xlint:ignore" files="CacheMethodResultAspect.java" outjar="aspects.jar"/> + <run class="Run" ltw="aop.xml"> + <stdout> + <line text="around: void A_yes.m()"/> + <line text="A_yes.m()"/> + <line text="A_yes has interface? CacheMethodResultAspect$ajcMightHaveAspect"/> + <line text="B_no.m()"/> + <line text="B_no has interface? no"/> + </stdout> + </run> + </ajc-test> + + <ajc-test dir="bugs1810/500035" title="ataspectj binding"> + <compile options="-1.8" files="Code.java"/> + <run class="Code"> + <stdout> + <line text="targetObject = hello"/> + <line text="regex = l"/> + <line text="replacement = 7"/> + <line text="he7lo"/> + </stdout> + </run> + </ajc-test> + + <ajc-test dir="bugs1810/500035" title="ataspectj binding 2"> + <compile options="-1.8" files="Code2.java"/> + <run class="Code2"> + <stdout> + <line text="targetObject = hello"/> + <line text="regex = l"/> + <line text="replacement = 8"/> + <line text="he8lo"/> + </stdout> + </run> + </ajc-test> + + <ajc-test dir="bugs1810/500035" title="ataspectj binding 3 -XnoInline"> + <compile options="-1.8 -XnoInline" files="Code3.java"/> + <run class="Code3"> + <stdout> + <line text="first: binding target, just passing everything through: target=Foo(1)"/> + <line text="Executing run(abc) on Foo(i=1)"/> + <line text="second: binding this and target, just passing everything through: this=Foo(0) target=Foo(1)"/> + <line text="Executing run(abc) on Foo(i=1)"/> + <line text="third: binding this, just passing everything through: this=Foo(0)"/> + <line text="Executing run(abc) on Foo(i=1)"/> + <line text="fourth: binding this, switching from Foo(0) to Foo(3)"/> + <line text="Executing run(abc) on Foo(i=1)"/> + <line text="fifth: binding target, switching from Foo(1) to Foo(4)"/> + <line text="Executing run(abc) on Foo(i=4)"/> + <line text="sixth: binding this and target, switching them around (before this=Foo(0) target=Foo(1))"/> + <line text="Executing run(abc) on Foo(i=0)"/> + </stdout> + </run> + </ajc-test> + + <ajc-test dir="bugs1810/500035" title="ataspectj binding 4"> + <compile options="-1.8" files="Code3.java"/> + <run class="Code3"> + <stdout> + <line text="first: binding target, just passing everything through: target=Foo(1)"/> + <line text="Executing run(abc) on Foo(i=1)"/> + <line text="second: binding this and target, just passing everything through: this=Foo(0) target=Foo(1)"/> + <line text="Executing run(abc) on Foo(i=1)"/> + <line text="third: binding this, just passing everything through: this=Foo(0)"/> + <line text="Executing run(abc) on Foo(i=1)"/> + <line text="fourth: binding this, switching from Foo(0) to Foo(3)"/> + <line text="Executing run(abc) on Foo(i=1)"/> + <line text="fifth: binding target, switching from Foo(1) to Foo(4)"/> + <line text="Executing run(abc) on Foo(i=4)"/> + <line text="sixth: binding this and target, switching them around (before this=Foo(0) target=Foo(1))"/> + <line text="Executing run(abc) on Foo(i=0)"/> + </stdout> + </run> + </ajc-test> + + <ajc-test dir="bugs1810/501656" title="generics exception"> + <compile options="-1.8 -parameters" files="ApplicationException.java ApplicationExceptionHandler.java"/> + </ajc-test> + <ajc-test dir="bugs1810/490315" title="indy"> <compile options="-1.8" files="FailingAspect.java SomeAnno.java SomeContext.java SomeCriteria.java SomeDTO.java SomeEnum.java SomePiece.java SomePropertyDTO.java SomeService.java SomeServiceImpl.java"/> </ajc-test> @@ -11,5 +93,18 @@ <run class="example.kusedep.Cmd"></run> </ajc-test> + <ajc-test dir="bugs1810/ambig" title="ambiguous message - 18"> + <compile options="-1.8" files="X.java"/> + </ajc-test> + + <ajc-test dir="bugs1810/ambig" title="ambiguous message - 17"> + <compile options="-1.7" files="X.java"/> + </ajc-test> + <ajc-test dir="bugs1810/502807" title="unexpected aioobe"> + <compile options="-1.8" files="TestCollectors.java"> + <message kind="error" text="The method toList() in the type Collectors is not applicable for the arguments (Inner::getId)"/> + </compile> + </ajc-test> + </suite> diff --git a/tests/src/org/aspectj/systemtest/ajc1811/Ajc1811Tests.java b/tests/src/org/aspectj/systemtest/ajc1811/Ajc1811Tests.java new file mode 100644 index 000000000..0c6663692 --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc1811/Ajc1811Tests.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * Copyright (c) 2016 Contributors + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc1811; + +import java.io.File; + +import org.aspectj.apache.bcel.Constants; +import org.aspectj.apache.bcel.classfile.Attribute; +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.apache.bcel.classfile.Method; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.weaver.ResolvedMember; +import org.aspectj.weaver.ResolvedType; +import org.aspectj.weaver.UnresolvedType; +import org.aspectj.weaver.bcel.BcelWorld; + +import junit.framework.Test; + +/** + * @author Andy Clement + */ +public class Ajc1811Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + +// public void testParameterizedWithInner() throws Exception { +// runTest("parameterized with inner"); +// JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "Outer"); +// assertNotNull(jc); +// BcelWorld world = new BcelWorld(ajc.getSandboxDirectory().toString()); +// +// ResolvedType outerType = world.resolve(UnresolvedType.forName("Outer")); +// ResolvedMember m = findMethod(outerType,"m"); +// +// UnresolvedType type = m.getReturnType(); +// assertEquals("LOuter$Inner;",type.getSignature()); +// +// type = m.getGenericReturnType(); +// assertEquals("LOuter$Inner;",type.getSignature()); +// +// ResolvedType resolvedType = world.resolve(type); +// ResolvedType outerResolvedType = resolvedType.getOuterClass(); +// assertEquals("LOuter;",outerResolvedType.getSignature()); +// +// ResolvedMember m2 = findMethod(outerType,"m2"); +// type = m2.getReturnType(); +// assertEquals("LOuter$Inner;",type.getSignature()); +// +// type = m2.getGenericReturnType(); +// assertEquals("LOuter$Inner;",type.getSignature()); +// +// // public Inner m() { ... } +// Method m = findMethod(jc,"m"); +// System.out.println(m); +// System.out.println(">"+m.getReturnType()); +// assertNotNull(returnType); +// +// // public Outer<String>.Inner m2() { ... } +// } +// +// public void testMultiArgs_509235() { +// runTest("multiargs"); +// } +// +// public void testMultiArgs_509235_2() { +// runTest("multiargs - no ellipsis"); +// } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc1811Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc1811.xml"); + } + +} diff --git a/tests/src/org/aspectj/systemtest/ajc1811/AllTestsAspectJ1811.java b/tests/src/org/aspectj/systemtest/ajc1811/AllTestsAspectJ1811.java new file mode 100644 index 000000000..b8aca6712 --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc1811/AllTestsAspectJ1811.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2016 Contributors + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc1811; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ1811 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.8.11 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc1811Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/org/aspectj/systemtest/ajc1811/ajc1811.xml b/tests/src/org/aspectj/systemtest/ajc1811/ajc1811.xml new file mode 100644 index 000000000..f4e321e5c --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc1811/ajc1811.xml @@ -0,0 +1,29 @@ +<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]> + +<suite> + + <ajc-test dir="bugs1811/parameterizedWithInner" title="parameterized with inner"> + <compile options="-1.8" files="Code.java"/> + </ajc-test> + + <ajc-test dir="bugs1811/509235" title="multiargs"> + <compile options="-1.8" files="Code.java"/> + <run class="Code"> + <stdout> + <line text="username = fooname"/> + <line text="username = barname"/> + </stdout> + </run> + </ajc-test> + + <ajc-test dir="bugs1811/509235" title="multiargs - no ellipsis"> + <compile options="-1.8" files="Code2.java"/> + <run class="Code2"> + <stdout> + <line text="username = fooname"/> + <line text="username = barname"/> + </stdout> + </run> + </ajc-test> + +</suite> diff --git a/tests/src/org/aspectj/systemtest/ajc185/Ajc185Tests.java b/tests/src/org/aspectj/systemtest/ajc185/Ajc185Tests.java index cc9800043..77b453188 100644 --- a/tests/src/org/aspectj/systemtest/ajc185/Ajc185Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc185/Ajc185Tests.java @@ -10,17 +10,12 @@ *******************************************************************************/ package org.aspectj.systemtest.ajc185; -import java.io.BufferedInputStream; import java.io.File; -import java.io.FileInputStream; -import junit.framework.Test; - -import org.aspectj.apache.bcel.classfile.JavaClass; -import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; -import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; import org.aspectj.testing.XMLBasedAjcTestCase; +import junit.framework.Test; + /** * @author Andy Clement */ diff --git a/tests/src/org/aspectj/systemtest/ajc187/Ajc187Tests.java b/tests/src/org/aspectj/systemtest/ajc187/Ajc187Tests.java index 754864fd7..4ff34b28e 100644 --- a/tests/src/org/aspectj/systemtest/ajc187/Ajc187Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc187/Ajc187Tests.java @@ -11,14 +11,11 @@ package org.aspectj.systemtest.ajc187; import java.io.File; -import java.lang.reflect.Method; -import java.net.URL; -import java.net.URLClassLoader; - -import junit.framework.Test; import org.aspectj.testing.XMLBasedAjcTestCase; +import junit.framework.Test; + /** * @author Andy Clement */ diff --git a/tests/src/org/aspectj/systemtest/ajc187/AllTestsAspectJ187.java b/tests/src/org/aspectj/systemtest/ajc187/AllTestsAspectJ187.java index 79634df8c..ef8ff0a1c 100644 --- a/tests/src/org/aspectj/systemtest/ajc187/AllTestsAspectJ187.java +++ b/tests/src/org/aspectj/systemtest/ajc187/AllTestsAspectJ187.java @@ -12,7 +12,6 @@ package org.aspectj.systemtest.ajc187; import junit.framework.Test; import junit.framework.TestSuite; -import org.aspectj.systemtest.apt.AptTests; public class AllTestsAspectJ187 { diff --git a/tests/src/org/aspectj/systemtest/ajc188/AllTestsAspectJ188.java b/tests/src/org/aspectj/systemtest/ajc188/AllTestsAspectJ188.java index 8867d9174..32d3c12bf 100644 --- a/tests/src/org/aspectj/systemtest/ajc188/AllTestsAspectJ188.java +++ b/tests/src/org/aspectj/systemtest/ajc188/AllTestsAspectJ188.java @@ -12,7 +12,6 @@ package org.aspectj.systemtest.ajc188; import junit.framework.Test; import junit.framework.TestSuite; -import org.aspectj.systemtest.apt.AptTests; public class AllTestsAspectJ188 { diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java b/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java index 9b6c11e90..01426d923 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java @@ -99,7 +99,7 @@ public class AjdeInteractionTestbed extends TestCase { ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setNonStandardOptions(options); } - public void configureAspectPath(String projectName, Set aspectpath) { + public void configureAspectPath(String projectName, Set<File> aspectpath) { AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setAspectPath(aspectpath); } @@ -121,12 +121,12 @@ public class AjdeInteractionTestbed extends TestCase { ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setAspectPath(s); } - public void configureResourceMap(String projectName, Map resourcesMap) { + public void configureResourceMap(String projectName, Map<String,File> resourcesMap) { AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setSourcePathResources(resourcesMap); } - public void configureJavaOptionsMap(String projectName, Map options) { + public void configureJavaOptionsMap(String projectName, Map<String,String> options) { AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setJavaOptions(options); } @@ -240,7 +240,7 @@ public class AjdeInteractionTestbed extends TestCase { private void addSourceFilesToBuild(String pname, AjCompiler compiler) { File projectBase = new File(sandboxDir, pname); ICompilerConfiguration icc = compiler.getCompilerConfiguration(); - List currentFiles = icc.getProjectSourceFiles(); + List<String> currentFiles = icc.getProjectSourceFiles(); List<String> filesForCompilation = new ArrayList<String>(); collectUpFiles(projectBase, projectBase, filesForCompilation); boolean changed = false; @@ -335,9 +335,8 @@ public class AjdeInteractionTestbed extends TestCase { MultiProjTestMessageHandler handler = (MultiProjTestMessageHandler) compiler.getMessageHandler(); if (handler.hasErrorMessages()) { System.err.println("Build errors:"); - for (Iterator<IMessage> iter = handler.getErrorMessages().iterator(); iter.hasNext();) { - IMessage element = iter.next(); - System.err.println(element); + for (IMessage message: handler.getErrorMessages()) { + System.err.println(message); } System.err.println("---------"); } @@ -358,7 +357,7 @@ public class AjdeInteractionTestbed extends TestCase { return ((MultiProjTestMessageHandler) compiler.getMessageHandler()).getWeavingMessages(); } - public List<IMessage> getCompilerErrorMessages(String projectName) { + public List<String> getCompilerErrorMessages(String projectName) { AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); return ((MultiProjTestMessageHandler) compiler.getMessageHandler()).getCompilerErrors(); } @@ -393,12 +392,10 @@ public class AjdeInteractionTestbed extends TestCase { if (getCompiledFiles(projectName).size() == 0 && getWovenClasses(projectName).size() == 0) { sb.append("No files were compiled or woven\n"); } - for (Iterator iter = getCompiledFiles(projectName).iterator(); iter.hasNext();) { - Object element = iter.next(); + for (String element: getCompiledFiles(projectName)) { sb.append("compiled: " + element + "\n"); } - for (Iterator iter = getWovenClasses(projectName).iterator(); iter.hasNext();) { - Object element = iter.next(); + for (String element: getWovenClasses(projectName)) { sb.append("woven: " + element + "\n"); } return sb.toString(); diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/IncrementalOutputLocationManagerTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/IncrementalOutputLocationManagerTests.java index 0c13b154b..3f2afc409 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/IncrementalOutputLocationManagerTests.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/IncrementalOutputLocationManagerTests.java @@ -40,7 +40,7 @@ public class IncrementalOutputLocationManagerTests extends AbstractMultiProjectI private String projectDir; private int numberOfSrcDirs; - private List allOutputDirs; + private List<File> allOutputDirs; public MyOutputLocationManager(String projectName, int numberOfSrcDirs) { projectDir = getWorkingDir() + File.separator + projectName; @@ -53,8 +53,8 @@ public class IncrementalOutputLocationManagerTests extends AbstractMultiProjectI public void reportFileRemove(String outputfile, int filetype) { } - public Map getInpathMap() { - return Collections.EMPTY_MAP; + public Map<File,String> getInpathMap() { + return Collections.emptyMap(); } public File getOutputLocationForClass(File compilationUnit) { @@ -72,9 +72,9 @@ public class IncrementalOutputLocationManagerTests extends AbstractMultiProjectI return getOutputLocationForClass(resource); } - public List getAllOutputLocations() { + public List<File> getAllOutputLocations() { if (allOutputDirs == null) { - allOutputDirs = new ArrayList(); + allOutputDirs = new ArrayList<>(); for (int i = 0; i < numberOfSrcDirs + 1; i++) { File f = null; if (i == 0) { diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java index 3299ee833..308ed42d5 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java @@ -64,12 +64,12 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen build("inpathTesting"); AjState state = getState(); - Map classNameToFileMap = state.getClassNameToFileMap(); + Map<String,File> classNameToFileMap = state.getClassNameToFileMap(); assertFalse("expected there to be classes ", classNameToFileMap.isEmpty()); - Set entrySet = classNameToFileMap.entrySet(); - for (Iterator iterator = entrySet.iterator(); iterator.hasNext();) { - Map.Entry entry = (Map.Entry) iterator.next(); - String className = (String) entry.getKey(); + Set<Map.Entry<String,File>> entrySet = classNameToFileMap.entrySet(); + for (Iterator<Map.Entry<String,File>> iterator = entrySet.iterator(); iterator.hasNext();) { + Map.Entry<String,File> entry = iterator.next(); + String className = entry.getKey(); String fullClassName = expectedOutputDir + File.separator + className.replace('.', File.separatorChar) + ".class"; File file = (File) entry.getValue(); assertEquals("expected file to have path \n" + fullClassName + ", but" + " found path \n" + file.getAbsolutePath(), @@ -105,15 +105,14 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen // the classes onthe inpath are recorded against the AjBuildManager // (they are deleted from the ajstate whilst cleaning up after a build) - Map binarySources = state.getAjBuildManager().getBinarySourcesForThisWeave(); + Map<String,List<UnwovenClassFile>> binarySources = state.getAjBuildManager().getBinarySourcesForThisWeave(); assertFalse("expected there to be binary sources from the inpath setting but didn't find any", binarySources.isEmpty()); - List unwovenClassFiles = (List) binarySources.get(inpathDir + File.separator + "InpathClass.class"); - List fileNames = new ArrayList(); + List<UnwovenClassFile> unwovenClassFiles = binarySources.get(inpathDir + File.separator + "InpathClass.class"); + List<String> fileNames = new ArrayList<>(); // the unwovenClassFiles should have filenames that point to the output dir // (which in this case is the sandbox dir) and not where they came from. - for (Iterator iterator = unwovenClassFiles.iterator(); iterator.hasNext();) { - UnwovenClassFile ucf = (UnwovenClassFile) iterator.next(); + for (UnwovenClassFile ucf: unwovenClassFiles) { if (ucf.getFilename().indexOf(expectedOutputDir) == -1) { fileNames.add(ucf.getFilename()); } @@ -145,15 +144,14 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen AjBuildConfig buildConfig = state.getBuildConfig(); state.prepareForNextBuild(buildConfig); - Map binarySources = state.getBinaryFilesToCompile(true); + Map<String, List<UnwovenClassFile>> binarySources = state.getBinaryFilesToCompile(true); assertFalse("expected there to be binary sources from the inpath setting but didn't find any", binarySources.isEmpty()); - List unwovenClassFiles = (List) binarySources.get(inpathDir + File.separator + "InpathClass.class"); - List fileNames = new ArrayList(); + List<UnwovenClassFile> unwovenClassFiles = binarySources.get(inpathDir + File.separator + "InpathClass.class"); + List<String> fileNames = new ArrayList<>(); // the unwovenClassFiles should have filenames that point to the output dir // (which in this case is the sandbox dir) and not where they came from. - for (Iterator iterator = unwovenClassFiles.iterator(); iterator.hasNext();) { - UnwovenClassFile ucf = (UnwovenClassFile) iterator.next(); + for (UnwovenClassFile ucf: unwovenClassFiles) { if (ucf.getFilename().indexOf(expectedOutputDir) == -1) { fileNames.add(ucf.getFilename()); } @@ -177,14 +175,13 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen AjState state = getState(); // tests AjState.createUnwovenClassFile(BinarySourceFile) - Map binarySources = state.getAjBuildManager().getBinarySourcesForThisWeave(); + Map<String,List<UnwovenClassFile>> binarySources = state.getAjBuildManager().getBinarySourcesForThisWeave(); assertFalse("expected there to be binary sources from the inpath setting but didn't find any", binarySources.isEmpty()); - List unwovenClassFiles = (List) binarySources.get(inpathDir); - List fileNames = new ArrayList(); + List<UnwovenClassFile> unwovenClassFiles = binarySources.get(inpathDir); + List<String> fileNames = new ArrayList<>(); - for (Iterator iterator = unwovenClassFiles.iterator(); iterator.hasNext();) { - UnwovenClassFile ucf = (UnwovenClassFile) iterator.next(); + for (UnwovenClassFile ucf: unwovenClassFiles) { if (ucf.getFilename().indexOf(expectedOutputDir) == -1) { fileNames.add(ucf.getFilename()); } @@ -312,7 +309,7 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen return; } File f = new File(entry); - Set s = new HashSet(); + Set<File> s = new HashSet<>(); s.add(f); configureInPath("inpathTesting", s); } @@ -325,14 +322,14 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen private File classOutputLoc; private File resourceOutputLoc; private String testProjectOutputPath; - private List allOutputLocations; + private List<File> allOutputLocations; private File outputLoc; public SingleDirOutputLocMgr(String testProjectPath) { this.testProjectOutputPath = testProjectPath + File.separator + "bin"; outputLoc = new File(testProjectOutputPath); - allOutputLocations = new ArrayList(); + allOutputLocations = new ArrayList<>(); allOutputLocations.add(outputLoc); } @@ -340,8 +337,8 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen return outputLoc; } - public Map getInpathMap() { - return Collections.EMPTY_MAP; + public Map<File,String> getInpathMap() { + return Collections.emptyMap(); } @@ -349,7 +346,7 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen return outputLoc; } - public List /* File */getAllOutputLocations() { + public List<File> getAllOutputLocations() { return allOutputLocations; } @@ -364,13 +361,11 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen } public String getSourceFolderForFile(File sourceFile) { - // TODO Auto-generated method stub - return null; + return null; // no impl } public int discoverChangesSince(File dir, long buildtime) { - // TODO Auto-generated method stub - return 0; + return 0; // no impl } } diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java index 562291c69..86302bfba 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java @@ -13,7 +13,6 @@ package org.aspectj.systemtest.incremental.tools; import java.io.File; import java.util.ArrayList; import java.util.Hashtable; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -30,11 +29,11 @@ public class MultiProjTestCompilerConfiguration implements ICompilerConfiguratio private boolean verbose = false; private String classPath = ""; - private Set aspectPath = null; - private Map sourcePathResources = null; + private Set<File> aspectPath = null; + private Map<String,File> sourcePathResources = null; private IOutputLocationManager outputLocationManager = null; private List<String> dependants; - private Map javaOptionsMap; + private Map<String,String> javaOptionsMap; private Set<File> inpath; private String encoding = null; private String outjar; @@ -43,8 +42,8 @@ public class MultiProjTestCompilerConfiguration implements ICompilerConfiguratio private String nonstandardoptions; private List<File> modifiedFiles; private List<String> modifiedDirs; - private List<String> projectSourceFiles = new ArrayList(); - private List xmlConfigFiles = new ArrayList(); + private List<String> projectSourceFiles = new ArrayList<>(); + private List<String> xmlConfigFiles = new ArrayList<>(); private String projectPath; int changed; @@ -53,7 +52,7 @@ public class MultiProjTestCompilerConfiguration implements ICompilerConfiguratio this.projectPath = projectPath; } - public Set getAspectPath() { + public Set<File> getAspectPath() { log("ICompilerConfiguration.getAspectPath(" + aspectPath + ")"); return aspectPath; } @@ -62,9 +61,8 @@ public class MultiProjTestCompilerConfiguration implements ICompilerConfiguratio log("ICompilerConfiguration.getClasspath()"); // AJDT has all the output directories on it's classpath StringBuffer sb = new StringBuffer(); - List allOutputPaths = getOutputLocationManager().getAllOutputLocations(); - for (Iterator iterator = allOutputPaths.iterator(); iterator.hasNext();) { - File dir = (File) iterator.next(); + List<File> allOutputPaths = getOutputLocationManager().getAllOutputLocations(); + for (File dir: allOutputPaths) { sb.append(File.pathSeparator + dir.getAbsolutePath()); } String cp = sb.toString() + File.pathSeparator + new File(AjdeInteractionTestbed.testdataSrcDir) + File.pathSeparator @@ -77,8 +75,8 @@ public class MultiProjTestCompilerConfiguration implements ICompilerConfiguratio // look at dependant projects if (dependants != null) { - for (Iterator iter = dependants.iterator(); iter.hasNext();) { - cp = AjdeInteractionTestbed.getFile((String) iter.next(), "bin") + File.pathSeparator + cp; + for (String dependant: dependants) { + cp = AjdeInteractionTestbed.getFile(dependant, "bin") + File.pathSeparator + cp; } } // System.err.println("For project "+projectPath+" getClasspath() returning "+cp); @@ -120,12 +118,12 @@ public class MultiProjTestCompilerConfiguration implements ICompilerConfiguratio return outputLocationManager; } - public List getProjectSourceFiles() { + public List<String> getProjectSourceFiles() { log("ICompilerConfiguration.getProjectSourceFiles()"); return projectSourceFiles; } - public List getProjectXmlConfigFiles() { + public List<String> getProjectXmlConfigFiles() { return xmlConfigFiles; } @@ -134,7 +132,7 @@ public class MultiProjTestCompilerConfiguration implements ICompilerConfiguratio return modifiedFiles; } - public Map getSourcePathResources() { + public Map<String,File> getSourcePathResources() { log("ICompilerConfiguration.getSourcePathResources()"); return sourcePathResources; } @@ -152,7 +150,7 @@ public class MultiProjTestCompilerConfiguration implements ICompilerConfiguratio } // -------------------- setter methods useful for testing --------------- - public void setAspectPath(Set aspectPath) { + public void setAspectPath(Set<File> aspectPath) { this.aspectPath = aspectPath; this.changed |= ICompilerConfiguration.ASPECTPATH_CHANGED; } @@ -177,7 +175,7 @@ public class MultiProjTestCompilerConfiguration implements ICompilerConfiguratio this.changed |= ICompilerConfiguration.PROCESSOR_CHANGED; } - public void setJavaOptions(Map javaOptions) { + public void setJavaOptions(Map<String,String> javaOptions) { this.javaOptionsMap = javaOptions; this.changed |= ICompilerConfiguration.JAVAOPTIONS_CHANGED; } @@ -215,7 +213,7 @@ public class MultiProjTestCompilerConfiguration implements ICompilerConfiguratio } } - public void setSourcePathResources(Map sourcePathResources) { + public void setSourcePathResources(Map<String,File> sourcePathResources) { this.sourcePathResources = sourcePathResources; this.changed |= ICompilerConfiguration.PROJECTSOURCERESOURCES_CHANGED; } @@ -240,7 +238,7 @@ public class MultiProjTestCompilerConfiguration implements ICompilerConfiguratio modifiedDirs = null; } - public List getClasspathElementsWithModifiedContents() { + public List<String> getClasspathElementsWithModifiedContents() { return modifiedDirs; } diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestMessageHandler.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestMessageHandler.java index 26afbf882..fa66bede7 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestMessageHandler.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestMessageHandler.java @@ -32,15 +32,15 @@ public class MultiProjTestMessageHandler implements IBuildMessageHandler { private List<IMessage> errorMessages; private List<IMessage> warningMessages; private List<IMessage> weavingMessages; - private List compilerErrors; - private List ignoring; + private List<String> compilerErrors; + private List<Kind> ignoring; public MultiProjTestMessageHandler() { - ignoring = new ArrayList(); + ignoring = new ArrayList<>(); errorMessages = new ArrayList<IMessage>(); warningMessages = new ArrayList<IMessage>(); weavingMessages = new ArrayList<IMessage>(); - compilerErrors = new ArrayList(); + compilerErrors = new ArrayList<>(); ignore(IMessage.INFO); ignore(IMessage.WEAVEINFO); } @@ -112,7 +112,7 @@ public class MultiProjTestMessageHandler implements IBuildMessageHandler { return weavingMessages; } - public List<IMessage> getCompilerErrors() { + public List<String> getCompilerErrors() { return compilerErrors; } diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestOutputLocationManager.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestOutputLocationManager.java index a5e93a824..bb04e515b 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestOutputLocationManager.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestOutputLocationManager.java @@ -31,7 +31,7 @@ public class MultiProjTestOutputLocationManager implements IOutputLocationManage private File classOutputLoc; private File resourceOutputLoc; private final Map sourceFolders = new HashMap(); - private List allOutputLocations; + private List<File> allOutputLocations; public MultiProjTestOutputLocationManager(String testProjectPath) { this.testProjectOutputPath = testProjectPath + File.separator + "bin"; @@ -52,9 +52,9 @@ public class MultiProjTestOutputLocationManager implements IOutputLocationManage return resourceOutputLoc; } - public List getAllOutputLocations() { + public List<File> getAllOutputLocations() { if (allOutputLocations == null) { - allOutputLocations = new ArrayList(); + allOutputLocations = new ArrayList<>(); initLocations(); allOutputLocations.add(classOutputLoc); if (!classOutputLoc.equals(resourceOutputLoc)) { diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java index 7080c03c9..779143bd1 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java @@ -14,8 +14,6 @@ package org.aspectj.systemtest.incremental.tools; import java.io.File; import java.io.IOException; import java.io.PrintWriter; -import java.net.URL; -import java.net.URLClassLoader; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -101,7 +99,16 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa runMethod(p, "demo.ConverterTest", "run"); } - + public void testRogueConstantReference() throws Exception { + String p = "pr404345"; + initialiseProject(p); + setProjectEncoding(p, "UTF-8"); + build(p); + checkWasFullBuild(); + // Should both indicate that Location cannot be resolved + assertEquals(2,getErrorMessages(p).size()); + } + public void testIncrementalITDInners4() throws Exception { String p = "prInner4"; initialiseProject(p); @@ -1150,7 +1157,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa alter(p, "inc1"); build(p); checkWasntFullBuild(); - List l = getCompilerErrorMessages(p); + List<String> l = getCompilerErrorMessages(p); assertEquals("Unexpected compiler error", 0, l.size()); } @@ -1159,14 +1166,14 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa String p = "pr298504"; initialiseProject(p); build(p); - List l = getErrorMessages(p); + List<IMessage> l = getErrorMessages(p); assertTrue(l.toString().indexOf("ManagedResource cannot be resolved to a type") != -1); // checkWasFullBuild(); alter(p, "inc1"); build(p); // checkWasntFullBuild(); - l = getCompilerErrorMessages(p); - assertTrue(l.toString().indexOf("NullPointerException") == -1); + List<String> compilerErrors = getCompilerErrorMessages(p); + assertTrue(compilerErrors.toString().indexOf("NullPointerException") == -1); l = getErrorMessages(p); assertTrue(l.toString().indexOf("ManagedResource cannot be resolved to a type") != -1); } @@ -1210,7 +1217,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa // "src/q/Asp.java")); build(p); checkWasntFullBuild(); - List<IMessage> l = getCompilerErrorMessages(p); + List<String> l = getCompilerErrorMessages(p); assertEquals("Unexpected compiler error", 0, l.size()); } @@ -1226,7 +1233,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa alter(p, "inc2"); // whitespace change on affected file build(p); checkWasntFullBuild(); - List l = getCompilerErrorMessages(p); + List<String> l = getCompilerErrorMessages(p); assertEquals("Unexpected compiler error", 0, l.size()); } @@ -1245,7 +1252,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa alter(p, "inc1"); build(p); checkWasntFullBuild(); - List<IMessage> l = getCompilerErrorMessages(p); + List<String> l = getCompilerErrorMessages(p); assertEquals("Unexpected compiler error", 0, l.size()); } @@ -1263,7 +1270,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa checkWasFullBuild(); alter(p, "inc1"); build(p); - List<IMessage> l = getCompilerErrorMessages(p); + List<String> l = getCompilerErrorMessages(p); assertEquals("Unexpected compiler error", 0, l.size()); } @@ -1909,7 +1916,6 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa + "ms second=" + timeTakenForSimpleIncBuild + "ms", timeTakenForSimpleIncBuild < timeTakenForFullBuildAndWeave); } - @SuppressWarnings("rawtypes") public void testBuildingTwoProjectsInTurns() { initialiseProject("P1"); initialiseProject("P2"); @@ -2114,7 +2120,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa long stime = System.currentTimeMillis(); try { ZipFile zf = new ZipFile("c:/jvms/jdk1.6.0_06/jre/lib/rt.jar"); - Enumeration e = zf.entries(); + Enumeration<? extends ZipEntry> e = zf.entries(); while (e.hasMoreElements()) { ZipEntry ze = (ZipEntry) e.nextElement(); String n = ze.getName(); @@ -2640,7 +2646,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa configureShowWeaveInfoMessages("PR157054", true); build("PR157054"); checkWasFullBuild(); - List weaveMessages = getWeavingMessages("PR157054"); + List<IMessage> weaveMessages = getWeavingMessages("PR157054"); assertTrue("Should be two weaving messages but there are " + weaveMessages.size(), weaveMessages.size() == 2); alter("PR157054", "inc1"); build("PR157054"); @@ -2821,7 +2827,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa initialiseProject("PR152257"); configureNonStandardCompileOptions("PR152257", "-XnoInline"); build("PR152257"); - List errors = getErrorMessages("PR152257"); + List<IMessage> errors = getErrorMessages("PR152257"); assertTrue("Should be no warnings, but there are #" + errors.size(), errors.size() == 0); checkWasFullBuild(); alter("PR152257", "inc1"); @@ -2959,10 +2965,9 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa } private void checkCompiled(String projectName, String typeNameSubstring) { - List files = getCompiledFiles(projectName); + List<String> files = getCompiledFiles(projectName); boolean found = false; - for (Iterator iterator = files.iterator(); iterator.hasNext();) { - String object = (String) iterator.next(); + for (String object: files) { if (object.indexOf(typeNameSubstring) != -1) { found = true; } @@ -3052,12 +3057,11 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa getWarningMessages("PR133117").size() == 1); alter("PR133117", "inc1"); build("PR133117"); - List warnings = getWarningMessages("PR133117"); - List noGuardWarnings = new ArrayList(); - for (Iterator iter = warnings.iterator(); iter.hasNext();) { - IMessage element = (IMessage) iter.next(); - if (element.getMessage().indexOf("Xlint:noGuardForLazyTjp") != -1) { - noGuardWarnings.add(element); + List<IMessage> warnings = getWarningMessages("PR133117"); + List<IMessage> noGuardWarnings = new ArrayList<>(); + for (IMessage warning: warnings) { + if (warning.getMessage().indexOf("Xlint:noGuardForLazyTjp") != -1) { + noGuardWarnings.add(warning); } } assertTrue("There should only be two Xlint:noGuardForLazyTjp warning message reported:\n" + noGuardWarnings, @@ -3297,7 +3301,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa // Step2. Quick check that the advice points to something... IProgramElement nodeForTypeA = checkForNode(model, "pkg", "A", true); IProgramElement nodeForAdvice = findAdvice(nodeForTypeA); - List relatedElements = getRelatedElements(model, nodeForAdvice, 1); + List<String> relatedElements = getRelatedElements(model, nodeForAdvice, 1); // Step3. Check the advice applying at the first 'code' join point // in pkg.C is from aspect pkg.A, line 7 @@ -3687,7 +3691,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa configureJavaOptionsMap("PR164384", javaOptions); build("PR164384"); - List errors = getErrorMessages("PR164384"); + List<IMessage> errors = getErrorMessages("PR164384"); if (getCompilerForProjectWithName("PR164384").isJava6Compatible()) { assertTrue("There should be no errros:\n" + errors, errors.isEmpty()); @@ -3957,9 +3961,8 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa return ipe; } } - List kids = ipe.getChildren(); - for (Iterator iter = kids.iterator(); iter.hasNext();) { - IProgramElement kid = (IProgramElement) iter.next(); + List<IProgramElement> kids = ipe.getChildren(); + for (IProgramElement kid: kids) { IProgramElement found = findAdvice(kid, whichOne); if (found != null) { return found; @@ -3986,8 +3989,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa } } List<IProgramElement> kids = ipe.getChildren(); - for (Iterator iter = kids.iterator(); iter.hasNext();) { - IProgramElement kid = (IProgramElement) iter.next(); + for (IProgramElement kid: kids) { IProgramElement found = findCode(kid, linenumber); if (found != null) { return found; diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/OutputLocationManagerTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/OutputLocationManagerTests.java index 2de3976db..333495399 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/OutputLocationManagerTests.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/OutputLocationManagerTests.java @@ -50,7 +50,7 @@ public class OutputLocationManagerTests extends AbstractMultiProjectIncrementalA } public void testResourceCopying() { - Map resourceMap = new HashMap(); + Map<String,File> resourceMap = new HashMap<>(); resourceMap.put("resourceOne.txt", new File(getFile(PROJECT_NAME, "srcRootOne/resourceOne.txt"))); resourceMap.put("resourceTwo.txt", new File(getFile(PROJECT_NAME, "srcRootTwo/resourceTwo.txt"))); configureResourceMap(PROJECT_NAME, resourceMap); @@ -93,7 +93,7 @@ public class OutputLocationManagerTests extends AbstractMultiProjectIncrementalA private static class MyOutputLocationManager implements IOutputLocationManager { private File projectHome; - private List allOutputDirs; + private List<File> allOutputDirs; public MyOutputLocationManager(File projectHome) { this.projectHome = projectHome; @@ -106,8 +106,8 @@ public class OutputLocationManagerTests extends AbstractMultiProjectIncrementalA public void reportFileRemove(String outputfile, int filetype) { } - public Map getInpathMap() { - return Collections.EMPTY_MAP; + public Map<File,String> getInpathMap() { + return Collections.emptyMap(); } @@ -132,9 +132,9 @@ public class OutputLocationManagerTests extends AbstractMultiProjectIncrementalA return getOutputLocationForClass(resource); } - public List getAllOutputLocations() { + public List<File> getAllOutputLocations() { if (allOutputDirs == null) { - allOutputDirs = new ArrayList(); + allOutputDirs = new ArrayList<>(); allOutputDirs.add(new File(projectHome, "target/main/classes")); allOutputDirs.add(new File(projectHome, "target/test/classes")); allOutputDirs.add(new File(projectHome, "target/anotherTest/classes")); diff --git a/util/src/org/aspectj/util/LangUtil.java b/util/src/org/aspectj/util/LangUtil.java index 3f913dc46..0f19124a9 100644 --- a/util/src/org/aspectj/util/LangUtil.java +++ b/util/src/org/aspectj/util/LangUtil.java @@ -940,11 +940,11 @@ public class LangUtil { * @param array the Object[] to convert (may be null) * @return the List corresponding to array (never null) */ - public static List<Object> arrayAsList(Object[] array) { + public static <T> List<T> arrayAsList(T[] array) { if ((null == array) || (1 > array.length)) { return Collections.emptyList(); } - ArrayList<Object> list = new ArrayList<Object>(); + ArrayList<T> list = new ArrayList<T>(); list.addAll(Arrays.asList(array)); return list; } diff --git a/util/src/org/aspectj/util/PartialOrder.java b/util/src/org/aspectj/util/PartialOrder.java index 5dd870205..8bb9f3b77 100644 --- a/util/src/org/aspectj/util/PartialOrder.java +++ b/util/src/org/aspectj/util/PartialOrder.java @@ -49,12 +49,12 @@ public class PartialOrder { public int fallbackCompareTo(Object other); } - private static class SortObject { - PartialComparable object; - List<SortObject> smallerObjects = new LinkedList<SortObject>(); - List<SortObject> biggerObjects = new LinkedList<SortObject>(); + private static class SortObject<T extends PartialComparable> { + T object; + List<SortObject<T>> smallerObjects = new LinkedList<SortObject<T>>(); + List<SortObject<T>> biggerObjects = new LinkedList<SortObject<T>>(); - public SortObject(PartialComparable o) { + public SortObject(T o) { object = o; } @@ -62,12 +62,12 @@ public class PartialOrder { return smallerObjects.size() == 0; } - boolean removeSmallerObject(SortObject o) { + boolean removeSmallerObject(SortObject<T> o) { smallerObjects.remove(o); return hasNoSmallerObjects(); } - void addDirectedLinks(SortObject other) { + void addDirectedLinks(SortObject<T> other) { int cmp = object.compareTo(other.object); if (cmp == 0) { return; @@ -86,18 +86,18 @@ public class PartialOrder { } } - private static void addNewPartialComparable(List<SortObject> graph, PartialComparable o) { - SortObject so = new SortObject(o); - for (Iterator<SortObject> i = graph.iterator(); i.hasNext();) { - SortObject other = i.next(); + private static <T extends PartialComparable> void addNewPartialComparable(List<SortObject<T>> graph, T o) { + SortObject<T> so = new SortObject<T>(o); + for (Iterator<SortObject<T>> i = graph.iterator(); i.hasNext();) { + SortObject<T> other = i.next(); so.addDirectedLinks(other); } graph.add(so); } - private static void removeFromGraph(List<SortObject> graph, SortObject o) { - for (Iterator<SortObject> i = graph.iterator(); i.hasNext();) { - SortObject other = i.next(); + private static <T extends PartialComparable> void removeFromGraph(List<SortObject<T>> graph, SortObject<T> o) { + for (Iterator<SortObject<T>> i = graph.iterator(); i.hasNext();) { + SortObject<T> other = i.next(); if (o == other) { i.remove(); @@ -114,7 +114,7 @@ public class PartialOrder { * @returns the same members as objects, but sorted according to their partial order. returns null if the objects are cyclical * */ - public static List sort(List objects) { + public static <T extends PartialComparable> List<T> sort(List<T> objects) { // lists of size 0 or 1 don't need any sorting if (objects.size() < 2) { return objects; @@ -124,9 +124,9 @@ public class PartialOrder { // ??? I don't like creating this data structure, but it does give good // ??? separation of concerns. - List<SortObject> sortList = new LinkedList<SortObject>(); // objects.size()); - for (Iterator i = objects.iterator(); i.hasNext();) { - addNewPartialComparable(sortList, (PartialComparable) i.next()); + List<SortObject<T>> sortList = new LinkedList<SortObject<T>>(); + for (Iterator<T> i = objects.iterator(); i.hasNext();) { + addNewPartialComparable(sortList, i.next()); } // System.out.println(sortList); @@ -140,11 +140,9 @@ public class PartialOrder { // System.out.println(sortList); // System.out.println("-->" + ret); - SortObject leastWithNoSmallers = null; + SortObject<T> leastWithNoSmallers = null; - for (Iterator i = sortList.iterator(); i.hasNext();) { - SortObject so = (SortObject) i.next(); - // System.out.println(so); + for (SortObject<T> so: sortList) { if (so.hasNoSmallerObjects()) { if (leastWithNoSmallers == null || so.object.fallbackCompareTo(leastWithNoSmallers.object) < 0) { leastWithNoSmallers = so; diff --git a/util/testsrc/org/aspectj/util/FileUtilTest.java b/util/testsrc/org/aspectj/util/FileUtilTest.java index 3f065278b..8ce18c700 100644 --- a/util/testsrc/org/aspectj/util/FileUtilTest.java +++ b/util/testsrc/org/aspectj/util/FileUtilTest.java @@ -62,7 +62,7 @@ public class FileUtilTest extends TestCase { * @throws AssertionFailedError if any names are not in dir */ public static String[] dirContains(File dir, final String[] filenames) { - final ArrayList sought = new ArrayList(LangUtil.arrayAsList(filenames)); + final ArrayList<String> sought = new ArrayList<>(LangUtil.arrayAsList(filenames)); FilenameFilter filter = new FilenameFilter() { public boolean accept(File d, String name) { return !sought.remove(name); @@ -129,11 +129,11 @@ public class FileUtilTest extends TestCase { * @return sorted String[] of all paths to all files under dir ending with one of the listed suffixes but not starting with "." */ public static String[] dirPaths(File dir, String[] suffixes) { - ArrayList result = new ArrayList(); + ArrayList<String> result = new ArrayList<String>(); doDirPaths(dir, result); // if suffixes required, remove those without suffixes if (!LangUtil.isEmpty(suffixes)) { - for (ListIterator iter = result.listIterator(); iter.hasNext();) { + for (ListIterator<String> iter = result.listIterator(); iter.hasNext();) { String path = iter.next().toString(); boolean hasSuffix = false; for (int i = 0; !hasSuffix && (i < suffixes.length); i++) { @@ -161,7 +161,7 @@ public class FileUtilTest extends TestCase { * @param dir the File to read - ignored if null, not a directory, or has "CVS" in its path * @param useSuffix if true, then use dir as suffix to path */ - private static void doDirPaths(File dir, ArrayList paths) { + private static void doDirPaths(File dir, ArrayList<String> paths) { if ((null == dir) || !dir.canRead() || (-1 != dir.getPath().indexOf("CVS"))) { return; } @@ -188,15 +188,15 @@ public class FileUtilTest extends TestCase { } /** List of File files or directories to delete when exiting */ - final ArrayList tempFiles; + final ArrayList<File> tempFiles; public FileUtilTest(String s) { super(s); - tempFiles = new ArrayList(); + tempFiles = new ArrayList<File>(); } public void tearDown() { - for (ListIterator iter = tempFiles.listIterator(); iter.hasNext();) { + for (ListIterator<File> iter = tempFiles.listIterator(); iter.hasNext();) { File dir = (File) iter.next(); log("removing " + dir); FileUtil.deleteContents(dir); @@ -236,7 +236,7 @@ public class FileUtilTest extends TestCase { public void testCopyFiles() { // bad input - Class iaxClass = IllegalArgumentException.class; + Class<?> iaxClass = IllegalArgumentException.class; checkCopyFiles(null, null, iaxClass, false); @@ -388,7 +388,7 @@ public class FileUtilTest extends TestCase { } public void testRandomFileString() { - ArrayList results = new ArrayList(); + ArrayList<String> results = new ArrayList<>(); for (int i = 0; i < 1000; i++) { String s = FileUtil.randomFileString(); if (results.contains(s)) { @@ -469,7 +469,7 @@ public class FileUtilTest extends TestCase { } }; for (int i = 0; i < 10; i++) { - List result = FileUtil.lineSeek("" + i, sourceList, true, errorSink); + List<String> result = FileUtil.lineSeek("" + i, sourceList, true, errorSink); assertEquals(2, result.size()); assertEquals(path + ":1:" + i, result.get(0)); assertEquals(path + ":2:" + i, result.get(1)); @@ -502,19 +502,19 @@ public class FileUtilTest extends TestCase { tempFiles.add(file); } // now test - final ArrayList errors = new ArrayList(); + final ArrayList<String> errors = new ArrayList<>(); final PrintStream errorSink = new PrintStream(System.err, true) { public void println(String error) { errors.add(error); } }; - List sourceList = new ArrayList(); + List<String> sourceList = new ArrayList<>(); sourceList.addAll(Arrays.asList(sources)); sourceList = Collections.unmodifiableList(sourceList); for (int k = 0; k < sources.length; k++) { - List result = FileUtil.lineSeek("" + k, sourceList, true, errorSink); + List<String> result = FileUtil.lineSeek("" + k, sourceList, true, errorSink); // number k found in every other line of every file at index k - Iterator iter = result.iterator(); + Iterator<String> iter = result.iterator(); for (int i = 0; i < MAX; i++) { // for each file for (int j = 1; j < (MAX + 1); j++) { // for every other line assertTrue(iter.hasNext()); diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java b/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java index a9f214723..d22b17d12 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java @@ -26,7 +26,6 @@ import org.aspectj.apache.bcel.generic.InstructionConstants; import org.aspectj.apache.bcel.generic.InstructionFactory; import org.aspectj.apache.bcel.generic.InstructionHandle; import org.aspectj.apache.bcel.generic.InstructionList; -import org.aspectj.apache.bcel.generic.InvokeDynamic; import org.aspectj.apache.bcel.generic.LineNumberTag; import org.aspectj.apache.bcel.generic.LocalVariableTag; import org.aspectj.bridge.ISourceLocation; diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java index 94462d5ff..10fdbd05c 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java @@ -2586,11 +2586,11 @@ public class BcelShadow extends Shadow { ret.append(InstructionFactory.createArrayLoad(Type.OBJECT)); ret.append(Utility.createConversion(fact, Type.OBJECT, callbackMethod.getArgumentTypes()[0])); } else { - int position = (hasThis()/* && pointcutBindsThis */? 1 : 0); + int position = (hasThis() && pointcutBindsThis)? 1 : 0; ret.append(InstructionFactory.createLoad(objectArrayType, theObjectArrayLocalNumber)); ret.append(Utility.createConstant(fact, position)); ret.append(InstructionFactory.createArrayLoad(Type.OBJECT)); - ret.append(Utility.createConversion(fact, Type.OBJECT, callbackMethod.getArgumentTypes()[position])); + ret.append(Utility.createConversion(fact, Type.OBJECT, callbackMethod.getArgumentTypes()[nextArgumentToProvideForCallback])); } nextArgumentToProvideForCallback++; } else { @@ -3049,12 +3049,9 @@ public class BcelShadow extends Shadow { /** * - * * @param callbackMethod the method we will call back to when our run method gets called. - * * @param proceedMap A map from state position to proceed argument position. May be non covering on state position. */ - private LazyMethodGen makeClosureClassAndReturnConstructor(String closureClassName, LazyMethodGen callbackMethod, IntMap proceedMap) { String superClassName = "org.aspectj.runtime.internal.AroundClosure"; @@ -3076,7 +3073,7 @@ public class BcelShadow extends Shadow { closureClass.addMethodGen(constructor); - // method + // Create the 'Object run(Object[])' method LazyMethodGen runMethod = new LazyMethodGen(Modifier.PUBLIC, Type.OBJECT, "run", new Type[] { objectArrayType }, new String[] {}, closureClass); InstructionList mbody = runMethod.getBody(); @@ -3092,12 +3089,11 @@ public class BcelShadow extends Shadow { Type[] stateTypes = callbackMethod.getArgumentTypes(); for (int i = 0, len = stateTypes.length; i < len; i++) { - Type stateType = stateTypes[i]; - ResolvedType stateTypeX = BcelWorld.fromBcel(stateType).resolve(world); + ResolvedType resolvedStateType = BcelWorld.fromBcel(stateTypes[i]).resolve(world); if (proceedMap.hasKey(i)) { - mbody.append(proceedVar.createConvertableArrayLoad(fact, proceedMap.get(i), stateTypeX)); + mbody.append(proceedVar.createConvertableArrayLoad(fact, proceedMap.get(i), resolvedStateType)); } else { - mbody.append(stateVar.createConvertableArrayLoad(fact, i, stateTypeX)); + mbody.append(stateVar.createConvertableArrayLoad(fact, i, resolvedStateType)); } } diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java index 8d5d26499..9768cb9e4 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java @@ -44,7 +44,6 @@ import org.aspectj.bridge.MessageUtil; import org.aspectj.bridge.WeaveMessage; import org.aspectj.bridge.context.CompilationAndWeavingContext; import org.aspectj.bridge.context.ContextToken; -import org.aspectj.weaver.AjAttribute; import org.aspectj.weaver.AjcMemberMaker; import org.aspectj.weaver.AnnotationAJ; import org.aspectj.weaver.AnnotationOnTypeMunger; diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java index e3e97517a..1a66c72b3 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java @@ -215,12 +215,15 @@ public class BcelWeaver { } return type; } else { - // FIXME AV - better warning upon no such aspect from aop.xml - RuntimeException ex = new RuntimeException("Cannot register non aspect: " + type.getName() + " , " + aspectName); - if (trace.isTraceEnabled()) { - trace.exit("addLibraryAspect", ex); - } - throw ex; + if (type.isMissing()) { + // May not be found if not visible to the classloader that can see the aop.xml during LTW + IMessage message = new Message("The specified aspect '"+aspectName+"' cannot be found", null, true); + world.getMessageHandler().handleMessage(message); + } else { + IMessage message = new Message("Cannot register '"+aspectName+"' because the type found with that name is not an aspect", null, true); + world.getMessageHandler().handleMessage(message); + } + return null; } } @@ -694,8 +697,7 @@ public class BcelWeaver { // if numFormals > 0 then every branch of a disjunction must bind each // formal once and only once. // in addition, the left and right branches of a disjunction must hold on - // join point kinds in - // common. + // join point kinds in common. private void validateBindings(Pointcut dnfPointcut, Pointcut userPointcut, int numFormals, String[] names) { if (numFormals == 0) { return; // nothing to check @@ -737,8 +739,7 @@ public class BcelWeaver { int kindsInCommon = left.couldMatchKinds() & right.couldMatchKinds(); if (kindsInCommon != Shadow.NO_SHADOW_KINDS_BITS && couldEverMatchSameJoinPoints(left, right)) { // we know that every branch binds every formal, so there is no - // ambiguity - // if each branch binds it in exactly the same way... + // ambiguity if each branch binds it in exactly the same way... List<String> ambiguousNames = new ArrayList<String>(); for (int i = 0; i < numFormals; i++) { if (leftBindings[i] == null) { @@ -799,10 +800,9 @@ public class BcelWeaver { validateSingleBranchRecursion(and.getLeft(), userPointcut, foundFormals, names, bindings); validateSingleBranchRecursion(and.getRight(), userPointcut, foundFormals, names, bindings); } else if (pc instanceof NameBindingPointcut) { - List/* BindingTypePattern */btps = ((NameBindingPointcut) pc).getBindingTypePatterns(); - for (Iterator iter = btps.iterator(); iter.hasNext();) { - BindingTypePattern btp = (BindingTypePattern) iter.next(); - int index = btp.getFormalIndex(); + List<BindingTypePattern> bindingTypePatterns = ((NameBindingPointcut) pc).getBindingTypePatterns(); + for (BindingTypePattern bindingTypePattern: bindingTypePatterns) { + int index = bindingTypePattern.getFormalIndex(); bindings[index] = pc; if (foundFormals[index]) { raiseAmbiguousBindingError(names[index], userPointcut); @@ -810,10 +810,9 @@ public class BcelWeaver { foundFormals[index] = true; } } - List/* BindingPattern */baps = ((NameBindingPointcut) pc).getBindingAnnotationTypePatterns(); - for (Iterator iter = baps.iterator(); iter.hasNext();) { - BindingPattern bap = (BindingPattern) iter.next(); - int index = bap.getFormalIndex(); + List<BindingPattern> bindingAnnotationTypePatterns = ((NameBindingPointcut) pc).getBindingAnnotationTypePatterns(); + for (BindingPattern bindingAnnotationTypePattern: bindingAnnotationTypePatterns) { + int index = bindingAnnotationTypePattern.getFormalIndex(); bindings[index] = pc; if (foundFormals[index]) { raiseAmbiguousBindingError(names[index], userPointcut); @@ -909,13 +908,9 @@ public class BcelWeaver { .getSourceContext().makeSourceLocation(userPointcut), null); } - /** - * @param name - * @param userPointcut - */ - private void raiseAmbiguousBindingError(String name, Pointcut userPointcut) { - world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.AMBIGUOUS_BINDING, name), userPointcut - .getSourceContext().makeSourceLocation(userPointcut), null); + private void raiseAmbiguousBindingError(String name, Pointcut pointcut) { + world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.AMBIGUOUS_BINDING, name), pointcut + .getSourceContext().makeSourceLocation(pointcut), null); } /** diff --git a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java index 869ed5819..2655a3456 100644 --- a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java +++ b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java @@ -24,7 +24,6 @@ import java.util.List; import java.util.ListIterator; import java.util.Map; import java.util.Set; -import java.util.Stack; import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.classfile.Attribute; @@ -688,8 +687,7 @@ public final class LazyMethodGen implements Traceable { } } int ecounter = 0; - for (Iterator i = exnTable.iterator(); i.hasNext();) { - ExceptionRange er = (ExceptionRange) i.next(); + for (ExceptionRange er: exnTable) { String exceptionLabel = "E" + ecounter++; labelMap.put(Range.getRealStart(er.getHandler()), exceptionLabel); labelMap.put(er.getHandler(), exceptionLabel); @@ -1022,7 +1020,8 @@ public final class LazyMethodGen implements Traceable { } else { packBody(gen); } - gen.setMaxLocals(); + + gen.setMaxLocals(true); gen.setMaxStack(); } else { gen.setInstructionList(null); diff --git a/weaver/src/org/aspectj/weaver/bcel/UnwovenClassFile.java b/weaver/src/org/aspectj/weaver/bcel/UnwovenClassFile.java index 79a96c775..d02c90130 100644 --- a/weaver/src/org/aspectj/weaver/bcel/UnwovenClassFile.java +++ b/weaver/src/org/aspectj/weaver/bcel/UnwovenClassFile.java @@ -71,10 +71,10 @@ public class UnwovenClassFile implements IUnwovenClassFile { } public void writeUnchangedBytes() throws IOException { - writeWovenBytes(getBytes(), Collections.EMPTY_LIST); + writeWovenBytes(getBytes(), Collections.<ChildClass>emptyList()); } - public void writeWovenBytes(byte[] bytes, List childClasses) throws IOException { + public void writeWovenBytes(byte[] bytes, List<ChildClass> childClasses) throws IOException { writeChildClasses(childClasses); // System.err.println("should write: " + getClassName()); diff --git a/weaver/testsrc/org/aspectj/weaver/bcel/ArgsWeaveTestCase.java b/weaver/testsrc/org/aspectj/weaver/bcel/ArgsWeaveTestCase.java index 3148cbdaf..8e7f72f4f 100644 --- a/weaver/testsrc/org/aspectj/weaver/bcel/ArgsWeaveTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/bcel/ArgsWeaveTestCase.java @@ -22,6 +22,7 @@ import org.aspectj.apache.bcel.generic.InstructionFactory; import org.aspectj.apache.bcel.generic.InstructionHandle; import org.aspectj.apache.bcel.generic.InstructionList; import org.aspectj.apache.bcel.generic.Type; +import org.aspectj.weaver.Advice; import org.aspectj.weaver.AdviceKind; import org.aspectj.weaver.MemberImpl; import org.aspectj.weaver.ResolvedType; @@ -54,8 +55,7 @@ public class ArgsWeaveTestCase extends WeaveTestCase { } public void testLots() throws IOException { - List l = new ArrayList(); - + List<Advice> l = new ArrayList(); BcelAdvice p1 = makeArgsMunger("before"); @@ -70,7 +70,6 @@ public class ArgsWeaveTestCase extends WeaveTestCase { l.add(p2); l.add(p3); - weaveTest("HelloWorld", "ArgsBeforeAfterHelloWorld", addLexicalOrder(l)); } diff --git a/weaver5/java5-src/org/aspectj/weaver/reflect/JavaLangTypeToResolvedTypeConverter.java b/weaver5/java5-src/org/aspectj/weaver/reflect/JavaLangTypeToResolvedTypeConverter.java index 51a9a4e84..30983e38f 100644 --- a/weaver5/java5-src/org/aspectj/weaver/reflect/JavaLangTypeToResolvedTypeConverter.java +++ b/weaver5/java5-src/org/aspectj/weaver/reflect/JavaLangTypeToResolvedTypeConverter.java @@ -66,10 +66,20 @@ public class JavaLangTypeToResolvedTypeConverter { return getWorld().resolve(name); } } else if (type instanceof ParameterizedType) { + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=509327 + // TODO should deal with the ownerType if it set, indicating this is possibly an inner type of a parameterized type + Type ownerType = ((ParameterizedType) type).getOwnerType(); ParameterizedType parameterizedType = (ParameterizedType) type; ResolvedType baseType = fromType(parameterizedType.getRawType()); - if (!baseType.isRawType()) throw new IllegalStateException("Expected raw type form of "+parameterizedType.getRawType().getTypeName()); Type[] typeArguments = parameterizedType.getActualTypeArguments(); + if (baseType.isSimpleType() && typeArguments.length == 0 && ownerType != null) { + // 'type' is an inner type of some outer parameterized type + // For now just return the base type - in future create the parameterized form of the outer + // and use it with the inner. We return the base type to be compatible with what the + // code does that accesses the info from the bytecode (unlike this code which accesses it + // reflectively). + return baseType; + } ResolvedType[] resolvedTypeArguments = fromTypes(typeArguments); return TypeFactory.createParameterizedType(baseType, resolvedTypeArguments, getWorld()); } else if (type instanceof java.lang.reflect.TypeVariable) { diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionWorldTest.java b/weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionWorldTest.java index cbde8e680..2310ad0a9 100644 --- a/weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionWorldTest.java +++ b/weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionWorldTest.java @@ -11,14 +11,27 @@ * ******************************************************************/ package org.aspectj.weaver.reflect; -import junit.framework.TestCase; +import java.lang.reflect.Method; +import java.lang.reflect.Type; +<<<<<<< HEAD import java.util.List; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.UnresolvedType; import org.aspectj.weaver.World; import org.aspectj.weaver.patterns.ConcreteCflowPointcut; +======= +import org.aspectj.bridge.IMessageHandler; +import org.aspectj.weaver.ReferenceType; +import org.aspectj.weaver.ResolvedMember; +import org.aspectj.weaver.ResolvedType; +import org.aspectj.weaver.UnresolvedType; +import org.aspectj.weaver.World; +import org.aspectj.weaver.bcel.BcelWorld; + +import junit.framework.TestCase; +>>>>>>> master public class ReflectionWorldTest extends TestCase { @@ -64,4 +77,156 @@ public class ReflectionWorldTest extends TestCase { ResolvedType resolvedType2 = converter.fromType(ConcreteClass.class); } + public void testTypeConversions_509327() throws Exception { + ReflectionWorld rWorld = new ReflectionWorld(getClass().getClassLoader()); + JavaLangTypeToResolvedTypeConverter converter = new JavaLangTypeToResolvedTypeConverter(rWorld); + + // Check basic conversion of String to String + Method method = TestClass.class.getDeclaredMethod("m"); + Type stringType = method.getGenericReturnType(); + assertEquals("java.lang.String",stringType.getTypeName()); + ResolvedType stringResolvedType = converter.fromType(stringType); + assertEquals("java.lang.String",stringResolvedType.getName()); + + // public String m() { return ""; } + method = TestClass2.class.getDeclaredMethod("m"); + stringType = method.getGenericReturnType(); + assertEquals("java.lang.String",stringType.getTypeName()); + stringResolvedType = converter.fromType(stringType); + assertEquals("java.lang.String",stringResolvedType.getName()); + + // Verify that the conversion process creates the same thing as the bcel unpacking + + // Here the return type is a non-static inner of a generic class + // public Inner m2() { return null; } + method = TestClass2.class.getDeclaredMethod("m2"); + Type innerType = method.getGenericReturnType(); + assertEquals("org.aspectj.weaver.reflect.ReflectionWorldTest.org.aspectj.weaver.reflect.ReflectionWorldTest$TestClass2<T>.Inner",innerType.getTypeName()); + ResolvedType rType_Inner = converter.fromType(innerType); + assertEquals("Lorg/aspectj/weaver/reflect/ReflectionWorldTest$TestClass2$Inner;",rType_Inner.getSignature()); + assertEquals(UnresolvedType.TypeKind.SIMPLE,rType_Inner.getTypekind()); + ResolvedType rType_Outer = rType_Inner.getOuterClass(); + assertEquals("Lorg/aspectj/weaver/reflect/ReflectionWorldTest$TestClass2;",rType_Outer.getSignature()); + + BcelWorld bWorld = new BcelWorld(getClass().getClassLoader(), IMessageHandler.THROW, null); + bWorld.setBehaveInJava5Way(true); + UnresolvedType javaUtilHashMap = UnresolvedType.forName("java.util.HashMap"); + ReferenceType rawType = (ReferenceType) bWorld.resolve(javaUtilHashMap); + assertNotNull(rawType); + + // Now use bcel to resolve the same m2 method, and compare the signatures of the return types + ResolvedType bResolved_TestClass2 = bWorld.resolve(UnresolvedType.forName(TestClass2.class.getName())); + assertNotNull(bResolved_TestClass2); + ResolvedMember bMethod_m2 = findMethod(bResolved_TestClass2,"m2"); + ResolvedType bType_Inner = (ResolvedType) bMethod_m2.getReturnType(); + assertEquals("Lorg/aspectj/weaver/reflect/ReflectionWorldTest$TestClass2$Inner;",bType_Inner.getSignature()); + assertEquals(UnresolvedType.TypeKind.SIMPLE,bType_Inner.getTypekind()); + ResolvedType bType_Outer = bType_Inner.getOuterClass(); + assertEquals("Lorg/aspectj/weaver/reflect/ReflectionWorldTest$TestClass2;",bType_Outer.getSignature()); + + assertEquals(bType_Inner.getSignature(),rType_Inner.getSignature()); + assertEquals(bType_Outer.getSignature(),rType_Outer.getSignature()); + } + + + public void testTypeConversions_509327_2() throws Exception { + ReflectionWorld world = new ReflectionWorld(getClass().getClassLoader()); + JavaLangTypeToResolvedTypeConverter converter = new JavaLangTypeToResolvedTypeConverter(world); + BcelWorld bWorld = new BcelWorld(getClass().getClassLoader(), IMessageHandler.THROW, null); + bWorld.setBehaveInJava5Way(true); + + // Slightly more advanced, now the method is returning a parameterized form of the outer + // generic class + + // public TestClass2<String>.Inner m3() { return new TestClass2<String>.Inner("Foo"); } + Method method = TestClass2.class.getDeclaredMethod("m3"); + Type type_ParameterizedInner = method.getGenericReturnType(); + assertEquals("org.aspectj.weaver.reflect.ReflectionWorldTest.org.aspectj.weaver.reflect.ReflectionWorldTest$TestClass2<java.lang.String>.Inner",type_ParameterizedInner.getTypeName()); + ResolvedType rType_ParameterizedInner = converter.fromType(type_ParameterizedInner); + // NOTE: DECLARED PARAMETERIZATION OF OUTER IS LOST + assertEquals("Lorg/aspectj/weaver/reflect/ReflectionWorldTest$TestClass2$Inner;",rType_ParameterizedInner.getSignature()); + + ResolvedType bResolved_TestClass2 = bWorld.resolve(UnresolvedType.forName(TestClass2.class.getName())); + assertNotNull(bResolved_TestClass2); + ResolvedMember bMethod_m3 = findMethod(bResolved_TestClass2,"m3"); + ResolvedType bType_Inner = (ResolvedType) bMethod_m3.getReturnType(); + // NOTE: DECLARED PARAMETERIZATION OF OUTER IS LOST + assertEquals("Lorg/aspectj/weaver/reflect/ReflectionWorldTest$TestClass2$Inner;",bType_Inner.getSignature()); + + assertEquals(UnresolvedType.TypeKind.SIMPLE,bType_Inner.getTypekind()); + ResolvedType bType_Outer = bType_Inner.getOuterClass(); + + // Fields seem to lose it too, although the backinggenericmember has the info +// ResolvedMember bField_f = findField(bResolved_TestClass2,"f"); +// ResolvedMember backingGenericMember = bField_f.getBackingGenericMember(); +// System.out.println(backingGenericMember); +// System.out.println(backingGenericMember.getGenericReturnType()); +// System.out.println(bField_f); +// System.out.println(bField_f.getSignature()); +// System.out.println(bField_f.getGenericReturnType()); + } + +// public void testbar() throws Exception { +// ReflectionWorld world = new ReflectionWorld(getClass().getClassLoader()); +// JavaLangTypeToResolvedTypeConverter converter = new JavaLangTypeToResolvedTypeConverter(world); +// +// // public TestClass2<String>.Inner m3() { return new TestClass2<String>.Inner("Foo"); } +// Method method = TestClass2.class.getDeclaredMethod("m3"); +// Type type_ParameterizedInner = method.getGenericReturnType(); +// assertEquals("org.aspectj.weaver.reflect.ReflectionWorldTest.org.aspectj.weaver.reflect.ReflectionWorldTest$TestClass2<java.lang.String>.Inner",type_ParameterizedInner.getTypeName()); +// ResolvedType rType_ParameterizedInner = converter.fromType(type_ParameterizedInner); +// System.out.println(rType_ParameterizedInner); +// System.out.println(type_ParameterizedInner.getTypeName()); +// } +// +// public void testfoo() { +// ReflectionWorld world = new ReflectionWorld(getClass().getClassLoader()); +// JavaLangTypeToResolvedTypeConverter converter = new JavaLangTypeToResolvedTypeConverter(world); +// BcelWorld bWorld = new BcelWorld(getClass().getClassLoader(), IMessageHandler.THROW, null); +// bWorld.setBehaveInJava5Way(true); +// +// +// ResolvedType bResolved_TestClass2 = bWorld.resolve(UnresolvedType.forName(TestClass2.class.getName())); +// ResolvedMember bField_f = findField(bResolved_TestClass2,"f"); +// System.out.println(bField_f); +// System.out.println(bField_f.getGenericReturnType()); +// System.out.println(bField_f.getReturnType()); +// System.out.println(bField_f.getBackingGenericMember().getGenericReturnType()); +// } + + static class TestClass { + public String m() { return ""; } + } + + static class TestClass2<T> { + class Inner { + T t; + Inner(T t) { + this.t = t; + } + } + public String m() { return ""; } + public Inner m2() { return null; } + public TestClass2<String> f; + public TestClass2<String>.Inner m3() { return new TestClass2<String>.Inner("Foo"); } + } + + private ResolvedMember findMethod(ResolvedType resolvedType, String methodName) { + for (ResolvedMember method: resolvedType.getDeclaredMethods()) { + if (method.getName().equals(methodName)) { + return method; + } + } + return null; + } + + private ResolvedMember findField(ResolvedType resolvedType, String fieldName) { + for (ResolvedMember field: resolvedType.getDeclaredFields()) { + if (field.getName().equals(fieldName)) { + return field; + } + } + return null; + } + } diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java b/weaver5/java5-testsrc/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java index 9b155df3e..f651a2f29 100644 --- a/weaver5/java5-testsrc/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java +++ b/weaver5/java5-testsrc/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java @@ -105,11 +105,11 @@ public class Java15PointcutExpressionTest extends TestCase { PointcutExpression pexpr = null; ShadowMatch match = null; - Method n = test.AnnoValues.class.getMethod("none",null); - Method r = test.AnnoValues.class.getMethod("redMethod",null); - Method g = test.AnnoValues.class.getMethod("greenMethod",null); - Method b = test.AnnoValues.class.getMethod("blueMethod",null); - Method d = test.AnnoValues.class.getMethod("defaultMethod",null); + Method n = test.AnnoValues.class.getMethod("none"); + Method r = test.AnnoValues.class.getMethod("redMethod"); + Method g = test.AnnoValues.class.getMethod("greenMethod"); + Method b = test.AnnoValues.class.getMethod("blueMethod"); + Method d = test.AnnoValues.class.getMethod("defaultMethod"); pexpr = p.parsePointcutExpression("execution(@test.A3(test.Color.RED) public void *(..))"); assertTrue("Should match", pexpr.matchesMethodExecution(n).neverMatches()); // default value RED |