boolean incrementalMode = buildConfig.isIncrementalMode() || buildConfig.isIncrementalFileMode();
- List xmlfileList = new ArrayList();
+ List<File> xmlfileList = new ArrayList<File>();
xmlfileList.addAll(parser.getXmlFiles());
- List fileList = new ArrayList();
- List files = parser.getFiles();
+ List<File> fileList = new ArrayList<File>();
+ List<File> files = parser.getFiles();
if (!LangUtil.isEmpty(files)) {
if (incrementalMode) {
MessageUtil.error(handler, "incremental mode only handles source files using -sourceroots");
}
}
- List javaArgList = new ArrayList();
+ List<String> javaArgList = new ArrayList<String>();
// disable all special eclipse warnings by default - why???
// ??? might want to instead override getDefaultOptions()
javaArgList.add("-warn:none");
javaArgList.add("-bootclasspath");
javaArgList.add(System.getProperty("user.dir"));
javaArgList.addAll(parser.getUnparsedArgs());
- super.configure((String[]) javaArgList.toArray(new String[javaArgList.size()]));
+ super.configure(javaArgList.toArray(new String[javaArgList.size()]));
if (!proceed) {
buildConfig.doNotProceed();
} else if (arg.startsWith("-Xset:")) {
buildConfig.setXconfigurationInfo(arg.substring(6));
} else if (arg.startsWith("-aspectj.pushin=")) {
- // a little dirty but this should never be used in the IDE
+ // a little dirty but this should never be used in the IDE
try {
System.setProperty("aspectj.pushin", arg.substring(16));
} catch (Exception e) {
public class ConfigParser {
Location location;
protected File relativeDirectory = null;
- protected List files = new LinkedList();
- protected List xmlfiles = new ArrayList();
+ protected List<File> files = new LinkedList<File>();
+ protected List<File> xmlfiles = new ArrayList<File>();
private boolean fileParsed = false;
protected static String CONFIG_MSG = "build config error: ";
- public List getFiles() {
+ public List<File> getFiles() {
return files;
}
- public List getXmlFiles() {
+ public List<File> getXmlFiles() {
return xmlfiles;
}
while ((line = stream.readLine()) != null) {
lineNum += 1;
line = stripWhitespaceAndComments(line);
- if (line.length() == 0)
+ if (line.length() == 0) {
continue;
+ }
args.add(new Arg(line, new CPSourceLocation(configFile, lineNum)));
}
stream.close();
String stripSingleLineComment(String s, String commentString) {
int commentStart = s.indexOf(commentString);
- if (commentStart == -1)
+ if (commentStart == -1) {
return s;
- else
+ } else {
return s.substring(0, commentStart);
+ }
}
String stripWhitespaceAndComments(String s) {
}
void addFiles(File dir, FileFilter filter) {
- if (dir == null)
+ if (dir == null) {
dir = new File(System.getProperty("user.dir"));
+ }
if (!dir.isDirectory()) {
showError("can't find " + dir.getPath());
}
void parseArgs(LinkedList args) {
- while (args.size() > 0)
+ while (args.size() > 0) {
parseOneArg(args);
+ }
}
protected Arg removeArg(LinkedList args) {
protected String removeStringArg(LinkedList args) {
Arg arg = removeArg(args);
- if (arg == null)
+ if (arg == null) {
return null;
+ }
return arg.getValue();
}
}
boolean isSourceFileName(String s) {
- if (s.endsWith(".java"))
+ if (s.endsWith(".java")) {
return true;
- if (s.endsWith(".aj"))
+ }
+ if (s.endsWith(".aj")) {
return true;
+ }
// if (s.endsWith(".ajava")) {
// showWarning(".ajava is deprecated, replace with .aj or .java: " + s);
// return true;
}
public int getLine() {
- if (location == null)
+ if (location == null) {
return -1;
+ }
return location.getLine();
}
public File getFile() {
- if (location == null)
+ if (location == null) {
return null;
+ }
return location.getFile();
}
}
private CompilationResultDestinationManager compilationResultDestinationManager = null;
private List/* File */sourceRoots = new ArrayList();
private List/* File */changedFiles;
- private List/* File */files = new ArrayList();
- private List/* File */xmlfiles = new ArrayList();
- private List /* File */binaryFiles = new ArrayList(); // .class files in indirs...
+ 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();
*
* @return all source files that should be compiled.
*/
- public List/* File */getFiles() {
+ public List<File> getFiles() {
return files;
}
- public List/* File */getXmlFiles() {
+ public List<File> getXmlFiles() {
return xmlfiles;
}
* returned files includes all .class files found in a directory on the inpath, but does not include .class files contained
* within jars.
*/
- public List/* BinarySourceFile */getBinaryFiles() {
+ public List<BinarySourceFile> getBinaryFiles() {
return binaryFiles;
}
this.compilationResultDestinationManager = mgr;
}
- public void setFiles(List files) {
+ public void setFiles(List<File> files) {
this.files = files;
}
- public void setXmlFiles(List xmlfiles) {
+ public void setXmlFiles(List<File> xmlfiles) {
this.xmlfiles = xmlfiles;
}
inPath = dirsOrJars;
// remember all the class files in directories on the inpath
- binaryFiles = new ArrayList();
+ binaryFiles = new ArrayList<BinarySourceFile>();
FileFilter filter = new FileFilter() {
public boolean accept(File pathname) {
return pathname.getPath().endsWith(".class");
import org.aspectj.ajdt.internal.compiler.CompilationResultDestinationManager;
import org.aspectj.ajdt.internal.compiler.InterimCompilationResult;
+import org.aspectj.ajdt.internal.core.builder.AjBuildConfig.BinarySourceFile;
import org.aspectj.asm.AsmManager;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.Message;
* When looking at changes on the classpath, this set accumulates files in our state instance that affected by those changes.
* Then if we can do an incremental build - these must be compiled.
*/
- private final Set affectedFiles = new HashSet();
+ private final Set<File> affectedFiles = new HashSet<File>();
// these are references created on a particular compile run - when looping round in
// addAffectedSourceFiles(), if some have been created then we look at which source files
private StringSet simpleStrings = new StringSet(3);
- private Set addedFiles;
- private Set deletedFiles;
- private Set /* BinarySourceFile */addedBinaryFiles;
- private Set /* BinarySourceFile */deletedBinaryFiles;
+ private Set<File> addedFiles;
+ private Set<File> deletedFiles;
+ 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();
*
* Refered to during addAffectedSourceFiles when calculating incremental compilation set.
*/
- private final Map/* <File, ReferenceCollection> */references = new HashMap();
+ private final Map<File, ReferenceCollection> references = new HashMap<File, ReferenceCollection>();
/**
* Holds UnwovenClassFiles (byte[]s) originating from the given file source. This could be a jar file, a directory, or an
}
if ((newBuildConfig.getChanged() & PROJECTSOURCEFILES_CHANGED) == 0) {
- addedFiles = Collections.EMPTY_SET;
- deletedFiles = Collections.EMPTY_SET;
+ addedFiles = Collections.emptySet();
+ deletedFiles = Collections.emptySet();
} else {
- Set oldFiles = new HashSet(buildConfig.getFiles());
- Set newFiles = new HashSet(newBuildConfig.getFiles());
+ Set<File> oldFiles = new HashSet<File>(buildConfig.getFiles());
+ Set<File> newFiles = new HashSet<File>(newBuildConfig.getFiles());
- addedFiles = new HashSet(newFiles);
+ addedFiles = new HashSet<File>(newFiles);
addedFiles.removeAll(oldFiles);
- deletedFiles = new HashSet(oldFiles);
+ deletedFiles = new HashSet<File>(oldFiles);
deletedFiles.removeAll(newFiles);
}
- Set oldBinaryFiles = new HashSet(buildConfig.getBinaryFiles());
- Set newBinaryFiles = new HashSet(newBuildConfig.getBinaryFiles());
+ Set<BinarySourceFile> oldBinaryFiles = new HashSet<BinarySourceFile>(buildConfig.getBinaryFiles());
+ Set<BinarySourceFile> newBinaryFiles = new HashSet<BinarySourceFile>(newBuildConfig.getBinaryFiles());
- addedBinaryFiles = new HashSet(newBinaryFiles);
+ addedBinaryFiles = new HashSet<BinarySourceFile>(newBinaryFiles);
addedBinaryFiles.removeAll(oldBinaryFiles);
- deletedBinaryFiles = new HashSet(oldBinaryFiles);
+ deletedBinaryFiles = new HashSet<BinarySourceFile>(oldBinaryFiles);
deletedBinaryFiles.removeAll(newBinaryFiles);
boolean couldStillBeIncremental = processDeletedFiles(deletedFiles);
return getModifiedFiles(lastSuccessfulBuildTime);
}
- Collection getModifiedFiles(long lastBuildTime) {
- Set ret = new HashSet();
+ Collection<File> getModifiedFiles(long lastBuildTime) {
+ Set<File> ret = new HashSet<File>();
// Check if the build configuration knows what files have changed...
- List/* File */modifiedFiles = buildConfig.getModifiedFiles();
+ List<File> modifiedFiles = buildConfig.getModifiedFiles();
if (modifiedFiles == null) {
// do not know, so need to go looking
// not our job to account for new and deleted files
- for (Iterator i = buildConfig.getFiles().iterator(); i.hasNext();) {
- File file = (File) i.next();
+ for (Iterator<File> i = buildConfig.getFiles().iterator(); i.hasNext();) {
+ File file = i.next();
if (!file.exists()) {
continue;
}
simpleNames = ReferenceCollection.internSimpleNames(simpleNames, true);
}
int newlyAffectedFiles = 0;
- 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)) {
if (listenerDefined()) {
getListener().recordDecision(
private void recordClassFile(UnwovenClassFile thisTime, File lastTime) {
if (simpleStrings == null) {
// batch build
- // record resolved type for structural comparisions in future increments
+ // record resolved type for structural comparisons in future increments
// this records a second reference to a structure already held in memory
// by the world.
ResolvedType rType = world.resolve(thisTime.getClassName());
* creates to support the language - for non-static inner types it also mangles ctors to be prefixed with an instance of the
* surrounding type.
*
- * Warning : long but boring method implementation...
- *
* @param reader
* @param existingType
* @return
// sb.append("(L").append(new String(enclosingTypeName)).append(";");
// skippableDescriptorPrefix = sb.toString().toCharArray();
// }
- //
- //
+ //
+ //
// // remove the aspectOf, hasAspect, clinit and ajc$XXX methods
// // from those we compare with the existing methods - bug 129163
// List nonGenMethods = new ArrayList();
if (!modifiersEqual(method.getModifiers(), existingMs[j].getModifiers())) {
return true;
}
+ if (exceptionClausesDiffer(existingMs[j], method)) {
+ return true;
+ }
continue new_method_loop;
}
}
return false;
}
+ /**
+ * For two methods, discover if there has been a change in the exception types specified.
+ *
+ * @return true if the exception types have changed
+ */
+ private boolean exceptionClausesDiffer(IBinaryMethod lastMethod, IBinaryMethod newMethod) {
+ char[][] previousExceptionTypeNames = lastMethod.getExceptionTypeNames();
+ char[][] newExceptionTypeNames = newMethod.getExceptionTypeNames();
+ int pLength = previousExceptionTypeNames.length;
+ int nLength = newExceptionTypeNames.length;
+ if (pLength != nLength) {
+ return true;
+ }
+ if (pLength == 0) {
+ return false;
+ }
+ // TODO could be insensitive to an order change
+ for (int i = 0; i < pLength; i++) {
+ if (!CharOperation.equals(previousExceptionTypeNames[i], newExceptionTypeNames[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+
private boolean modifiersEqual(int eclipseModifiers, int resolvedTypeModifiers) {
resolvedTypeModifiers = resolvedTypeModifiers & ExtraCompilerModifiers.AccJustFlag;
eclipseModifiers = eclipseModifiers & ExtraCompilerModifiers.AccJustFlag;