@@ -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; |
@@ -1082,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; |
@@ -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); | |||
} | |||
@@ -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); |
@@ -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"; |
@@ -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..."; | |||
} | |||
} | |||
} |
@@ -196,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 " |
@@ -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(); |
@@ -72,7 +72,7 @@ public class ModulesTest extends TestCase { | |||
} | |||
} | |||
ArrayList tempFiles = new ArrayList(); | |||
ArrayList<File> tempFiles = new ArrayList<>(); | |||
public ModulesTest(String name) { | |||
super(name); |
@@ -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())) { |
@@ -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 |
@@ -123,19 +123,19 @@ public class Ajctest extends Task implements PropertyChangeListener { | |||
//fields | |||
private String testId = NO_TESTID; | |||
private List args = new Vector(); | |||
private List testsets = new Vector(); | |||
private List<Argument> args = new Vector<>(); | |||
private List<Testset> testsets = new Vector<>(); | |||
private Path classpath; | |||
private Path internalclasspath; | |||
private File destdir; | |||
private File dir; | |||
private File errorfile; | |||
private List testclasses = new Vector(); | |||
private List<Run> testclasses = new Vector<>(); | |||
private boolean nocompile; | |||
private Ajdoc ajdoc = null; | |||
private boolean noclean; | |||
private boolean noverify; | |||
private List depends = new Vector(); | |||
private List<String> depends = new Vector<>(); | |||
//end-fields | |||
public Argfile createArgfile() { | |||
@@ -321,7 +321,7 @@ public class Ajctest extends Task implements PropertyChangeListener { | |||
public static class Argument { | |||
private String name; | |||
private List values = new Vector(); | |||
private List<String> values = new Vector<>(); | |||
private boolean always = true; | |||
final boolean isj; | |||
public Argument(boolean isj) { | |||
@@ -332,14 +332,14 @@ public class Ajctest extends Task implements PropertyChangeListener { | |||
("-" + (str.startsWith("J") ? str.substring(1) : str)); | |||
} | |||
public void setValues(String str) { | |||
values = new Vector(); | |||
values = new Vector<>(); | |||
StringTokenizer tok = new StringTokenizer(str, ", ", false); | |||
while (tok.hasMoreTokens()) { | |||
values.add(tok.nextToken().trim()); | |||
} | |||
} | |||
public void setValue(String value) { | |||
(values = new Vector()).add(value); | |||
(values = new Vector<>()).add(value); | |||
} | |||
public void setAlways(boolean always) { | |||
this.always = always; | |||
@@ -401,30 +401,30 @@ public class Ajctest extends Task implements PropertyChangeListener { | |||
} | |||
public class Testset extends FileSet { | |||
private List argfileNames = new Vector(); | |||
public List argfiles; | |||
public List files; | |||
public List args = new Vector(); | |||
private List<Argfile> argfileNames = new Vector<>(); | |||
public List<File> argfiles; | |||
public List<File> files; | |||
public List<Argument> args = new Vector<>(); | |||
public String classname; | |||
private boolean havecludes = false; | |||
private List testclasses = new Vector(); | |||
private List<Run> testclasses = new Vector<>(); | |||
private Path classpath; | |||
private Path internalclasspath; | |||
private Ajdoc ajdoc = null; | |||
private boolean fork = false; | |||
private boolean noclean; | |||
private List depends = new Vector(); | |||
private List<String> depends = new Vector<>(); | |||
public String toString() { | |||
String str = ""; | |||
if (files.size() > 0) { | |||
str += "files:" + "\n"; | |||
for (Iterator i = files.iterator(); i.hasNext();) { | |||
for (Iterator<File> i = files.iterator(); i.hasNext();) { | |||
str += "\t" + i.next() + "\n"; | |||
} | |||
} | |||
if (argfiles.size() > 0) { | |||
str += "argfiles:" + "\n"; | |||
for (Iterator i = argfiles.iterator(); i.hasNext();) { | |||
for (Iterator<File> i = argfiles.iterator(); i.hasNext();) { | |||
str += "\t" + i.next() + "\n"; | |||
} | |||
} | |||
@@ -578,10 +578,10 @@ public class Ajctest extends Task implements PropertyChangeListener { | |||
public void resolve() throws BuildException { | |||
if (dir != null) this.setDir(dir); | |||
File src = getDir(project); | |||
argfiles = new Vector(); | |||
files = new Vector(); | |||
for(Iterator iter = argfileNames.iterator(); iter.hasNext();) { | |||
String name = ((Argfile)iter.next()).name; | |||
argfiles = new Vector<>(); | |||
files = new Vector<>(); | |||
for(Iterator<Argfile> iter = argfileNames.iterator(); iter.hasNext();) { | |||
String name = iter.next().name; | |||
File argfile = new File(src, name); | |||
if (check(argfile, name, location)) argfiles.add(argfile); | |||
} | |||
@@ -610,8 +610,8 @@ public class Ajctest extends Task implements PropertyChangeListener { | |||
this.ajdoc = Ajctest.this.ajdoc; | |||
} | |||
if (this.fork) { | |||
for (Iterator i = this.testclasses.iterator(); i.hasNext();) { | |||
((Run)i.next()).setFork(fork); | |||
for (Iterator<Run> i = this.testclasses.iterator(); i.hasNext();) { | |||
i.next().setFork(fork); | |||
} | |||
} | |||
if (!this.noclean) { | |||
@@ -687,40 +687,36 @@ public class Ajctest extends Task implements PropertyChangeListener { | |||
} | |||
private void log(String space, List list, String title) { | |||
private void log(String space, List<?> list, String title) { | |||
if (list == null || list.size() < 1) return; | |||
log(space + title); | |||
for (Iterator i = list.iterator(); i.hasNext();) { | |||
for (Iterator<?> i = list.iterator(); i.hasNext();) { | |||
log(space + " " + i.next()); | |||
} | |||
} | |||
private void execute(Testset testset, List args) throws BuildException { | |||
private void execute(Testset testset, List<Arg> args) throws BuildException { | |||
if (testset.files.size() > 0) { | |||
log("\tfiles:"); | |||
for (Iterator i = testset.files.iterator(); | |||
i.hasNext();) { | |||
for (Iterator<File> i = testset.files.iterator(); i.hasNext();) { | |||
log("\t " + i.next()); | |||
} | |||
} | |||
if (testset.argfiles.size() > 0) { | |||
log("\targfiles:"); | |||
for (Iterator i = testset.argfiles.iterator(); | |||
i.hasNext();) { | |||
for (Iterator<File> i = testset.argfiles.iterator(); i.hasNext();) { | |||
log("\t " + i.next()); | |||
} | |||
} | |||
if (args.size() > 0) { | |||
log("\targs:"); | |||
for (Iterator i = args.iterator(); | |||
i.hasNext();) { | |||
for (Iterator<Arg> i = args.iterator(); i.hasNext();) { | |||
log("\t " + i.next()); | |||
} | |||
} | |||
if (testset.testclasses.size() > 0) { | |||
log("\tclasses:"); | |||
for (Iterator i = testset.testclasses.iterator(); | |||
i.hasNext();) { | |||
for (Iterator<Run> i = testset.testclasses.iterator(); i.hasNext();) { | |||
log("\t " + i.next()); | |||
} | |||
} | |||
@@ -731,7 +727,7 @@ public class Ajctest extends Task implements PropertyChangeListener { | |||
} | |||
delete(workingdir); | |||
make(workingdir); | |||
for (Iterator i = testset.depends.iterator(); i.hasNext();) { | |||
for (Iterator<String> i = testset.depends.iterator(); i.hasNext();) { | |||
String target = i.next()+""; | |||
// todo: capture failures here? | |||
project.executeTarget(target); | |||
@@ -788,9 +784,8 @@ public class Ajctest extends Task implements PropertyChangeListener { | |||
-1, "run"); | |||
} else if (!isSet("norun")) { | |||
for (Iterator i = testset.testclasses.iterator(); | |||
i.hasNext();) { | |||
Run testclass = (Run)i.next(); | |||
for (Iterator<Run> i = testset.testclasses.iterator(); i.hasNext();) { | |||
Run testclass = i.next(); | |||
log("\ttest..." + testclass.classname()); | |||
if (null != destdir) { | |||
testclass.setClassesDir(destdir.getAbsolutePath()); | |||
@@ -812,27 +807,26 @@ public class Ajctest extends Task implements PropertyChangeListener { | |||
prepare(); | |||
log(testsets.size() + " testset" + s(testsets), | |||
Project.MSG_VERBOSE); | |||
Map testsetToArgcombo = new HashMap(); | |||
List argcombos = new Vector(); | |||
for (Iterator iter = testsets.iterator(); iter.hasNext();) { | |||
Testset testset = (Testset)iter.next(); | |||
Map<Testset,List<List<Arg>>> testsetToArgcombo = new HashMap<>(); | |||
List<Integer> argcombos = new Vector<>(); | |||
for (Testset testset: testsets) { | |||
testset.resolve(); | |||
List bothargs = new Vector(args); | |||
List<Argument> bothargs = new Vector<>(args); | |||
bothargs.addAll(testset.args); | |||
List argcombo = argcombo(bothargs); | |||
List<List<Arg>> argcombo = argcombo(bothargs); | |||
argcombos.add(new Integer(argcombo.size())); | |||
testsetToArgcombo.put(testset, argcombo); | |||
} | |||
while (!testsetToArgcombo.isEmpty()) { | |||
int _ = 1; | |||
for (Iterator iter = testsets.iterator(); iter.hasNext(); _++) { | |||
Testset testset = (Testset)iter.next(); | |||
List argcombo = (List)testsetToArgcombo.get(testset); | |||
for (Iterator<Testset> iter = testsets.iterator(); iter.hasNext(); _++) { | |||
Testset testset = iter.next(); | |||
List<List<Arg>> argcombo = testsetToArgcombo.get(testset); | |||
if (argcombo.size() == 0) { | |||
testsetToArgcombo.remove(testset); | |||
continue; | |||
} | |||
List args = (List)argcombo.remove(0); | |||
List<Arg> args = argcombo.remove(0); | |||
final String startStr = "Testset " + _ + " of " + testsets.size(); | |||
String str = startStr + " / Combo " + _ + " of " + argcombos.size(); | |||
log("---------- " + str + " ----------"); | |||
@@ -1085,7 +1079,7 @@ public class Ajctest extends Task implements PropertyChangeListener { | |||
// } | |||
private static List allErrors = new Vector(); | |||
private List errors = new Vector(); | |||
private List<Failure> errors = new Vector<>(); | |||
private void post(Testset testset, List args, | |||
String msgs, int exit, String type) { | |||
@@ -1290,11 +1284,11 @@ public class Ajctest extends Task implements PropertyChangeListener { | |||
} | |||
} | |||
private List argcombo(List arguments) { | |||
List combos = new Vector(); | |||
List always = new Vector(); | |||
for (Iterator iter = arguments.iterator(); iter.hasNext();) { | |||
Argument arg = (Argument)iter.next(); | |||
private List<List<Arg>> argcombo(List<Argument> arguments) { | |||
List<Argument> combos = new Vector<>(); | |||
List<Arg> always = new Vector<>(); | |||
for (Iterator<Argument> iter = arguments.iterator(); iter.hasNext();) { | |||
Argument arg = iter.next(); | |||
if (arg.values.size() == 0) arg.values.add(""); | |||
if (!arg.always && !arg.values.contains(null)) arg.values.add(null); | |||
if (arg.values.size() > 0) { | |||
@@ -1303,11 +1297,11 @@ public class Ajctest extends Task implements PropertyChangeListener { | |||
always.add(new Arg(arg.name, arg.values.get(0)+"", arg.isj)); | |||
} | |||
} | |||
List argcombo = combinations(combos); | |||
for (Iterator iter = always.iterator(); iter.hasNext();) { | |||
Arg arg = (Arg)iter.next(); | |||
for (Iterator comboiter = argcombo.iterator(); comboiter.hasNext();) { | |||
((List)comboiter.next()).add(arg); | |||
List<List<Arg>> argcombo = combinations(combos); | |||
for (Iterator<Arg> iter = always.iterator(); iter.hasNext();) { | |||
Arg arg = iter.next(); | |||
for (Iterator<List<Arg>> comboiter = argcombo.iterator(); comboiter.hasNext();) { | |||
comboiter.next().add(arg); | |||
} | |||
} | |||
return argcombo; | |||
@@ -1624,16 +1618,16 @@ public class Ajctest extends Task implements PropertyChangeListener { | |||
log("done handling " + t); | |||
} | |||
private List combinations(List arglist) { | |||
List result = new Vector(); | |||
result.add(new Vector()); | |||
for (Iterator iter = arglist.iterator(); iter.hasNext();) { | |||
Argument arg = (Argument)iter.next(); | |||
private List<List<Arg>> combinations(List<Argument> arglist) { | |||
List<List<Arg>> result = new Vector<>(); | |||
result.add(new Vector<Arg>()); | |||
for (Iterator<Argument> iter = arglist.iterator(); iter.hasNext();) { | |||
Argument arg = iter.next(); | |||
int N = result.size(); | |||
for (int i = 0; i < N; i++) { | |||
List to = (List)result.remove(0); | |||
for (Iterator valiter = arg.values.iterator(); valiter.hasNext();) { | |||
List newlist = new Vector(to); | |||
List<Arg> to = result.remove(0); | |||
for (Iterator<String> valiter = arg.values.iterator(); valiter.hasNext();) { | |||
List<Arg> newlist = new Vector<>(to); | |||
Object val = valiter.next(); | |||
if (val != null) newlist.add(new Arg(arg.name, val+"", arg.isj)); | |||
result.add(newlist); |
@@ -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())) { |
@@ -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); |
@@ -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) |
@@ -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; | |||
} |
@@ -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); | |||
} | |||
/** |
@@ -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); | |||
} | |||
} |
@@ -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); | |||
} | |||
} |
@@ -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+")"); | |||
} | |||
} |
@@ -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+")"); | |||
} | |||
} |
@@ -0,0 +1,9 @@ | |||
package com.myapp; | |||
public class ApplicationException extends Exception { | |||
private static final long serialVersionUID = 1L; | |||
public ApplicationException(String message) { | |||
super(message); | |||
} | |||
} |
@@ -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); | |||
} |
@@ -0,0 +1,4 @@ | |||
public abstract class Code { | |||
public void m(String str1) {} | |||
public abstract void m2(String str2); | |||
} |
@@ -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 { | |||
/*========================================== |
@@ -12,17 +12,14 @@ package org.aspectj.systemtest.ajc151; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.io.PrintWriter; | |||
import junit.framework.Test; | |||
import org.aspectj.ajdt.internal.core.builder.AsmHierarchyBuilder; | |||
import org.aspectj.asm.AsmManager; | |||
import org.aspectj.asm.IHierarchy; | |||
import org.aspectj.asm.IProgramElement; | |||
import org.aspectj.systemtest.ajc150.GenericsTests; | |||
import org.aspectj.testing.XMLBasedAjcTestCase; | |||
import org.aspectj.weaver.UnresolvedType.TypeKind; | |||
import junit.framework.Test; | |||
public class Ajc151Tests extends org.aspectj.testing.XMLBasedAjcTestCase { | |||
@@ -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); | |||
} | |||
@@ -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"); | |||
} |
@@ -10,8 +10,6 @@ | |||
*******************************************************************************/ | |||
package org.aspectj.systemtest.ajc180; | |||
import org.aspectj.systemtest.ajc181.Ajc181Tests; | |||
import junit.framework.Test; | |||
import junit.framework.TestSuite; | |||
@@ -12,24 +12,38 @@ 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_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"); | |||
} |
@@ -2,6 +2,74 @@ | |||
<suite> | |||
<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> |
@@ -12,7 +12,6 @@ package org.aspectj.systemtest.ajc182; | |||
import junit.framework.Test; | |||
import junit.framework.TestSuite; | |||
import org.aspectj.systemtest.apt.AptTests; | |||
public class AllTestsAspectJ182 { | |||
@@ -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 | |||
*/ |
@@ -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 | |||
*/ |
@@ -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 { | |||
@@ -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 { | |||
@@ -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; | |||
@@ -392,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(); |
@@ -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) { |
@@ -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 | |||
} | |||
} | |||
@@ -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)) { |
@@ -1233,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()); | |||
} | |||
@@ -2646,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"); | |||
@@ -2827,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"); | |||
@@ -2965,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; | |||
} | |||
@@ -3302,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 |
@@ -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")); |
@@ -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 { | |||
@@ -3048,13 +3048,10 @@ 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)); | |||
} | |||
} | |||