options.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.GENERATE);
}
- private Collection collectSourceRootFiles(File dir) {
+ private Collection<File> collectSourceRootFiles(File dir) {
return Arrays.asList(FileUtil.listFiles(dir, FileUtil.aspectjSourceFileFilter));
}
* in order to prevent wierd bootstrap issues (refer to bug#39959).
*/
public List getClasspath(AjcConfigParser parser) {
- List ret = new ArrayList();
+ List<String> ret = new ArrayList<>();
// if (parser.bootclasspath == null) {
// addClasspath(System.getProperty("sun.boot.class.path", ""), ret);
if (parser.classpath == null) {
addClasspath(System.getProperty("java.class.path", ""), ret);
- List fixedList = new ArrayList();
+ List<String> fixedList = new ArrayList<>();
for (Object o : ret) {
String entry = (String) o;
if (!entry.endsWith("aspectjtools.jar")) {
return checkedClasspaths;
}
- private void addExtDirs(String extdirs, List classpathCollector) {
+ private void addExtDirs(String extdirs, List<String> classpathCollector) {
StringTokenizer tokenizer = new StringTokenizer(extdirs, File.pathSeparator);
while (tokenizer.hasMoreTokens()) {
// classpathCollector.add(tokenizer.nextToken());
private String modulepath = null;
private String modulesourcepath = null;
private String extdirs = null;
- private List unparsedArgs = new ArrayList();
+ private List<String> unparsedArgs = new ArrayList<>();
private AjBuildConfig buildConfig;
private IMessageHandler handler;
private String moduleInfoArgument;
import org.aspectj.org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
import org.aspectj.weaver.bcel.BcelWeaver;
import org.aspectj.weaver.bcel.BcelWorld;
+import org.aspectj.weaver.bcel.UnwovenClassFile;
/**
* @author colyer
private AjState incrementalCompilationState;
- List /* InterimResult */resultsPendingWeave = new ArrayList();
+ List<InterimCompilationResult> resultsPendingWeave = new ArrayList<>();
/**
* Create an adapter, and tell it everything it needs to now to drive the AspectJ parts of a compile cycle.
// the compilation lifecycle methods below are called in order as compilation progresses...
public void beforeCompiling(ICompilationUnit[] sourceUnits) {
- resultsPendingWeave = new ArrayList();
+ resultsPendingWeave = new ArrayList<>();
reportedErrors = false;
}
}
}
- private List getBinarySourcesFrom(Map binarySourceEntries) {
+ private List<InterimCompilationResult> getBinarySourcesFrom(Map<String, List<UnwovenClassFile>> binarySourceEntries) {
// Map is fileName |-> List<UnwovenClassFile>
- List ret = new ArrayList();
+ List<InterimCompilationResult> ret = new ArrayList<>();
for (Object o : binarySourceEntries.keySet()) {
String sourceFileName = (String) o;
- List unwovenClassFiles = (List) binarySourceEntries.get(sourceFileName);
+ List<UnwovenClassFile> unwovenClassFiles = binarySourceEntries.get(sourceFileName);
// XXX - see bugs 57432,58679 - final parameter on next call should be "compiler.options.maxProblemsPerUnit"
CompilationResult result = new CompilationResult(sourceFileName.toCharArray(), 0, 0, Integer.MAX_VALUE);
result.noSourceAvailable();
}
resultsPendingWeave.addAll(getBinarySourcesFrom(binarySourceSetForFullWeave));
} else {
- Map binarySourcesToAdd = binarySourceProvider.getBinarySourcesForThisWeave();
+ Map<String, List<UnwovenClassFile>> binarySourcesToAdd = binarySourceProvider.getBinarySourcesForThisWeave();
resultsPendingWeave.addAll(getBinarySourcesFrom(binarySourcesToAdd));
}
// TESTING
if (pipelineTesting) {
if (pipelineOutput == null) {
- pipelineOutput = new Hashtable();
+ pipelineOutput = new Hashtable<>();
}
pipelineOutput.put("filesContainingAspects", Integer.toString(toWaitFor));
StringBuilder order = new StringBuilder();
}
resultsPendingWeave.addAll(getBinarySourcesFrom(binarySourceSetForFullWeave));
} else {
- Map binarySourcesToAdd = binarySourceProvider.getBinarySourcesForThisWeave();
+ Map<String, List<UnwovenClassFile>> binarySourcesToAdd = binarySourceProvider.getBinarySourcesForThisWeave();
resultsPendingWeave.addAll(getBinarySourcesFrom(binarySourcesToAdd));
}
}
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.IProgressListener;
import org.aspectj.bridge.MessageUtil;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile;
import org.aspectj.org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
import org.aspectj.weaver.IClassFileProvider;
import org.aspectj.weaver.IUnwovenClassFile;
public class WeaverAdapter implements IClassFileProvider, IWeaveRequestor, Iterator {
private final AbstractCompilerAdapter compilerAdapter;
- private Iterator resultIterator;
+ private Iterator<InterimCompilationResult> resultIterator;
private int classFileIndex = 0;
private InterimCompilationResult nowProcessing;
private InterimCompilationResult lastReturnedResult;
compilerAdapter.acceptResult(result.result());
}
- private boolean removeFromMap(Map aMap, char[] key) {
+ private boolean removeFromMap(Map<char[], ClassFile> aMap, char[] key) {
// jdt uses char[] as a key in the hashtable, which is not very useful as equality is based on being
// the same array, not having the same content.
// String skey = new String(key);
return context;
}
- private IProblem[] buildSeeAlsoProblems(IProblem originalProblem, List sourceLocations, CompilationResult problemSource,
+ private IProblem[] buildSeeAlsoProblems(IProblem originalProblem, List<ISourceLocation> sourceLocations, CompilationResult problemSource,
boolean usedBinarySourceFileName) {
List<IProblem> ret = new ArrayList<>();
import java.util.ArrayList;
import java.util.List;
+import org.aspectj.org.eclipse.jdt.internal.compiler.IAttribute;
import org.aspectj.weaver.AjAttribute;
import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile;
import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult;
*/
protected int generateInfoAttributes(ClassFile classFile) {
// add extra attributes into list then call 2-arg version of generateInfoAttributes...
- List extras = new ArrayList();
+ List<IAttribute> extras = new ArrayList<>();
addDeclarationStartLineAttribute(extras,classFile);
return classFile.generateMethodInfoAttributes(binding,extras);
}
import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile;
import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult;
+import org.aspectj.org.eclipse.jdt.internal.compiler.IAttribute;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.aspectj.weaver.AjAttribute;
*/
public class AjMethodDeclaration extends MethodDeclaration {
- private List attributes = null;
+ private List<IAttribute> attributes = null;
/**
* @param compilationResult
// general purpose hook to add an AjAttribute to this method
// used by @AspectJ visitor to add pointcut attribute to @Advice
protected void addAttribute(EclipseAttributeAdapter eaa) {
- if (attributes==null) attributes = new ArrayList();
+ if (attributes==null) attributes = new ArrayList<>();
attributes.add(eaa);
}
*/
protected int generateInfoAttributes(ClassFile classFile,boolean addAjSynthetic) {
// add extra attributes into list then call 2-arg version of generateInfoAttributes...
- List extras = (attributes==null?new ArrayList():attributes);
+ List<IAttribute> extras = (attributes==null?new ArrayList<>():attributes);
addDeclarationStartLineAttribute(extras,classFile);
if (addAjSynthetic) {
extras.add(new EclipseAttributeAdapter(new AjAttribute.AjSynthetic()));
import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation;
import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile;
import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult;
+import org.aspectj.org.eclipse.jdt.internal.compiler.IAttribute;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Clinit;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
* methods are able to masquerade as any join point (a field set, field get or method call). The effective signature attribute
* is 'unwrapped' in BcelClassWeaver.matchInvokeInstruction()
*/
- private void generateMethod(ClassFile classFile, MethodBinding methodBinding, List additionalAttributes, BodyGenerator gen) {
+ private void generateMethod(ClassFile classFile, MethodBinding methodBinding, List<EclipseAttributeAdapter> additionalAttributes, BodyGenerator gen) {
// EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(this.scope);
classFile.generateMethodInfoHeader(methodBinding);
int methodAttributeOffset = classFile.contentsOffset;
int attributeNumber;
if (additionalAttributes != null) { // mini optimization
- List attrs = new ArrayList();
+ List<IAttribute> attrs = new ArrayList<>();
attrs.addAll(AstUtil.getAjSyntheticAttribute());
attrs.addAll(additionalAttributes);
attributeNumber = classFile.generateMethodInfoAttributes(methodBinding, attrs);
import java.util.List;
import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation;
+import org.aspectj.org.eclipse.jdt.internal.compiler.IAttribute;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Argument;
}
public static List getAjSyntheticAttribute() {
- List ret = new ArrayList(1);
+ List<IAttribute> ret = new ArrayList<>(1);
ret.add(new EclipseAttributeAdapter(new AjAttribute.AjSynthetic()));
return ret;
}
} else if (declareDecl instanceof DeclareParents) {
DeclareParents dp = (DeclareParents) declareDecl;
String childPattern = dp.getChild().toString();
- Collection parentPatterns = dp.getParents().getExactTypes();
+ Collection<UnresolvedType> parentPatterns = dp.getParents().getExactTypes();
StringBuilder parents = new StringBuilder();
- for (Iterator iter = parentPatterns.iterator(); iter.hasNext();) {
+ for (Iterator<UnresolvedType> iter = parentPatterns.iterator(); iter.hasNext();) {
UnresolvedType urt = ((UnresolvedType) iter.next());
parents.append(urt.getName());
if (iter.hasNext()) {
import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation;
import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile;
import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult;
+import org.aspectj.org.eclipse.jdt.internal.compiler.IAttribute;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ParameterizedQualifiedTypeReference;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference;
Shadow.Kind kind,
boolean weaveBody)
{
- List l = new ArrayList(1);
+ List<IAttribute> l = new ArrayList<>(1);
l.add(new EclipseAttributeAdapter(
new AjAttribute.EffectiveSignatureAttribute(sig, kind, weaveBody)));
return l;
@Override
protected int generateInfoAttributes(ClassFile classFile) {
- List l;
+ List<IAttribute> l;
Shadow.Kind kind = getShadowKindForBody();
if (kind != null) {
l = makeEffectiveSignatureAttribute(munger.getSignature(), kind, true);
} else {
- l = new ArrayList(0);
+ l = new ArrayList<>(0);
}
addDeclarationStartLineAttribute(l,classFile);
if (onType instanceof ParameterizedSingleTypeReference) {
ParameterizedSingleTypeReference paramRef = (ParameterizedSingleTypeReference) onType;
TypeReference[] rb = paramRef.typeArguments;
- typeVariableAliases = new ArrayList();
+ typeVariableAliases = new ArrayList<>();
for (TypeReference typeReference : rb) {
typeVariableAliases.add(CharOperation.toString(typeReference.getTypeName()));
}
} else if (onType instanceof ParameterizedQualifiedTypeReference) {
ParameterizedQualifiedTypeReference paramRef = (ParameterizedQualifiedTypeReference) onType;
- typeVariableAliases = new ArrayList();
+ typeVariableAliases = new ArrayList<>();
for (int j = 0; j < paramRef.typeArguments.length; j++) {
TypeReference[] rb = paramRef.typeArguments[j];
for (int i = 0; rb!=null && i < rb.length; i++) {
// afterThrowingAdviceSig, aroundAdviceSig };
private final CompilationUnitDeclaration unit;
- private final Stack typeStack = new Stack();
+ private final Stack<TypeDeclaration> typeStack = new Stack<>();
private AspectJAnnotations ajAnnotations;
public ValidateAtAspectJAnnotationsVisitor(CompilationUnitDeclaration unit) {
* @param arguments
* @return argument names (possibly empty)
*/
- private List toArgumentNames(Argument[] arguments) {
- List names = new ArrayList();
+ private List<String> toArgumentNames(Argument[] arguments) {
+ List<String> names = new ArrayList<>();
if (arguments == null) {
return names;
} else {
* interfaces targetted by ITDs that have to be implemented by accessing the topMostImplementor of the interface, yet the aspect
* where the ITD originated is not in the world
*/
- private final Map dangerousInterfaces = new HashMap();
+ private final Map<ResolvedType, String> dangerousInterfaces = new HashMap<>();
public AjLookupEnvironment(ITypeRequestor typeRequestor, CompilerOptions options, ProblemReporter problemReporter,
INameEnvironment nameEnvironment) {
// dangerous interface -
// report a problem if it is.
for (Object o : dangerousInterfaces.entrySet()) {
- Map.Entry entry = (Map.Entry) o;
+ Map.Entry<ResolvedType, String> entry = (Map.Entry) o;
ResolvedType interfaceType = (ResolvedType) entry.getKey();
if (onType.isTopmostImplementor(interfaceType)) {
factory.showMessage(IMessage.ERROR, onType + ": " + entry.getValue(), onType.getSourceLocation(), null);
}
}
- private final List pendingTypesToFinish = new ArrayList();
+ private final List<BinaryTypeBinding> pendingTypesToFinish = new ArrayList<>();
boolean inBinaryTypeCreationAndWeaving = false;
boolean processingTheQueue = false;
public class PrivilegedHandler implements IPrivilegedHandler {
private AspectDeclaration inAspect;
- private Map accessors = new HashMap();
+ private Map<ResolvedMember, Object> accessors = new HashMap<>();
public PrivilegedHandler(AspectDeclaration inAspect) {
this.inAspect = inAspect;
}
public ResolvedMember[] getMembers() {
- Collection m = accessors.keySet();
+ Collection<ResolvedMember> m = accessors.keySet();
int len = m.size();
ResolvedMember[] ret = new ResolvedMember[len];
int index = 0;
} else {
weaverType = factory.fromEclipse(type.superclass());
}
- Set checked = new HashSet();
+ Set<ResolvedType> checked = new HashSet<>();
for (ConcreteTypeMunger m : weaverType.getInterTypeMungersIncludingSupers()) {
ResolvedType theAspect = m.getAspectType();
if (!checked.contains(theAspect)) {
} else if (theAspect instanceof ReferenceType) {
// ResolvedMember rm = factory.makeResolvedMember(fieldDecl.binding);
String fname = new String(fieldDecl.name);
- Collection/* ResolvedMember */privvies = ((ReferenceType) theAspect).getPrivilegedAccesses();
+ Collection<ResolvedMember> privvies = ((ReferenceType) theAspect).getPrivilegedAccesses();
// On an incremental compile the information is in the bcel delegate
if (privvies != null) {
for (Object privvy : privvies) {
model.setConfigFile(buildConfig.getConfigFile().getAbsolutePath());
kind = IProgramElement.Kind.FILE_LST;
}
- model.setRoot(new ProgramElement(structureModel, rootLabel, kind, new ArrayList()));
+ model.setRoot(new ProgramElement(structureModel, rootLabel, kind, new ArrayList<>()));
model.setFileMap(new HashMap<>());
// setStructureModel(model);
/** init only on initial batch compile? no file-specific options */
private void initBcelWorld(IMessageHandler handler) throws IOException {
- List cp = buildConfig.getFullClasspath(); // pr145693
+ List<String> cp = buildConfig.getFullClasspath(); // pr145693
// buildConfig.getBootclasspath();
// cp.addAll(buildConfig.getClasspath());
BcelWorld bcelWorld = new BcelWorld(cp, handler, null);
private void populateCompilerOptionsFromLintSettings(org.aspectj.org.eclipse.jdt.internal.compiler.Compiler forCompiler) {
BcelWorld world = this.state.getBcelWorld();
IMessage.Kind swallowedExceptionKind = world.getLint().swallowedExceptionInCatchBlock.getKind();
- Map optionsMap = new HashMap();
+ Map<String, String> optionsMap = new HashMap<>();
optionsMap.put(CompilerOptions.OPTION_ReportSwallowedExceptionInCatchBlock, swallowedExceptionKind == null ? "ignore"
: swallowedExceptionKind.toString());
forCompiler.options.set(optionsMap);
sb.append("incrementally building ");
}
AjBuildConfig config = (AjBuildConfig) data;
- List classpath = config.getClasspath();
+ List<String> classpath = config.getClasspath();
sb.append("with classpath: ");
for (Object o : classpath) {
sb.append(o.toString());
filename = new String(currCompilationResult.fileName);
lineseps = currCompilationResult.lineSeparatorPositions;
LangUtil.throwIaxIfNull(currCompilationResult, "result");
- stack = new Stack();
+ stack = new Stack<>();
packageDecl = null;
this.buildConfig = buildConfig;
internalBuild(cuDeclaration, structureModel);
// -- remove duplicates before adding (XXX use them instead?)
if (addToNode != null && addToNode.getChildren() != null) {
- for (ListIterator itt = addToNode.getChildren().listIterator(); itt.hasNext();) {
+ for (ListIterator<IProgramElement> itt = addToNode.getChildren().listIterator(); itt.hasNext();) {
IProgramElement child = (IProgramElement) itt.next();
ISourceLocation childLoc = child.getSourceLocation();
if (null == childLoc) {
}
}
if (sourceFolderNode == null) {
- sourceFolderNode = new ProgramElement(structureModel, sourceFolder, IProgramElement.Kind.SOURCE_FOLDER, new ArrayList());
+ sourceFolderNode = new ProgramElement(structureModel, sourceFolder, IProgramElement.Kind.SOURCE_FOLDER, new ArrayList<>());
root.addChild(sourceFolderNode);
}
return sourceFolderNode;
}
if (pkgNode == null) {
// note packages themselves have no source location
- pkgNode = new ProgramElement(activeStructureModel, pkgName, IProgramElement.Kind.PACKAGE, new ArrayList());
+ pkgNode = new ProgramElement(activeStructureModel, pkgName, IProgramElement.Kind.PACKAGE, new ArrayList<>());
rootForSource.addChild(pkgNode);
}
addToNode = pkgNode;
formatter.genLabelAndKind(methodDeclaration, peNode); // will set the
// name
genBytecodeInfo(methodDeclaration, peNode);
- List namedPointcuts = genNamedPointcuts(methodDeclaration);
+ List<ReferencePointcut> namedPointcuts = genNamedPointcuts(methodDeclaration);
// if (shouldAddUsesPointcut)
// addUsesPointcutRelationsForNode(peNode, namedPointcuts, methodDeclaration);
* @param methodDeclaration
* @return all of the named pointcuts referenced by the PCD of this declaration
*/
- private List genNamedPointcuts(MethodDeclaration methodDeclaration) {
- List pointcuts = new ArrayList();
+ private List<ReferencePointcut> genNamedPointcuts(MethodDeclaration methodDeclaration) {
+ List<ReferencePointcut> pointcuts = new ArrayList<>();
if (methodDeclaration instanceof AdviceDeclaration) {
if (((AdviceDeclaration) methodDeclaration).pointcutDesignator != null) {
addAllNamed(((AdviceDeclaration) methodDeclaration).pointcutDesignator.getPointcut(), pointcuts);
* @param pointcuts
* accumulator for named pointcuts
*/
- private void addAllNamed(Pointcut pointcut, List pointcuts) {
+ private void addAllNamed(Pointcut pointcut, List<ReferencePointcut> pointcuts) {
if (pointcut == null) {
return;
}
* @see org.eclipse.jdt.internal.compiler.ICompilerAdapterFactory#getAdapter(org.eclipse.jdt.internal.compiler.Compiler)
*/
public ICompilerAdapter getAdapter(Compiler forCompiler) {
- Map javaOptions = forCompiler.options.getMap();
+ Map<String, String> javaOptions = forCompiler.options.getMap();
// TODO get aspectj options from project and add into map before...
AjCompilerOptions ajOptions = new AjCompilerOptions(javaOptions);
forCompiler.options = ajOptions;
private void setLintProperties(BcelWorld world, AjCompilerOptions options) {
Properties p = new Properties();
Lint lintSettings = world.getLint();
- Map map = options.getMap();
+ Map<String, String> map = options.getMap();
p.put(lintSettings.invalidAbsoluteTypeName.getName(), map.get(AjCompilerOptions.OPTION_ReportInvalidAbsoluteTypeName));
p.put(lintSettings.invalidWildcardTypeName.getName(), map.get(AjCompilerOptions.OPTION_ReportInvalidWildcardTypeName));
p.put(lintSettings.unresolvableMember.getName(), map.get(AjCompilerOptions.OPTION_ReportUnresolvableMember));
private static class UnwovenResultCollector implements IIntermediateResultsRequestor {
- private Collection results = new ArrayList();
+ private Collection<InterimCompilationResult> results = new ArrayList<>();
/*
* (non-Javadoc)
try {
// Set fileSet = StructureModelManager.INSTANCE.getStructureModel().getFileMap().entrySet();
- Set fileSet = model.getHierarchy().getFileMapEntrySet();
+ Set<Map.Entry<String, IProgramElement>> fileSet = model.getHierarchy().getFileMapEntrySet();
for (Object o : fileSet) {
IProgramElement peNode = (IProgramElement) ((Map.Entry) o).getValue();
dumpStructureToFile(peNode);
}
CompilationResultDestinationManager outputManager = ajbc.getCompilationResultDestinationManager();
if (outputManager != null) {
- List outputDirs = outputManager.getAllOutputLocations();
+ List<File> outputDirs = outputManager.getAllOutputLocations();
for (Object o : outputDirs) {
File dir = (File) o;
if (dir.equals(location)) {
public List getAdvice() {
// ajh02: method added
List bd = bodyDeclarations();
- List advice = new ArrayList();
+ List<AdviceDeclaration> advice = new ArrayList<>();
for (Object decl : bd) {
if (decl instanceof AdviceDeclaration) {
- advice.add(decl);
+ advice.add((AdviceDeclaration)decl);
}
}
return advice;