private File outputJar;
private String outxmlName;
private CompilationResultDestinationManager compilationResultDestinationManager = null;
- private List/* File */sourceRoots = new ArrayList();
- private List/* File */changedFiles;
+ private List<File> sourceRoots = new ArrayList<File>();
+ private List<File> changedFiles;
private List<File> files = new ArrayList<File>();
private List<File> xmlfiles = new ArrayList<File>();
private List<BinarySourceFile> binaryFiles = new ArrayList<BinarySourceFile>(); // .class files in indirs...
- private List/* File */inJars = new ArrayList();
- private List/* File */inPath = new ArrayList();
- private Map/* String->File */sourcePathResources = new HashMap();
- private List/* File */aspectpath = new ArrayList();
- private List/* String */classpath = new ArrayList();
- private List/* String */bootclasspath = new ArrayList();
- private List/* String */cpElementsWithModifiedContents = new ArrayList();
+ private List<File> inJars = new ArrayList<File>();
+ private List<File> inPath = new ArrayList<File>();
+ private Map<String, File> sourcePathResources = new HashMap<String, File>();
+ private List<File> aspectpath = new ArrayList<File>();
+ private List<String> classpath = new ArrayList<String>();
+ private List<String> bootclasspath = new ArrayList<String>();
+ private List<String> cpElementsWithModifiedContents = new ArrayList<String>();
private File configFile;
private String lintMode = AJLINT_DEFAULT;
/**
* This does not include -bootclasspath but includes -extdirs and -classpath
*/
- public List getClasspath() { // XXX setters don't respect javadoc contract...
+ public List<String> getClasspath() {
return classpath;
}
- public void setClasspath(List classpath) {
+ public void setClasspath(List<String> classpath) {
this.classpath = classpath;
}
- public List getBootclasspath() {
+ public List<String> getBootclasspath() {
return bootclasspath;
}
- public void setBootclasspath(List bootclasspath) {
+ public void setBootclasspath(List<String> bootclasspath) {
this.bootclasspath = bootclasspath;
}
return outxmlName;
}
- public List/* File */getInpath() {
+ public List<File> getInpath() {
// Elements of the list are either archives (jars/zips) or directories
return inPath;
}
- public List/* File */getInJars() {
+ public List<File> getInJars() {
return inJars;
}
- public Map getSourcePathResources() {
+ public Map<String, File> getSourcePathResources() {
return sourcePathResources;
}
this.outxmlName = name;
}
- public void setInJars(List sourceJars) {
+ public void setInJars(List<File> sourceJars) {
this.inJars = sourceJars;
}
- public void setInPath(List dirsOrJars) {
+ public void setInPath(List<File> dirsOrJars) {
inPath = dirsOrJars;
// remember all the class files in directories on the inpath
return pathname.getPath().endsWith(".class");
}
};
- for (Iterator iter = dirsOrJars.iterator(); iter.hasNext();) {
- File inpathElement = (File) iter.next();
+ for (Iterator<File> iter = dirsOrJars.iterator(); iter.hasNext();) {
+ File inpathElement = iter.next();
if (inpathElement.isDirectory()) {
File[] files = FileUtil.listFiles(inpathElement, filter);
for (int i = 0; i < files.length; i++) {
}
}
- public List getSourceRoots() {
+ public List<File> getSourceRoots() {
return sourceRoots;
}
- public void setSourceRoots(List sourceRootDir) {
+ public void setSourceRoots(List<File> sourceRootDir) {
this.sourceRoots = sourceRootDir;
}
* @return List (String) classpath of bootclasspath, injars, inpath, aspectpath entries, specified classpath (extdirs, and
* classpath), and output dir or jar
*/
- public List getFullClasspath() {
- List full = new ArrayList();
+ public List<String> getFullClasspath() {
+ List<String> full = new ArrayList<String>();
full.addAll(getBootclasspath()); // XXX Is it OK that boot classpath overrides inpath/injars/aspectpath?
- for (Iterator i = inJars.iterator(); i.hasNext();) {
- full.add(((File) i.next()).getAbsolutePath());
+ for (Iterator<File> i = inJars.iterator(); i.hasNext();) {
+ full.add((i.next()).getAbsolutePath());
}
- for (Iterator i = inPath.iterator(); i.hasNext();) {
- full.add(((File) i.next()).getAbsolutePath());
+ for (Iterator<File> i = inPath.iterator(); i.hasNext();) {
+ full.add((i.next()).getAbsolutePath());
}
- for (Iterator i = aspectpath.iterator(); i.hasNext();) {
- full.add(((File) i.next()).getAbsolutePath());
+ for (Iterator<File> i = aspectpath.iterator(); i.hasNext();) {
+ full.add((i.next()).getAbsolutePath());
}
full.addAll(getClasspath());
// if (null != outputDir) {
this.lintSpecFile = lintSpecFile;
}
- public List getAspectpath() {
+ public List<File> getAspectpath() {
return aspectpath;
}
- public void setAspectpath(List aspectpath) {
+ public void setAspectpath(List<File> aspectpath) {
this.aspectpath = aspectpath;
}
setMakeReflectable(global.isMakeReflectable());
}
+ @SuppressWarnings({ "rawtypes", "unchecked" })
void join(Collection local, Collection global) {
for (Iterator iter = global.iterator(); iter.hasNext();) {
Object next = iter.next();
}
}
- /**
- * Join some global options into a local set of options - globals will override locals.
- *
- * @param local
- * @param global
- */
- void join(Map local, Map global) {
- for (Iterator iter = global.keySet().iterator(); iter.hasNext();) {
- Object key = iter.next();
- // if (override || (null == local.get(key))) { //
- Object value = global.get(key);
- if (null != value) {
- local.put(key, value);
- }
- // }
- }
- }
-
- public void setSourcePathResources(Map map) {
+ public void setSourcePathResources(Map<String, File> map) {
sourcePathResources = map;
}
}
if (lintValue != null) {
- Map lintOptions = new HashMap();
+ Map<String, String> lintOptions = new HashMap<String, String>();
lintOptions.put(AjCompilerOptions.OPTION_ReportInvalidAbsoluteTypeName, lintValue);
lintOptions.put(AjCompilerOptions.OPTION_ReportInvalidWildcardTypeName, lintValue);
lintOptions.put(AjCompilerOptions.OPTION_ReportUnresolvableMember, lintValue);
return this.changes;
}
- public void setModifiedFiles(List projectSourceFilesChanged) {
+ public void setModifiedFiles(List<File> projectSourceFilesChanged) {
this.changedFiles = projectSourceFilesChanged;
}
- public List getModifiedFiles() {
+ public List<File> getModifiedFiles() {
return this.changedFiles;
}
- public void setClasspathElementsWithModifiedContents(List cpElementsWithModifiedContents) {
+ public void setClasspathElementsWithModifiedContents(List<String> cpElementsWithModifiedContents) {
this.cpElementsWithModifiedContents = cpElementsWithModifiedContents;
}
- public List getClasspathElementsWithModifiedContents() {
+ public List<String> getClasspathElementsWithModifiedContents() {
return this.cpElementsWithModifiedContents;
}
}
package org.aspectj.ajdt.internal.core.builder;
import java.io.File;
-import java.io.FileFilter;
import java.io.FilenameFilter;
import java.io.IOException;
import java.lang.ref.ReferenceQueue;
import org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation;
import org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryField;
import org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryMethod;
+import org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryNestedType;
import org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryType;
import org.aspectj.org.eclipse.jdt.internal.compiler.env.INameEnvironment;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
private Set<BinarySourceFile> addedBinaryFiles;
private Set<BinarySourceFile> deletedBinaryFiles;
// For a particular build run, this set records the changes to classesFromName
- public final Set deltaAddedClasses = new HashSet();
+ public final Set<String> deltaAddedClasses = new HashSet<String>();
// --- non static, but transient state - no need to write out, DOES need reinitializing when read AjState instance reloaded
private AjBuildConfig buildConfig;
private long lastSuccessfulFullBuildTime = -1;
- private final Hashtable /* File, long */structuralChangesSinceLastFullBuild = new Hashtable();
+ private final Hashtable<String, Long> structuralChangesSinceLastFullBuild = new Hashtable<String, Long>();
private long lastSuccessfulBuildTime = -1;
private long currentBuildTime = -1;
*
* Populated in noteResult and used in processDeletedFiles
*/
- private final Set/* <File> */sourceFilesDefiningAspects = new HashSet();
+ private final Set<File> sourceFilesDefiningAspects = new HashSet<File>();
/**
* Populated in noteResult to record the set of types that should be recompiled if the given file is modified or deleted.
/**
* A list of the .class files created by this state that contain aspects.
*/
- private final List/* <String> */aspectClassFiles = new ArrayList();
+ private final List<String> aspectClassFiles = new ArrayList<String>();
/**
* Holds structure information on types as they were at the end of the last build. It would be nice to get rid of this too, but
* can't see an easy way to do that right now.
*/
- private final Map/* FQN,CompactStructureRepresentation */resolvedTypeStructuresFromLastBuild = new HashMap();
+ private final Map<String, CompactTypeStructureRepresentation> resolvedTypeStructuresFromLastBuild = new HashMap<String, CompactTypeStructureRepresentation>();
/**
* Populated in noteResult to record the set of UnwovenClassFiles (intermediate results) that originated from compilation of the
*
* Passed into StatefulNameEnvironment during incremental compilation to support findType lookups.
*/
- private final Map<String, File> classesFromName = new HashMap();
+ private final Map<String, File> classesFromName = new HashMap<String, File>();
/**
* Populated by AjBuildManager to record the aspects with the file name in which they're contained. This is later used when
*/
private Map<String, char[]> aspectsFromFileNames;
- private Set/* File */compiledSourceFiles = new HashSet();
+ private Set<File> compiledSourceFiles = new HashSet<File>();
private final Map<String, File> resources = new HashMap<String, File>();
SoftHashMap/* <baseDir,SoftHashMap<theFile,className>> */fileToClassNameMap = new SoftHashMap();
*
* @return false if we discovered an aspect declaration
*/
- private boolean processDeletedFiles(Set deletedFiles) {
- for (Iterator iter = deletedFiles.iterator(); iter.hasNext();) {
- File aDeletedFile = (File) iter.next();
- if (this.sourceFilesDefiningAspects.contains(aDeletedFile)) {
+ private boolean processDeletedFiles(Set<File> deletedFiles) {
+ for (File deletedFile : deletedFiles) {
+ if (this.sourceFilesDefiningAspects.contains(deletedFile)) {
removeAllResultsOfLastBuild();
if (stateListener != null) {
- stateListener.detectedAspectDeleted(aDeletedFile);
+ stateListener.detectedAspectDeleted(deletedFile);
}
return false;
}
- List/* ClassFile */classes = fullyQualifiedTypeNamesResultingFromCompilationUnit.get(aDeletedFile);
+ List<ClassFile> classes = fullyQualifiedTypeNamesResultingFromCompilationUnit.get(deletedFile);
if (classes != null) {
- for (Iterator iterator = classes.iterator(); iterator.hasNext();) {
- ClassFile element = (ClassFile) iterator.next();
- resolvedTypeStructuresFromLastBuild.remove(element.fullyQualifiedTypeName);
+ for (ClassFile cf : classes) {
+ resolvedTypeStructuresFromLastBuild.remove(cf.fullyQualifiedTypeName);
}
}
}
return ret;
}
- private Collection getModifiedBinaryFiles() {
+ private Collection<BinarySourceFile> getModifiedBinaryFiles() {
return getModifiedBinaryFiles(lastSuccessfulBuildTime);
}
- Collection getModifiedBinaryFiles(long lastBuildTime) {
- List ret = new ArrayList();
+ Collection<BinarySourceFile> getModifiedBinaryFiles(long lastBuildTime) {
+ List<BinarySourceFile> ret = new ArrayList<BinarySourceFile>();
// not our job to account for new and deleted files
- for (Iterator i = buildConfig.getBinaryFiles().iterator(); i.hasNext();) {
- AjBuildConfig.BinarySourceFile bsfile = (AjBuildConfig.BinarySourceFile) i.next();
+ for (Iterator<BinarySourceFile> i = buildConfig.getBinaryFiles().iterator(); i.hasNext();) {
+ AjBuildConfig.BinarySourceFile bsfile = i.next();
File file = bsfile.binSrc;
if (!file.exists()) {
continue;
return ret;
}
- public static final FileFilter classFileFilter = new FileFilter() {
- public boolean accept(File pathname) {
- return pathname.getName().endsWith(".class");
- }
- };
-
private void recordDecision(String decision) {
getListener().recordDecision(decision);
}
}
}
- List classFiles = FileUtil.listClassFiles(dir);
+ List<File> classFiles = FileUtil.listClassFiles(dir);
- for (Iterator iterator = classFiles.iterator(); iterator.hasNext();) {
- File classFile = (File) iterator.next();
+ for (Iterator<File> iterator = classFiles.iterator(); iterator.hasNext();) {
+ File classFile = iterator.next();
if (CHECK_STATE_FIRST && state != null) {
// Next section reworked based on bug 270033:
// if it is an aspect we may or may not be in trouble depending on whether (a) we depend on it (b) it is on the
return aspectClassFiles.contains(file.getAbsolutePath());
}
+ @SuppressWarnings("rawtypes")
public static class SoftHashMap extends AbstractMap {
private final Map map;
private final Object key;
+ @SuppressWarnings("unchecked")
SoftReferenceKnownKey(Object k, Object v) {
super(v, rq);
this.key = k;
*/
private boolean hasStructuralChangedSince(File file, long lastSuccessfulBuildTime) {
// long lastModTime = file.lastModified();
- Long l = (Long) structuralChangesSinceLastFullBuild.get(file.getAbsolutePath());
+ Long l = structuralChangesSinceLastFullBuild.get(file.getAbsolutePath());
long strucModTime = -1;
if (l != null) {
strucModTime = l.longValue();
* Determine if anything has changed since a given time.
*/
private boolean hasAnyStructuralChangesSince(long lastSuccessfulBuildTime) {
- Set entries = structuralChangesSinceLastFullBuild.entrySet();
- for (Iterator iterator = entries.iterator(); iterator.hasNext();) {
- Map.Entry entry = (Map.Entry) iterator.next();
- Long l = (Long) entry.getValue();
+ Set<Map.Entry<String, Long>> entries = structuralChangesSinceLastFullBuild.entrySet();
+ for (Iterator<Map.Entry<String, Long>> iterator = entries.iterator(); iterator.hasNext();) {
+ Map.Entry<String, Long> entry = iterator.next();
+ Long l = entry.getValue();
if (l != null) {
long lvalue = l.longValue();
if (lvalue > lastSuccessfulBuildTime) {
int changes = newConfig.getChanged();
if ((changes & (CLASSPATH_CHANGED | ASPECTPATH_CHANGED | INPATH_CHANGED | OUTPUTDESTINATIONS_CHANGED | INJARS_CHANGED)) != 0) {
- List oldOutputLocs = getOutputLocations(previousConfig);
+ List<File> oldOutputLocs = getOutputLocations(previousConfig);
- Set alreadyAnalysedPaths = new HashSet();
+ Set<String> alreadyAnalysedPaths = new HashSet<String>();
- List oldClasspath = previousConfig.getClasspath();
- List newClasspath = newConfig.getClasspath();
+ List<String> oldClasspath = previousConfig.getClasspath();
+ List<String> newClasspath = newConfig.getClasspath();
if (stateListener != null) {
stateListener.aboutToCompareClasspaths(oldClasspath, newClasspath);
}
return true;
}
- List oldAspectpath = previousConfig.getAspectpath();
- List newAspectpath = newConfig.getAspectpath();
+ List<File> oldAspectpath = previousConfig.getAspectpath();
+ List<File> newAspectpath = newConfig.getAspectpath();
if (changedAndNeedsFullBuild(oldAspectpath, newAspectpath, true, oldOutputLocs, alreadyAnalysedPaths, PATHID_ASPECTPATH)) {
return true;
}
- List oldInPath = previousConfig.getInpath();
- List newInPath = newConfig.getInpath();
+ List<File> oldInPath = previousConfig.getInpath();
+ List<File> newInPath = newConfig.getInpath();
if (changedAndNeedsFullBuild(oldInPath, newInPath, false, oldOutputLocs, alreadyAnalysedPaths, PATHID_INPATH)) {
return true;
}
- List oldInJars = previousConfig.getInJars();
- List newInJars = newConfig.getInJars();
+ List<File> oldInJars = previousConfig.getInJars();
+ List<File> newInJars = newConfig.getInJars();
if (changedAndNeedsFullBuild(oldInJars, newInJars, false, oldOutputLocs, alreadyAnalysedPaths, PATHID_INPATH)) {
return true;
}
// the compiler configuration. This will allow for projects with long classpaths where classpaths
// are also capturing project dependencies - when a project we depend on is rebuilt, we can just check
// it as a standalone element on our classpath rather than going through them all
- List/* String */modifiedCpElements = newConfig.getClasspathElementsWithModifiedContents();
- for (Iterator iterator = modifiedCpElements.iterator(); iterator.hasNext();) {
- File cpElement = new File((String) iterator.next());
+ List<String> modifiedCpElements = newConfig.getClasspathElementsWithModifiedContents();
+ for (Iterator<String> iterator = modifiedCpElements.iterator(); iterator.hasNext();) {
+ File cpElement = new File(iterator.next());
if (cpElement.exists() && !cpElement.isDirectory()) {
if (cpElement.lastModified() > lastSuccessfulBuildTime) {
return true;
}
private File getOutputLocationFor(AjBuildConfig config, File aResourceFile) {
- new ArrayList();
if (config.getCompilationResultDestinationManager() != null) {
File outputLoc = config.getCompilationResultDestinationManager().getOutputLocationForResource(aResourceFile);
if (outputLoc != null) {
* @param outputLocs the output locations that should be ignored if they occur on the paths being compared
* @return true if a change is detected that requires a full build
*/
- private boolean changedAndNeedsFullBuild(List oldPath, List newPath, boolean checkClassFiles, List outputLocs,
- Set alreadyAnalysedPaths, int pathid) {
+ private boolean changedAndNeedsFullBuild(List oldPath, List newPath, boolean checkClassFiles, List<File> outputLocs,
+ Set<String> alreadyAnalysedPaths, int pathid) {
if (oldPath.size() != newPath.size()) {
return true;
}
// that should save a massive amount of processing for incremental builds in a multi project scenario
boolean foundMatch = false;
- for (Iterator iterator = outputLocs.iterator(); !foundMatch && iterator.hasNext();) {
- File dir = (File) iterator.next();
+ for (Iterator<File> iterator = outputLocs.iterator(); !foundMatch && iterator.hasNext();) {
+ File dir = iterator.next();
if (f.equals(dir)) {
foundMatch = true;
}
* @param outputLocs the output locations that should be ignored if they occur on the paths being compared
* @return true if a change is detected that requires a full build
*/
- private boolean classpathChangedAndNeedsFullBuild(List oldPath, List newPath, boolean checkClassFiles, List outputLocs,
- Set alreadyAnalysedPaths) {
+ private boolean classpathChangedAndNeedsFullBuild(List<String> oldPath, List<String> newPath, boolean checkClassFiles,
+ List<File> outputLocs, Set<String> alreadyAnalysedPaths) {
if (oldPath.size() != newPath.size()) {
return true;
}
if (!oldPath.get(i).equals(newPath.get(i))) {
return true;
}
- File f = new File((String) oldPath.get(i));
+ File f = new File(oldPath.get(i));
if (f.exists() && !f.isDirectory() && (f.lastModified() >= lastSuccessfulBuildTime)) {
return true;
}
// that should save a massive amount of processing for incremental builds in a multi project scenario
boolean foundMatch = false;
- for (Iterator iterator = outputLocs.iterator(); !foundMatch && iterator.hasNext();) {
- File dir = (File) iterator.next();
+ for (Iterator<File> iterator = outputLocs.iterator(); !foundMatch && iterator.hasNext();) {
+ File dir = iterator.next();
if (f.equals(dir)) {
foundMatch = true;
}
return false;
}
- public Set getFilesToCompile(boolean firstPass) {
+ public Set<File> getFilesToCompile(boolean firstPass) {
Set<File> thisTime = new HashSet<File>();
if (firstPass) {
compiledSourceFiles = new HashSet<File>();
*/
private void removeAllResultsOfLastBuild() {
// remove all binarySourceFiles, and all classesFromName...
- for (Iterator iter = this.inputClassFilesBySource.values().iterator(); iter.hasNext();) {
- List cfs = (List) iter.next();
- for (Iterator iterator = cfs.iterator(); iterator.hasNext();) {
- ClassFile cf = (ClassFile) iterator.next();
+ for (Iterator<List<ClassFile>> iter = this.inputClassFilesBySource.values().iterator(); iter.hasNext();) {
+ List<ClassFile> cfs = iter.next();
+ for (ClassFile cf : cfs) {
cf.deleteFromFileSystem(buildConfig);
}
}
if (deletedFiles == null) {
return;
}
- for (Iterator i = deletedFiles.iterator(); i.hasNext();) {
- File deletedFile = (File) i.next();
+ for (File deletedFile : deletedFiles) {
addDependentsOf(deletedFile);
- List cfs = this.fullyQualifiedTypeNamesResultingFromCompilationUnit.get(deletedFile);
+ List<ClassFile> cfs = this.fullyQualifiedTypeNamesResultingFromCompilationUnit.get(deletedFile);
this.fullyQualifiedTypeNamesResultingFromCompilationUnit.remove(deletedFile);
if (cfs != null) {
- for (Iterator iter = cfs.iterator(); iter.hasNext();) {
- ClassFile cf = (ClassFile) iter.next();
+ for (ClassFile cf : cfs) {
deleteClassFile(cf);
}
}
*/
private void deleteTypesThatWereInThisCompilationUnitLastTimeRoundButHaveBeenDeletedInThisIncrement(File sourceFile,
UnwovenClassFile[] unwovenClassFiles) {
- List classFiles = this.fullyQualifiedTypeNamesResultingFromCompilationUnit.get(sourceFile);
+ List<ClassFile> classFiles = this.fullyQualifiedTypeNamesResultingFromCompilationUnit.get(sourceFile);
if (classFiles != null) {
for (int i = 0; i < unwovenClassFiles.length; i++) {
// deleting also deletes types from the weaver... don't do this if they are
// still present this time around...
removeFromClassFilesIfPresent(unwovenClassFiles[i].getClassName(), classFiles);
}
- for (Iterator iter = classFiles.iterator(); iter.hasNext();) {
- ClassFile cf = (ClassFile) iter.next();
+ for (ClassFile cf : classFiles) {
deleteClassFile(cf);
}
}
}
- private void removeFromClassFilesIfPresent(String className, List classFiles) {
+ private void removeFromClassFilesIfPresent(String className, List<ClassFile> classFiles) {
ClassFile victim = null;
- for (Iterator iter = classFiles.iterator(); iter.hasNext();) {
- ClassFile cf = (ClassFile) iter.next();
+ for (ClassFile cf : classFiles) {
if (cf.fullyQualifiedTypeName.equals(className)) {
victim = cf;
break;
if (cr != null) {
Map compiledTypes = cr.compiledTypes;
if (compiledTypes != null) {
- for (Iterator iterator = compiledTypes.keySet().iterator(); iterator.hasNext();) {
- char[] className = (char[]) iterator.next();
+ for (Iterator<char[]> iterator = compiledTypes.keySet().iterator(); iterator.hasNext();) {
+ char[] className = iterator.next();
String typeName = new String(className).replace('/', '.');
if (typeName.indexOf(BcelWeaver.SYNTHETIC_CLASS_POSTFIX) == -1) {
ResolvedType rt = world.resolve(typeName);
return;
}
- CompactTypeStructureRepresentation existingStructure = (CompactTypeStructureRepresentation) this.resolvedTypeStructuresFromLastBuild
+ CompactTypeStructureRepresentation existingStructure = this.resolvedTypeStructuresFromLastBuild
.get(thisTime.getClassName());
ResolvedType newResolvedType = world.resolve(thisTime.getClassName());
if (!newResolvedType.isMissing()) {
return true; // (no match found)
}
+ // check for differences in inner types
+ // TODO could make order insensitive
+ IBinaryNestedType[] binaryNestedTypes = reader.getMemberTypes();
+ IBinaryNestedType[] existingBinaryNestedTypes = existingType.getMemberTypes();
+ if ((binaryNestedTypes == null && existingBinaryNestedTypes != null)
+ || (binaryNestedTypes != null && existingBinaryNestedTypes == null)) {
+ return true;
+ }
+ if (binaryNestedTypes != null) {
+ int bnLength = binaryNestedTypes.length;
+ for (int m = 0; m < bnLength; m++) {
+ IBinaryNestedType bnt = binaryNestedTypes[m];
+ IBinaryNestedType existingBnt = existingBinaryNestedTypes[m];
+ if (!CharOperation.equals(bnt.getName(), existingBnt.getName())) {
+ return true;
+ }
+ }
+ }
return false;
}
// return ret;
// }
- private String stringifyList(Set l) {
+ private String stringifySet(Set<?> l) {
StringBuffer sb = new StringBuffer();
sb.append("{");
- for (Iterator iter = l.iterator(); iter.hasNext();) {
+ for (Iterator<?> iter = l.iterator(); iter.hasNext();) {
Object el = iter.next();
sb.append(el);
if (iter.hasNext()) {
return sb.toString();
}
- protected void addAffectedSourceFiles(Set addTo, Set lastTimeSources) {
+ protected void addAffectedSourceFiles(Set<File> addTo, Set<File> lastTimeSources) {
if (qualifiedStrings.elementSize == 0 && simpleStrings.elementSize == 0) {
return;
}
if (listenerDefined()) {
getListener().recordDecision(
"Examining whether any other files now need compilation based on just compiling: '"
- + stringifyList(lastTimeSources) + "'");
+ + stringifySet(lastTimeSources) + "'");
}
// the qualifiedStrings are of the form 'p1/p2' & the simpleStrings are just 'X'
char[][][] qualifiedNames = ReferenceCollection.internQualifiedNames(qualifiedStrings);
// System.err.println("simple: " + simpleStrings);
// System.err.println("qualif: " + qualifiedStrings);
- for (Iterator i = references.entrySet().iterator(); i.hasNext();) {
- Map.Entry entry = (Map.Entry) i.next();
- ReferenceCollection refs = (ReferenceCollection) entry.getValue();
+ for (Iterator<Map.Entry<File, ReferenceCollection>> i = references.entrySet().iterator(); i.hasNext();) {
+ Map.Entry<File, ReferenceCollection> entry = i.next();
+ ReferenceCollection refs = entry.getValue();
if (refs != null && refs.includes(qualifiedNames, simpleNames)) {
- File file = (File) entry.getKey();
+ File file = entry.getKey();
if (file.exists()) {
if (!lastTimeSources.contains(file)) { // ??? O(n**2)
if (listenerDefined()) {
}
protected void addDependentsOf(File sourceFile) {
- List cfs = this.fullyQualifiedTypeNamesResultingFromCompilationUnit.get(sourceFile);
-
+ List<ClassFile> cfs = this.fullyQualifiedTypeNamesResultingFromCompilationUnit.get(sourceFile);
if (cfs != null) {
- for (Iterator iter = cfs.iterator(); iter.hasNext();) {
- ClassFile cf = (ClassFile) iter.next();
+ for (ClassFile cf : cfs) {
recordTypeChanged(cf.fullyQualifiedTypeName);
}
}
-
}
public void setStructureModel(AsmManager structureModel) {
}
public void clearBinarySourceFiles() {
- this.binarySourceFiles = new HashMap();
+ this.binarySourceFiles = new HashMap<String, List<UnwovenClassFile>>();
}
- public void recordBinarySource(String fromPathName, List unwovenClassFiles) {
+ public void recordBinarySource(String fromPathName, List<UnwovenClassFile> unwovenClassFiles) {
this.binarySourceFiles.put(fromPathName, unwovenClassFiles);
if (this.maybeIncremental()) {
- List simpleClassFiles = new LinkedList();
- for (Iterator iter = unwovenClassFiles.iterator(); iter.hasNext();) {
- UnwovenClassFile ucf = (UnwovenClassFile) iter.next();
+ List<ClassFile> simpleClassFiles = new LinkedList<ClassFile>();
+ for (UnwovenClassFile ucf : unwovenClassFiles) {
ClassFile cf = getClassFileFor(ucf);
simpleClassFiles.add(cf);
}
return new ClassFile(ucf.getClassName(), new File(ucf.getFilename()));
}
- public Map getBinarySourceMap() {
+ public Map<String, List<UnwovenClassFile>> getBinarySourceMap() {
return this.binarySourceFiles;
}
/**
* @return Returns the addedFiles.
*/
- public Set getAddedFiles() {
+ public Set<File> getAddedFiles() {
return this.addedFiles;
}
/**
* @return Returns the deletedFiles.
*/
- public Set getDeletedFiles() {
+ public Set<File> getDeletedFiles() {
return this.deletedFiles;
}
}
public void initializeAspectNamesToFileNameMap() {
- this.aspectsFromFileNames = new HashMap();
+ this.aspectsFromFileNames = new HashMap<String, char[]>();
}
// Will allow us to record decisions made during incremental processing, hopefully aid in debugging
}
public IBinaryType checkPreviousBuild(String name) {
- return (IBinaryType) resolvedTypeStructuresFromLastBuild.get(name);
+ return resolvedTypeStructuresFromLastBuild.get(name);
}
public AjBuildManager getAjBuildManager() {
import junit.framework.TestCase;
-
public class AjStateTest extends TestCase {
- private AjState aRightState;
- private AjBuildConfig oldConfig;
- private AjBuildConfig newConfig;
-
- public void testNoChange() {
- aRightState.setCouldBeSubsequentIncrementalBuild(true);
- assertTrue("Can do incremental",aRightState.prepareForNextBuild(newConfig));
- }
-
- public void testAddEntryToClasspath() {
- newConfig.getClasspath().add("anotherEntry");
- assertFalse("Can do incremental",aRightState.prepareForNextBuild(newConfig));
- }
-
- public void testRemoveEntryFromClasspath() {
- newConfig.getClasspath().remove(0);
- assertFalse("Can do incremental",aRightState.prepareForNextBuild(newConfig));
- }
-
- public void testReorderClasspath() {
- Object o = newConfig.getClasspath().remove(0);
- newConfig.getClasspath().add(o);
- assertFalse("Can do incremental",aRightState.prepareForNextBuild(newConfig));
- }
-
- public void testAddEntryToAspectpath() {
- newConfig.getAspectpath().add(new File("anotherEntry.jar"));
- assertFalse("Can do incremental",aRightState.prepareForNextBuild(newConfig));
- }
-
- public void testRemoveEntryFromAspectpath() {
- newConfig.getAspectpath().remove(0);
- assertFalse("Can do incremental",aRightState.prepareForNextBuild(newConfig));
- }
-
- public void testReorderAspectpath() {
- Object o = newConfig.getClasspath().remove(0);
- newConfig.getAspectpath().add(o);
- assertFalse("Can do incremental",aRightState.prepareForNextBuild(newConfig));
- }
-
- public void testAddEntryToInpath() {
- newConfig.getInpath().add(new File("anotherEntry"));
- assertFalse("Can do incremental",aRightState.prepareForNextBuild(newConfig));
- }
-
- public void testRemoveEntryFromInpath() {
- newConfig.getInpath().remove(0);
- assertFalse("Can do incremental",aRightState.prepareForNextBuild(newConfig));
- }
-
- public void testReorderInpath() {
- Object o = newConfig.getClasspath().remove(0);
- newConfig.getInpath().add(o);
- assertFalse("Can do incremental",aRightState.prepareForNextBuild(newConfig));
- }
-
- public void testAddEntryToInjars() {
- newConfig.getInJars().add(new File("anotherEntry.jar"));
- assertFalse("Can do incremental",aRightState.prepareForNextBuild(newConfig));
- }
-
- public void testRemoveEntryFromInjars() {
- newConfig.getInJars().remove(0);
- assertFalse("Can do incremental",aRightState.prepareForNextBuild(newConfig));
- }
-
- public void testReorderInjars() {
- Object o = newConfig.getClasspath().remove(0);
- newConfig.getInJars().add(o);
- assertFalse("Can do incremental",aRightState.prepareForNextBuild(newConfig));
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- aRightState = new AjState(null);
- oldConfig = new AjBuildConfig();
- newConfig = new AjBuildConfig();
- List cp = new ArrayList();
- cp.add("adir");
- cp.add("ajar.jar");
- oldConfig.setClasspath(cp);
- newConfig.setClasspath(new ArrayList(cp));
- List ap = new ArrayList();
- ap.add(new File("aLib.jar"));
- ap.add(new File("anotherLib.jar"));
- oldConfig.setAspectpath(ap);
- newConfig.setAspectpath(new ArrayList(ap));
- List ip = new ArrayList();
- ip.add(new File("adir"));
- ip.add(new File("ajar.jar"));
- oldConfig.setInPath(ip);
- newConfig.setInPath(new ArrayList(ip));
- List ij = new ArrayList();
- ij.add(new File("aLib.jar"));
- ij.add(new File("anotherLib.jar"));
- oldConfig.setInJars(ij);
- newConfig.setInJars(new ArrayList(ij));
- aRightState.prepareForNextBuild(oldConfig);
- aRightState.successfulCompile(oldConfig,true);
- }
+ private AjState aRightState;
+ private AjBuildConfig oldConfig;
+ private AjBuildConfig newConfig;
+
+ public void testNoChange() {
+ aRightState.setCouldBeSubsequentIncrementalBuild(true);
+ assertTrue("Can do incremental", aRightState.prepareForNextBuild(newConfig));
+ }
+
+ public void testAddEntryToClasspath() {
+ newConfig.getClasspath().add("anotherEntry");
+ assertFalse("Can do incremental", aRightState.prepareForNextBuild(newConfig));
+ }
+
+ public void testRemoveEntryFromClasspath() {
+ newConfig.getClasspath().remove(0);
+ assertFalse("Can do incremental", aRightState.prepareForNextBuild(newConfig));
+ }
+
+ public void testReorderClasspath() {
+ String o = newConfig.getClasspath().remove(0);
+ newConfig.getClasspath().add(o);
+ assertFalse("Can do incremental", aRightState.prepareForNextBuild(newConfig));
+ }
+
+ public void testAddEntryToAspectpath() {
+ newConfig.getAspectpath().add(new File("anotherEntry.jar"));
+ assertFalse("Can do incremental", aRightState.prepareForNextBuild(newConfig));
+ }
+
+ public void testRemoveEntryFromAspectpath() {
+ newConfig.getAspectpath().remove(0);
+ assertFalse("Can do incremental", aRightState.prepareForNextBuild(newConfig));
+ }
+
+ public void testReorderAspectpath() {
+ String o = newConfig.getClasspath().remove(0);
+ newConfig.getAspectpath().add(new File(o));
+ assertFalse("Can do incremental", aRightState.prepareForNextBuild(newConfig));
+ }
+
+ public void testAddEntryToInpath() {
+ newConfig.getInpath().add(new File("anotherEntry"));
+ assertFalse("Can do incremental", aRightState.prepareForNextBuild(newConfig));
+ }
+
+ public void testRemoveEntryFromInpath() {
+ newConfig.getInpath().remove(0);
+ assertFalse("Can do incremental", aRightState.prepareForNextBuild(newConfig));
+ }
+
+ public void testReorderInpath() {
+ String o = newConfig.getClasspath().remove(0);
+ newConfig.getInpath().add(new File(o));
+ assertFalse("Can do incremental", aRightState.prepareForNextBuild(newConfig));
+ }
+
+ public void testAddEntryToInjars() {
+ newConfig.getInJars().add(new File("anotherEntry.jar"));
+ assertFalse("Can do incremental", aRightState.prepareForNextBuild(newConfig));
+ }
+
+ public void testRemoveEntryFromInjars() {
+ newConfig.getInJars().remove(0);
+ assertFalse("Can do incremental", aRightState.prepareForNextBuild(newConfig));
+ }
+
+ public void testReorderInjars() {
+ String o = newConfig.getClasspath().remove(0);
+ newConfig.getInJars().add(new File(o));
+ assertFalse("Can do incremental", aRightState.prepareForNextBuild(newConfig));
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ aRightState = new AjState(null);
+ oldConfig = new AjBuildConfig();
+ newConfig = new AjBuildConfig();
+ List<String> cp = new ArrayList<String>();
+ cp.add("adir");
+ cp.add("ajar.jar");
+ oldConfig.setClasspath(cp);
+ newConfig.setClasspath(new ArrayList<String>(cp));
+ List<File> ap = new ArrayList<File>();
+ ap.add(new File("aLib.jar"));
+ ap.add(new File("anotherLib.jar"));
+ oldConfig.setAspectpath(ap);
+ newConfig.setAspectpath(new ArrayList<File>(ap));
+ List<File> ip = new ArrayList<File>();
+ ip.add(new File("adir"));
+ ip.add(new File("ajar.jar"));
+ oldConfig.setInPath(ip);
+ newConfig.setInPath(new ArrayList<File>(ip));
+ List<File> ij = new ArrayList<File>();
+ ij.add(new File("aLib.jar"));
+ ij.add(new File("anotherLib.jar"));
+ oldConfig.setInJars(ij);
+ newConfig.setInJars(new ArrayList<File>(ij));
+ aRightState.prepareForNextBuild(oldConfig);
+ aRightState.successfulCompile(oldConfig, true);
+ }
}