WeavingURLClassLoader loader = new WeavingURLClassLoader(getClass().getClassLoader());
try {
- Class clazz = loader.loadClass("LTWHelloWorld");
+ Class<?> clazz = loader.loadClass("LTWHelloWorld");
invokeMain(clazz, new String[] {});
} catch (Exception ex) {
fail(ex.toString());
WeavingURLClassLoader loader = new WeavingURLClassLoader(getClass().getClassLoader());
try {
- Class clazz = loader.loadClass("LTWHelloWorld");
+ Class<?> clazz = loader.loadClass("LTWHelloWorld");
invokeMain(clazz, new String[] { "LTWAspect" });
} catch (Exception ex) {
fail(ex.toString());
WeavingURLClassLoader loader = new WeavingURLClassLoader(classURLs, aspectURLs, getClass().getClassLoader());
try {
- Class clazz = loader.loadClass("LTWHelloWorld");
+ Class<?> clazz = loader.loadClass("LTWHelloWorld");
invokeMain(clazz, new String[] { "LTWAspect" });
} catch (Exception ex) {
fail(ex.toString());
WeavingURLClassLoader loader = new WeavingURLClassLoader(getClass().getClassLoader());
try {
- Class clazz = loader.loadClass("LTWHelloWorld");
+ Class<?> clazz = loader.loadClass("LTWHelloWorld");
invokeMain(clazz, new String[] { "LTWAspect" });
} catch (Exception ex) {
fail(ex.toString());
WeavingURLClassLoader loader = new WeavingURLClassLoader(getClass().getClassLoader());
try {
- Class clazz = loader.loadClass("LTWHelloWorld");
+ Class<?> clazz = loader.loadClass("LTWHelloWorld");
invokeMain(clazz, new String[] { "LTWAspect" });
} catch (Exception ex) {
fail(ex.toString());
WeavingURLClassLoader loader = new WeavingURLClassLoader(getClass().getClassLoader());
try {
- Class clazz = loader.loadClass("LTWHelloWorld");
+ Class<?> clazz = loader.loadClass("LTWHelloWorld");
invokeMain(clazz, new String[] { "LTWAspect" });
} catch (Exception ex) {
fail(ex.toString());
WeavingURLClassLoader loader = new WeavingURLClassLoader(getClass().getClassLoader());
try {
- Class clazz = loader.loadClass("LTWHelloWorld");
+ Class<?> clazz = loader.loadClass("LTWHelloWorld");
invokeMain(clazz, new String[] {});
} catch (Exception ex) {
fail(ex.toString());
WeavingURLClassLoader loader = new WeavingURLClassLoader(getClass().getClassLoader());
try {
- Class clazz = loader.loadClass("LTWHelloWorld");
+ Class<?> clazz = loader.loadClass("LTWHelloWorld");
invokeMain(clazz, new String[] {});
fail("Expecting org.aspectj.bridge.AbortException");
} catch (Exception ex) {
WeavingURLClassLoader loader = new WeavingURLClassLoader(getClass().getClassLoader());
try {
- Class clazz = loader.loadClass("LTWHelloWorld");
+ Class<?> clazz = loader.loadClass("LTWHelloWorld");
invokeMain(clazz, new String[] { "LTWAroundClosure" });
} catch (Exception ex) {
fail(ex.toString());
WeavingURLClassLoader loader = new WeavingURLClassLoader(classURLs, aspectURLs, getClass().getClassLoader());
try {
- Class clazz = loader.loadClass("LTWHelloWorld");
+ Class<?> clazz = loader.loadClass("LTWHelloWorld");
invokeMain(clazz, new String[] { "LTWInterfaceITD", "LTWFieldITD", "LTWMethodITD" });
} catch (Exception ex) {
ex.printStackTrace();
WeavingURLClassLoader loader = new WeavingURLClassLoader(classURLs, aspectURLs, getClass().getClassLoader());
try {
- Class clazz = loader.loadClass("LTWHelloWorld");
+ Class<?> clazz = loader.loadClass("LTWHelloWorld");
invokeMain(clazz, new String[] { "LTWPerthis" });
} catch (Exception ex) {
fail(ex.toString());
WeavingURLClassLoader loader = new WeavingURLClassLoader(classURLs, aspectURLs, getClass().getClassLoader());
try {
- Class clazz = loader.loadClass("LTWHelloWorld");
+ Class<?> clazz = loader.loadClass("LTWHelloWorld");
invokeMain(clazz, new String[] { "LTWAspect", "LTWAroundClosure", "LTWPerthis", "LTWInterfaceITD", "LTWFieldITD",
"LTWMethodITD", "LTWPerthis" });
} catch (Exception ex) {
loader.addURL(classes);
try {
- Class clazz = loader.loadClass("LTWHelloWorld");
+ Class<?> clazz = loader.loadClass("LTWHelloWorld");
invokeMain(clazz, new String[] { "LTWAspect" });
} catch (Exception ex) {
fail(ex.toString());
WeavingURLClassLoader child = new WeavingURLClassLoader(classURLs, aspectURLs, parent);
try {
- Class clazz = child.loadClass("LTWHelloWorld");
+ Class<?> clazz = child.loadClass("LTWHelloWorld");
invokeMain(clazz, new String[] { "LTWAspect" });
} catch (Exception ex) {
fail(ex.toString());
WeavingURLClassLoader loader = new WeavingURLClassLoader(getClass().getClassLoader());
try {
- Class clazz = loader.loadClass("LTWHelloWorld");
+ Class<?> clazz = loader.loadClass("LTWHelloWorld");
invokeMain(clazz, new String[] { "LTWAspect" });
fail("Expecting java.lang.NoClassDefFoundError");
} catch (Exception ex) {
WeavingURLClassLoader loader = new WeavingURLClassLoader(getClass().getClassLoader());
try {
- Class clazz = loader.loadClass("ltw.LTWPackageTest");
+ Class<?> clazz = loader.loadClass("ltw.LTWPackageTest");
invokeMain(clazz, new String[] {});
Package pakkage = clazz.getPackage();
assertTrue("Expected 'ltw' got " + pakkage, (pakkage != null));
URL[] aspectURLs = new URL[] { aspects };
WeavingURLClassLoader loader = new WeavingURLClassLoader(classURLs, aspectURLs, getClass().getClassLoader());
- Class clazz = loader.loadClass("packag.Main");
+ Class<?> clazz = loader.loadClass("packag.Main");
invokeMain(clazz, new String[] {});
}
URL[] aspectURLs = new URL[] { aspects };
WeavingURLClassLoader loader = new WeavingURLClassLoader(classURLs, aspectURLs, getClass().getClassLoader());
- Class clazz = loader.loadClass("packag.Main");
+ Class<?> clazz = loader.loadClass("packag.Main");
invokeMain(clazz, new String[] {});
fail("Should reject bad aspect MissingFile");
} catch (AbortException ae) {
URL[] aspectURLs = new URL[] { aspects };
ClassLoader parent = getClass().getClassLoader();
WeavingURLClassLoader loader = new WeavingURLClassLoader(classURLs, aspectURLs, parent);
- Class clazz = loader.loadClass("packag.Main");
+ Class<?> clazz = loader.loadClass("packag.Main");
invokeMain(clazz, new String[] {});
// throws Error unless advice applies
}
URL[] classURLs = new URL[] { classes, aspectjrt };
ClassLoader parent = getClass().getClassLoader();
WeavingURLClassLoader loader = new WeavingURLClassLoader(classURLs, new URL[] {}, parent);
- Class clazz = loader.loadClass("packag.Main");
+ Class<?> clazz = loader.loadClass("packag.Main");
invokeMain(clazz, new String[] {});
// throws Error because advice does not apply
}
}
public static void invokeMain(Class clazz, String[] args) {
- Class[] paramTypes = new Class[1];
+ Class<?>[] paramTypes = new Class[1];
paramTypes[0] = args.getClass();
try {
/* Restore system properties */
Properties systemProperties = System.getProperties();
- for (Enumeration enu = savedProperties.keys(); enu.hasMoreElements();) {
+ for (Enumeration<Object> enu = savedProperties.keys(); enu.hasMoreElements();) {
String key = (String) enu.nextElement();
String value = savedProperties.getProperty(key);
if (value == NULL) {
private IProblem[] buildSeeAlsoProblems(IProblem originalProblem, List sourceLocations, CompilationResult problemSource,
boolean usedBinarySourceFileName) {
- List ret = new ArrayList();
+ List<IProblem> ret = new ArrayList<IProblem>();
for (int i = 0; i < sourceLocations.size(); i++) {
ISourceLocation loc = (ISourceLocation) sourceLocations.get(i);
List missingWarnings = copyAll(expected.warnings);
List missingErrors = copyAll(expected.errors);
List missingWeaves = copyAll(expected.weaves);
- List extraFails = copyAll(result.getFailMessages());
- List extraInfos = copyAll(result.getInfoMessages());
- List extraWarnings = copyAll(result.getWarningMessages());
- List extraErrors = copyAll(result.getErrorMessages());
- List extraWeaves = copyAll(result.getWeaveMessages());
+ List<IMessage> extraFails = copyAll(result.getFailMessages());
+ List<IMessage> extraInfos = copyAll(result.getInfoMessages());
+ List<IMessage> extraWarnings = copyAll(result.getWarningMessages());
+ List<IMessage> extraErrors = copyAll(result.getErrorMessages());
+ List<IMessage> extraWeaves = copyAll(result.getWeaveMessages());
compare(expected.fails, result.getFailMessages(), missingFails, extraFails);
compare(expected.warnings, result.getWarningMessages(), missingWarnings, extraWarnings);
compare(expected.errors, result.getErrorMessages(), missingErrors, extraErrors);
/**
* Helper method to build a new message list for passing to a MessageSpec.
*/
- protected List newMessageList(Message m1) {
- List ret = new ArrayList();
+ protected List<Message> newMessageList(Message m1) {
+ List<Message> ret = new ArrayList<Message>();
ret.add(m1);
return ret;
}
/**
* Helper method to build a new message list for passing to a MessageSpec.
*/
- protected List newMessageList(Message m1, Message m2) {
- List ret = new ArrayList();
+ protected List<Message> newMessageList(Message m1, Message m2) {
+ List<Message> ret = new ArrayList<Message>();
ret.add(m1);
ret.add(m2);
return ret;
/**
* Helper method to build a new message list for passing to a MessageSpec.
*/
- protected List newMessageList(Message m1, Message m2, Message m3) {
- List ret = new ArrayList();
+ protected List<Message> newMessageList(Message m1, Message m2, Message m3) {
+ List<Message> ret = new ArrayList<Message>();
ret.add(m1);
ret.add(m2);
ret.add(m3);
import java.util.Iterator;
import java.util.List;
+import org.aspectj.bridge.IMessage;
+
/**
* Utility class that makes the results of a compiler run available.
* <p>
private String[] args;
private String stdOut;
private String stdErr;
- private List /*IMessage*/ infoMessages;
- private List /*IMessage*/ errorMessages;
- private List /*IMessage*/ warningMessages;
- private List /*IMessage*/ failMessages;
- private List /*IMessage*/ weaveMessages;
+ private List<IMessage> infoMessages;
+ private List<IMessage> errorMessages;
+ private List<IMessage> warningMessages;
+ private List<IMessage> failMessages;
+ private List<IMessage> weaveMessages;
/**
* Build a compilation result - called by the Ajc.compile and
String[] args,
String stdOut,
String stdErr,
- List infoMessages,
- List errorMessages,
- List warningMessages,
- List failMessages,
- List weaveMessages) {
+ List<IMessage> infoMessages,
+ List<IMessage> errorMessages,
+ List<IMessage> warningMessages,
+ List<IMessage> failMessages,
+ List<IMessage> weaveMessages) {
this.args = args;
this.stdOut = stdOut;
this.stdErr = stdErr;
- this.infoMessages = (infoMessages == null) ? Collections.EMPTY_LIST : infoMessages;
- this.errorMessages = (errorMessages == null) ? Collections.EMPTY_LIST : errorMessages;
- this.warningMessages = (warningMessages == null) ? Collections.EMPTY_LIST : warningMessages;
- this.failMessages = (failMessages == null) ? Collections.EMPTY_LIST : failMessages;
- this.weaveMessages = (weaveMessages == null) ? Collections.EMPTY_LIST : weaveMessages;
+ this.infoMessages = (infoMessages == null) ? Collections.<IMessage>emptyList() : infoMessages;
+ this.errorMessages = (errorMessages == null) ? Collections.<IMessage>emptyList() : errorMessages;
+ this.warningMessages = (warningMessages == null) ? Collections.<IMessage>emptyList() : warningMessages;
+ this.failMessages = (failMessages == null) ? Collections.<IMessage>emptyList() : failMessages;
+ this.weaveMessages = (weaveMessages == null) ? Collections.<IMessage>emptyList() : weaveMessages;
}
/**
* though.
* @see org.aspectj.tools.ajc.AjcTestCase
*/
- public List /*IMessage*/ getErrorMessages() { return errorMessages; }
+ public List<IMessage> getErrorMessages() { return errorMessages; }
/**
* The warning messages produced by the compiler. The list
* entries are the <code>IMessage</code> objects created during the
* though.
* @see org.aspectj.tools.ajc.AjcTestCase
*/
- public List /*IMessage*/ getWarningMessages() { return warningMessages; }
+ public List<IMessage> getWarningMessages() { return warningMessages; }
/**
* The fail or abort messages produced by the compiler. The list
* entries are the <code>IMessage</code> objects created during the
* though.
* @see org.aspectj.tools.ajc.AjcTestCase
*/
- public List /*IMessage*/ getFailMessages() { return failMessages; }
+ public List<IMessage> getFailMessages() { return failMessages; }
- public List /*IMessage*/ getWeaveMessages() { return weaveMessages; }
+ public List<IMessage> getWeaveMessages() { return weaveMessages; }
/**
* Returns string containing message count summary, list of messages
setLocation(namePatterns[0].getSourceContext(), namePatterns[0].getStart(), namePatterns[namePatterns.length - 1].getEnd());
}
- public WildTypePattern(List names, boolean includeSubtypes, int dim) {
+ public WildTypePattern(List<NamePattern> names, boolean includeSubtypes, int dim) {
this((NamePattern[]) names.toArray(new NamePattern[names.size()]), includeSubtypes, dim, false, TypePatternList.EMPTY);
}
- public WildTypePattern(List names, boolean includeSubtypes, int dim, int endPos) {
+ public WildTypePattern(List<NamePattern> names, boolean includeSubtypes, int dim, int endPos) {
this(names, includeSubtypes, dim);
this.end = endPos;
}
- public WildTypePattern(List names, boolean includeSubtypes, int dim, int endPos, boolean isVarArg) {
+ public WildTypePattern(List<NamePattern> names, boolean includeSubtypes, int dim, int endPos, boolean isVarArg) {
this(names, includeSubtypes, dim);
this.end = endPos;
this.isVarArgs = isVarArg;
}
- public WildTypePattern(List names, boolean includeSubtypes, int dim, int endPos, boolean isVarArg, TypePatternList typeParams,
+ public WildTypePattern(List<NamePattern> names, boolean includeSubtypes, int dim, int endPos, boolean isVarArg, TypePatternList typeParams,
TypePattern upperBound, TypePattern[] additionalInterfaceBounds, TypePattern lowerBound) {
this((NamePattern[]) names.toArray(new NamePattern[names.size()]), includeSubtypes, dim, isVarArg, typeParams);
this.end = endPos;
this.additionalInterfaceBounds = additionalInterfaceBounds;
}
- public WildTypePattern(List names, boolean includeSubtypes, int dim, int endPos, boolean isVarArg, TypePatternList typeParams) {
+ public WildTypePattern(List<NamePattern> names, boolean includeSubtypes, int dim, int endPos, boolean isVarArg, TypePatternList typeParams) {
this((NamePattern[]) names.toArray(new NamePattern[names.size()]), includeSubtypes, dim, isVarArg, typeParams);
this.end = endPos;
}
}
@Override
- public TypePattern parameterizeWith(Map typeVariableMap, World w) {
+ public TypePattern parameterizeWith(Map<String,UnresolvedType> typeVariableMap, World w) {
NamePattern[] newNamePatterns = new NamePattern[namePatterns.length];
for (int i = 0; i < namePatterns.length; i++) {
newNamePatterns[i] = namePatterns[i];
private static final String REQUIRE_KEYWORDS = "RequireKeywords=";
private static final String SKIP_KEYWORDS = "SkipKeywords=";
private static final String PICK_PR = "PR=";
- private static final List VALID_SUFFIXES
+ private static final List<String> VALID_SUFFIXES
= Collections.unmodifiableList(Arrays.asList(new String[]
{ TITLE_LIST, TITLE_FAIL_LIST, TITLE_CONTAINS,
REQUIRE_KEYWORDS, SKIP_KEYWORDS, PICK_PR }));
/** Map String titlesName to List (String) of titles to accept */
- private static final Map TITLES = new HashMap();
+ private static final Map<String,List<String>> TITLES = new HashMap<String,List<String>>();
- private static List getTitles(String titlesName) {
+ private static List<String> getTitles(String titlesName) {
return getTitles(titlesName, false);
}
- private static List getTitles(String titlesName, boolean fail) {
+ private static List<String> getTitles(String titlesName, boolean fail) {
if (LangUtil.isEmpty(titlesName)) {
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
- List result = (List) TITLES.get(titlesName);
+ List<String> result = (List<String>) TITLES.get(titlesName);
if (null == result) {
result = makeTitlesList(titlesName, fail);
TITLES.put(titlesName, result);
* @param fail if true, only read titles prefixed "FAIL" from files
* @return the unmodifiable List of titles (maybe empty, never null)
*/
- private static List makeTitlesList(String titlesKey, boolean fail) {
+ private static List<String> makeTitlesList(String titlesKey, boolean fail) {
File file = new File(titlesKey);
return file.canRead()
? readTitlesFile(file, fail)
* @param titlesList a comma-delimited String of titles
* @return the unmodifiable List of titles (maybe empty, never null)
*/
- private static List parseTitlesList(String titlesList) {
- ArrayList result = new ArrayList();
+ private static List<String> parseTitlesList(String titlesList) {
+ ArrayList<String> result = new ArrayList<String>();
String last = null;
StringTokenizer st = new StringTokenizer(titlesList, ",");
while (st.hasMoreTokens()) {
* @param fail if true, only select titles prefixed "FAIL"
* @return the unmodifiable List of titles (maybe empty, never null)
*/
- private static List readTitlesFile(File titlesFile, boolean fail) {
- ArrayList result = new ArrayList();
+ private static List<String> readTitlesFile(File titlesFile, boolean fail) {
+ ArrayList<String> result = new ArrayList<String>();
Reader reader = null;
try {
reader = new FileReader(titlesFile);
}
option = option.substring(OPTION_PREFIX.length());
boolean keywordMustExist = false;
- List permittedTitles = null;
- List permittedTitleStrings = null;
+ List<String> permittedTitles = null;
+ List<String> permittedTitleStrings = null;
String havePr = null;
if (option.startsWith(REQUIRE_KEYWORDS)) {
option = option.substring(REQUIRE_KEYWORDS.length());
}
if (null != permittedTitleStrings) {
boolean gotHit = false;
- for (Iterator iter = permittedTitleStrings.iterator();
+ for (Iterator<String> iter = permittedTitleStrings.iterator();
!gotHit && iter.hasNext();
) {
String substring = (String) iter.next();
}
} else {
// all other options handled as comma-delimited lists
- List specs = LangUtil.commaSplit(option);
+ List<String> specs = LangUtil.commaSplit(option);
// XXX also throw Error on empty specs...
- for (Iterator iter = specs.iterator(); iter.hasNext();) {
+ for (Iterator<String> iter = specs.iterator(); iter.hasNext();) {
String spec = (String) iter.next();
if (null != havePr) {
if (havePr.equals(spec)) { // String.equals()
}
public void addXmlConfigFile(String projectName, String xmlfile) {
- List l = new ArrayList();
+ List<String> l = new ArrayList<String>();
l.add(xmlfile);
AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setProjectXmlConfigFiles(l);
public void configureAspectPath(String projectName, File aspectpath) {
AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
- Set s = new HashSet();
+ Set<File> s = new HashSet<File>();
s.add(aspectpath);
((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setAspectPath(s);
}
((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setJavaOptions(options);
}
- public static void configureInPath(String projectName, Set inpath) {
+ public static void configureInPath(String projectName, Set<File> inpath) {
AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setInpath(inpath);
}
import junit.framework.TestCase;
/**
- * @author colyer
- *
+ * @author Adrian Colyer
*/
public class WeaverMessagesTestCase extends TestCase {
public void testAllMessagesDefined() {
- Class wmClass = WeaverMessages.class;
+ Class<?> wmClass = WeaverMessages.class;
Field[] fields = wmClass.getDeclaredFields();
- List fieldList = new ArrayList();
+ List<String> fieldList = new ArrayList<String>();
for (int i = 0; i < fields.length; i++) {
Field f = fields[i];
if (f.getType() == String.class) {
import org.aspectj.bridge.IMessageHandler;
import org.aspectj.weaver.tools.GeneratedClassHandler;
-import java.net.URL;
-import java.net.URLClassLoader;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;