String filename = buildConfig.getOutxmlName();
// System.err.println("? AjBuildManager.writeOutxmlFile() outxml=" + filename);
- Map outputDirsAndAspects = findOutputDirsForAspects();
- Set outputDirs = outputDirsAndAspects.entrySet();
- for (Iterator iterator = outputDirs.iterator(); iterator.hasNext();) {
- Map.Entry entry = (Map.Entry) iterator.next();
- File outputDir = (File) entry.getKey();
- List aspects = (List) entry.getValue();
+ Map<File, List<String>> outputDirsAndAspects = findOutputDirsForAspects();
+ Set<Map.Entry<File, List<String>>> outputDirs = outputDirsAndAspects.entrySet();
+ for (Iterator<Map.Entry<File, List<String>>> iterator = outputDirs.iterator(); iterator.hasNext();) {
+ Map.Entry<File, List<String>> entry = iterator.next();
+ File outputDir = entry.getKey();
+ List<String> aspects = entry.getValue();
ByteArrayOutputStream baos = getOutxmlContents(aspects);
if (zos != null) {
ZipEntry newEntry = new ZipEntry(filename);
* Returns a map where the keys are File objects corresponding to all the output directories and the values are a list of
* aspects which are sent to that ouptut directory
*/
- private Map /* File --> List (String) */findOutputDirsForAspects() {
- Map outputDirsToAspects = new HashMap();
- Map aspectNamesToFileNames = state.getAspectNamesToFileNameMap();
+ private Map<File, List<String>> findOutputDirsForAspects() {
+ Map<File, List<String>> outputDirsToAspects = new HashMap<File, List<String>>();
+ Map<String, char[]> aspectNamesToFileNames = state.getAspectNamesToFileNameMap();
if (buildConfig.getCompilationResultDestinationManager() == null
|| buildConfig.getCompilationResultDestinationManager().getAllOutputLocations().size() == 1) {
// we only have one output directory...which simplifies things
if (buildConfig.getCompilationResultDestinationManager() != null) {
outputDir = buildConfig.getCompilationResultDestinationManager().getDefaultOutputLocation();
}
- List aspectNames = new ArrayList();
+ List<String> aspectNames = new ArrayList<String>();
if (aspectNamesToFileNames != null) {
- Set keys = aspectNamesToFileNames.keySet();
- for (Iterator iterator = keys.iterator(); iterator.hasNext();) {
- String name = (String) iterator.next();
+ Set<String> keys = aspectNamesToFileNames.keySet();
+ for (String name : keys) {
aspectNames.add(name);
}
}
List outputDirs = buildConfig.getCompilationResultDestinationManager().getAllOutputLocations();
for (Iterator iterator = outputDirs.iterator(); iterator.hasNext();) {
File outputDir = (File) iterator.next();
- outputDirsToAspects.put(outputDir, new ArrayList());
+ outputDirsToAspects.put(outputDir, new ArrayList<String>());
}
- Set entrySet = aspectNamesToFileNames.entrySet();
- for (Iterator iterator = entrySet.iterator(); iterator.hasNext();) {
- Map.Entry entry = (Map.Entry) iterator.next();
- String aspectName = (String) entry.getKey();
- char[] fileName = (char[]) entry.getValue();
+ Set<Map.Entry<String, char[]>> entrySet = aspectNamesToFileNames.entrySet();
+ for (Iterator<Map.Entry<String, char[]>> iterator = entrySet.iterator(); iterator.hasNext();) {
+ Map.Entry<String, char[]> entry = iterator.next();
+ String aspectName = entry.getKey();
+ char[] fileName = entry.getValue();
File outputDir = buildConfig.getCompilationResultDestinationManager().getOutputLocationForClass(
new File(new String(fileName)));
if (!outputDirsToAspects.containsKey(outputDir)) {
- outputDirsToAspects.put(outputDir, new ArrayList());
+ outputDirsToAspects.put(outputDir, new ArrayList<String>());
}
((List) outputDirsToAspects.get(outputDir)).add(aspectName);
}
// state.setRelationshipMap(AsmManager.getDefault().getRelationshipMap());
}
- //
+ //
// private void dumplist(List l) {
// System.err.println("---- "+l.size());
// for (int i =0 ;i<l.size();i++) System.err.println(i+"\t "+l.get(i));
return System.getProperty("user.dir"); //$NON-NLS-1$
}
- public void performCompilation(Collection files) {
+ public void performCompilation(Collection<File> files) {
if (progressListener != null) {
compiledCount = 0;
sourceFileCount = files.size();
// Translate from strings to File objects
String[] filenames = new String[files.size()];
int idx = 0;
- for (Iterator fIterator = files.iterator(); fIterator.hasNext();) {
- File f = (File) fIterator.next();
+ for (Iterator<File> fIterator = files.iterator(); fIterator.hasNext();) {
+ File f = fIterator.next();
filenames[idx++] = f.getPath();
}
// ClassFile classFile = (ClassFile) classFiles.nextElement();
// String filename = new String(classFile.fileName());
// filename = filename.replace('/', File.separatorChar) + ".class";
- //
+ //
// File destinationPath = buildConfig.getOutputDir();
// if (destinationPath == null) {
// filename = new File(filename).getName();
// } else {
// filename = new File(destinationPath, filename).getPath();
// }
- //
+ //
// //System.out.println("classfile: " + filename);
// unwovenClassFiles.add(new UnwovenClassFile(filename, classFile.getBytes()));
// }
// state.noteClassesFromFile(null, sourceFileName, Collections.EMPTY_LIST);
// }
// }
- //
+ //
private void setBuildConfig(AjBuildConfig buildConfig) {
this.buildConfig = buildConfig;
* Note :- the ClassFile objects contain no byte code, they are simply a Filename,typename pair.
*
* Populated in noteResult and used in addDependentsOf(File)
- *
- * Added by AMC during state refactoring, 1Q06.
*/
- private final Map/* <File, List<ClassFile> */fullyQualifiedTypeNamesResultingFromCompilationUnit = new HashMap();
+ private final Map<File, List<ClassFile>> fullyQualifiedTypeNamesResultingFromCompilationUnit = new HashMap<File, List<ClassFile>>();
/**
* Source files defining aspects
*
* Populated in noteResult and used in processDeletedFiles
- *
- * Added by AMC during state refactoring, 1Q06.
*/
private final Set/* <File> */sourceFilesDefiningAspects = new HashSet();
* input file has changed.
*
*/
- private Map/* File, List<UnwovenClassFile> */binarySourceFiles = new HashMap();
+ private Map<String, List<UnwovenClassFile>> binarySourceFiles = new HashMap<String, List<UnwovenClassFile>>();
/**
* Initially a duplicate of the information held in binarySourceFiles, with the key difference that the values are ClassFiles
* (type name, File) not UnwovenClassFiles (which also have all the byte code in them). After a batch build, binarySourceFiles
* is cleared, leaving just this much lighter weight map to use in processing subsequent incremental builds.
*/
- private final Map/* <File,List<ClassFile> */inputClassFilesBySource = new HashMap();
+ private final Map<String, List<ClassFile>> inputClassFilesBySource = new HashMap<String, List<ClassFile>>();
/**
* A list of the .class files created by this state that contain aspects.
*
* 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();
/**
* Populated by AjBuildManager to record the aspects with the file name in which they're contained. This is later used when
* output directories and in order to ask the OutputLocationManager for the output location for a given aspect we need the file
* in which it is contained.
*/
- private Map /* <String, char[]> */aspectsFromFileNames;
+ private Map<String, char[]> aspectsFromFileNames;
private Set/* File */compiledSourceFiles = new HashSet();
- private final Map/* String,File sourcelocation */resources = new HashMap();
+ private final Map<String, File> resources = new HashMap<String, File>();
SoftHashMap/* <baseDir,SoftHashMap<theFile,className>> */fileToClassNameMap = new SoftHashMap();
}
return false;
}
- List/* ClassFile */classes = (List) fullyQualifiedTypeNamesResultingFromCompilationUnit.get(aDeletedFile);
+ List/* ClassFile */classes = fullyQualifiedTypeNamesResultingFromCompilationUnit.get(aDeletedFile);
if (classes != null) {
for (Iterator iterator = classes.iterator(); iterator.hasNext();) {
ClassFile element = (ClassFile) iterator.next();
return true;
}
- private Collection getModifiedFiles() {
+ private Collection<File> getModifiedFiles() {
return getModifiedFiles(lastSuccessfulBuildTime);
}
* @param config the build configuration for which the output locations should be determined
* @return a list of file objects
*/
- private List /* File */getOutputLocations(AjBuildConfig config) {
- List outputLocs = new ArrayList();
+ private List<File> getOutputLocations(AjBuildConfig config) {
+ List<File> outputLocs = new ArrayList<File>();
// Is there a default location?
if (config.getOutputDir() != null) {
try {
}
}
if (config.getCompilationResultDestinationManager() != null) {
- List dirs = config.getCompilationResultDestinationManager().getAllOutputLocations();
- for (Iterator iterator = dirs.iterator(); iterator.hasNext();) {
- File f = (File) iterator.next();
+ List<File> dirs = config.getCompilationResultDestinationManager().getAllOutputLocations();
+ for (Iterator<File> iterator = dirs.iterator(); iterator.hasNext();) {
+ File f = iterator.next();
try {
File cf = f.getCanonicalFile();
if (!outputLocs.contains(cf)) {
}
public Set getFilesToCompile(boolean firstPass) {
- Set thisTime = new HashSet();
+ Set<File> thisTime = new HashSet<File>();
if (firstPass) {
- compiledSourceFiles = new HashSet();
- Collection modifiedFiles = getModifiedFiles();
+ compiledSourceFiles = new HashSet<File>();
+ Collection<File> modifiedFiles = getModifiedFiles();
// System.out.println("modified: " + modifiedFiles);
thisTime.addAll(modifiedFiles);
// ??? eclipse IncrementalImageBuilder appears to do this
// }
if (addedFiles != null) {
- for (Iterator fIter = addedFiles.iterator(); fIter.hasNext();) {
- Object o = fIter.next();
+ for (Iterator<File> fIter = addedFiles.iterator(); fIter.hasNext();) {
+ File o = fIter.next();
+ // TODO isn't it a set?? why do this
if (!thisTime.contains(o)) {
thisTime.add(o);
}
return (FORCE_INCREMENTAL_DURING_TESTING || this.couldBeSubsequentIncrementalBuild);
}
- public Map /* String -> List<ucf> */getBinaryFilesToCompile(boolean firstTime) {
+ public Map<String, List<UnwovenClassFile>> getBinaryFilesToCompile(boolean firstTime) {
if (lastSuccessfulBuildTime == -1 || buildConfig == null || !maybeIncremental()) {
return binarySourceFiles;
}
// else incremental...
- Map toWeave = new HashMap();
+ Map<String, List<UnwovenClassFile>> toWeave = new HashMap<String, List<UnwovenClassFile>>();
if (firstTime) {
- List addedOrModified = new ArrayList();
+ List<BinarySourceFile> addedOrModified = new ArrayList<BinarySourceFile>();
addedOrModified.addAll(addedBinaryFiles);
addedOrModified.addAll(getModifiedBinaryFiles());
- for (Iterator iter = addedOrModified.iterator(); iter.hasNext();) {
- AjBuildConfig.BinarySourceFile bsf = (AjBuildConfig.BinarySourceFile) iter.next();
+ for (Iterator<BinarySourceFile> iter = addedOrModified.iterator(); iter.hasNext();) {
+ AjBuildConfig.BinarySourceFile bsf = iter.next();
UnwovenClassFile ucf = createUnwovenClassFile(bsf);
if (ucf == null) {
continue;
}
- List ucfs = new ArrayList();
+ List<UnwovenClassFile> ucfs = new ArrayList<UnwovenClassFile>();
ucfs.add(ucf);
recordTypeChanged(ucf.getClassName());
binarySourceFiles.put(bsf.binSrc.getPath(), ucfs);
- List cfs = new ArrayList(1);
+ List<ClassFile> cfs = new ArrayList<ClassFile>(1);
cfs.add(getClassFileFor(ucf));
this.inputClassFilesBySource.put(bsf.binSrc.getPath(), cfs);
toWeave.put(bsf.binSrc.getPath(), ucfs);
cf.deleteFromFileSystem(buildConfig);
}
}
- for (Iterator iterator = classesFromName.values().iterator(); iterator.hasNext();) {
- File f = (File) iterator.next();
+ for (Iterator<File> iterator = classesFromName.values().iterator(); iterator.hasNext();) {
+ File f = iterator.next();
new ClassFile("", f).deleteFromFileSystem(buildConfig);
}
- Set resourceEntries = resources.entrySet();
- for (Iterator iter = resourceEntries.iterator(); iter.hasNext();) {
- Map.Entry resourcePair = (Map.Entry) iter.next();
- File sourcePath = (File) resourcePair.getValue();
+ Set<Map.Entry<String, File>> resourceEntries = resources.entrySet();
+ for (Iterator<Map.Entry<String, File>> iter = resourceEntries.iterator(); iter.hasNext();) {
+ Map.Entry<String, File> resourcePair = iter.next();
+ File sourcePath = resourcePair.getValue();
File outputLoc = getOutputLocationFor(buildConfig, sourcePath);
if (outputLoc != null) {
- outputLoc = new File(outputLoc, (String) resourcePair.getKey());
+ outputLoc = new File(outputLoc, resourcePair.getKey());
if (!outputLoc.getPath().equals(sourcePath.getPath()) && outputLoc.exists()) {
outputLoc.delete();
if (buildConfig.getCompilationResultDestinationManager() != null) {
File deletedFile = (File) i.next();
addDependentsOf(deletedFile);
- List cfs = (List) this.fullyQualifiedTypeNamesResultingFromCompilationUnit.get(deletedFile);
+ List cfs = this.fullyQualifiedTypeNamesResultingFromCompilationUnit.get(deletedFile);
this.fullyQualifiedTypeNamesResultingFromCompilationUnit.remove(deletedFile);
if (cfs != null) {
private void deleteBinaryClassFiles() {
// range of bsf is ucfs, domain is files (.class and jars) in inpath/jars
- for (Iterator iter = deletedBinaryFiles.iterator(); iter.hasNext();) {
- AjBuildConfig.BinarySourceFile deletedFile = (AjBuildConfig.BinarySourceFile) iter.next();
- List cfs = (List) this.inputClassFilesBySource.get(deletedFile.binSrc.getPath());
- for (Iterator iterator = cfs.iterator(); iterator.hasNext();) {
- deleteClassFile((ClassFile) iterator.next());
+ for (BinarySourceFile deletedFile : deletedBinaryFiles) {
+ List<ClassFile> cfs = this.inputClassFilesBySource.get(deletedFile.binSrc.getPath());
+ for (Iterator<ClassFile> iterator = cfs.iterator(); iterator.hasNext();) {
+ deleteClassFile(iterator.next());
}
this.inputClassFilesBySource.remove(deletedFile.binSrc.getPath());
}
UnwovenClassFile[] unwovenClassFiles = result.unwovenClassFiles();
for (int i = 0; i < unwovenClassFiles.length; i++) {
- File lastTimeRound = (File) classesFromName.get(unwovenClassFiles[i].getClassName());
+ File lastTimeRound = classesFromName.get(unwovenClassFiles[i].getClassName());
recordClassFile(unwovenClassFiles[i], lastTimeRound);
String name = unwovenClassFiles[i].getClassName();
if (lastTimeRound == null) {
*/
private void deleteTypesThatWereInThisCompilationUnitLastTimeRoundButHaveBeenDeletedInThisIncrement(File sourceFile,
UnwovenClassFile[] unwovenClassFiles) {
- List classFiles = (List) this.fullyQualifiedTypeNamesResultingFromCompilationUnit.get(sourceFile);
+ List 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
* @param icr, the CompilationResult from compiling it
*/
private void recordFQNsResultingFromCompilationUnit(File sourceFile, InterimCompilationResult icr) {
- List classFiles = new ArrayList();
+ List<ClassFile> classFiles = new ArrayList<ClassFile>();
UnwovenClassFile[] types = icr.unwovenClassFiles();
for (int i = 0; i < types.length; i++) {
classFiles.add(new ClassFile(types[i].getClassName(), new File(types[i].getFilename())));
continue; // might be overloading
} else {
// matching sigs
- if (!modifiersEqual(method.getModifiers(), existingMs[j].getModifiers())) {
+ IBinaryMethod existing = existingMs[j];
+ if (!modifiersEqual(method.getModifiers(), existing.getModifiers())) {
+ return true;
+ }
+
+ if (exceptionClausesDiffer(existing, method)) {
return true;
}
- if (exceptionClausesDiffer(existingMs[j], method)) {
+
+ char[] existingGSig = existing.getGenericSignature();
+ char[] methodGSig = method.getGenericSignature();
+ if ((existingGSig == null && methodGSig != null) || (existingGSig != null && methodGSig == null)) {
return true;
}
+ if (existingGSig != null) {
+ if (!CharOperation.equals(existingGSig, methodGSig)) {
+ return true;
+ }
+ }
+
continue new_method_loop;
}
}
}
protected void addDependentsOf(File sourceFile) {
- List cfs = (List) this.fullyQualifiedTypeNamesResultingFromCompilationUnit.get(sourceFile);
+ List cfs = this.fullyQualifiedTypeNamesResultingFromCompilationUnit.get(sourceFile);
if (cfs != null) {
for (Iterator iter = cfs.iterator(); iter.hasNext();) {
return this.binarySourceFiles;
}
- public Map getClassNameToFileMap() {
+ public Map<String, File> getClassNameToFileMap() {
return this.classesFromName;
}
// buildManager.setStructureModel(null);
}
- public Map getAspectNamesToFileNameMap() {
+ public Map<String, char[]> getAspectNamesToFileNameMap() {
return aspectsFromFileNames;
}