From 6b02aaf5929ea866dc9ed9e20c77613118fdfcca Mon Sep 17 00:00:00 2001 From: aclement Date: Mon, 5 Jul 2010 22:16:23 +0000 Subject: [PATCH] 318884: incremental: throws clause change --- .../org/aspectj/ajdt/ajc/BuildArgParser.java | 12 +-- .../org/aspectj/ajdt/ajc/ConfigParser.java | 37 +++++--- .../internal/core/builder/AjBuildConfig.java | 18 ++-- .../ajdt/internal/core/builder/AjState.java | 85 ++++++++++++------- 4 files changed, 94 insertions(+), 58 deletions(-) diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java index 88357a014..b193f4604 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java @@ -146,11 +146,11 @@ public class BuildArgParser extends Main { boolean incrementalMode = buildConfig.isIncrementalMode() || buildConfig.isIncrementalFileMode(); - List xmlfileList = new ArrayList(); + List xmlfileList = new ArrayList(); xmlfileList.addAll(parser.getXmlFiles()); - List fileList = new ArrayList(); - List files = parser.getFiles(); + List fileList = new ArrayList(); + List files = parser.getFiles(); if (!LangUtil.isEmpty(files)) { if (incrementalMode) { MessageUtil.error(handler, "incremental mode only handles source files using -sourceroots"); @@ -159,7 +159,7 @@ public class BuildArgParser extends Main { } } - List javaArgList = new ArrayList(); + List javaArgList = new ArrayList(); // disable all special eclipse warnings by default - why??? // ??? might want to instead override getDefaultOptions() javaArgList.add("-warn:none"); @@ -171,7 +171,7 @@ public class BuildArgParser extends Main { 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(); @@ -571,7 +571,7 @@ public class BuildArgParser extends Main { } 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) { diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/ConfigParser.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/ConfigParser.java index 8ab62e231..b4175043e 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/ConfigParser.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/ConfigParser.java @@ -25,16 +25,16 @@ import java.util.List; public class ConfigParser { Location location; protected File relativeDirectory = null; - protected List files = new LinkedList(); - protected List xmlfiles = new ArrayList(); + protected List files = new LinkedList(); + protected List xmlfiles = new ArrayList(); private boolean fileParsed = false; protected static String CONFIG_MSG = "build config error: "; - public List getFiles() { + public List getFiles() { return files; } - public List getXmlFiles() { + public List getXmlFiles() { return xmlfiles; } @@ -73,8 +73,9 @@ public class ConfigParser { 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(); @@ -95,10 +96,11 @@ public class ConfigParser { 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) { @@ -155,8 +157,9 @@ public class ConfigParser { } 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()); @@ -189,8 +192,9 @@ public class ConfigParser { } void parseArgs(LinkedList args) { - while (args.size() > 0) + while (args.size() > 0) { parseOneArg(args); + } } protected Arg removeArg(LinkedList args) { @@ -204,8 +208,9 @@ public class ConfigParser { protected String removeStringArg(LinkedList args) { Arg arg = removeArg(args); - if (arg == null) + if (arg == null) { return null; + } return arg.getValue(); } @@ -217,10 +222,12 @@ public class ConfigParser { } 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; @@ -362,14 +369,16 @@ public class ConfigParser { } 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(); } } diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java index 180832fb1..40ab2ebc5 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java @@ -46,9 +46,9 @@ public class AjBuildConfig implements CompilerConfigurationChangeFlags { 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 files = new ArrayList(); + private List xmlfiles = new ArrayList(); + private List binaryFiles = new ArrayList(); // .class files in indirs... private List/* File */inJars = new ArrayList(); private List/* File */inPath = new ArrayList(); private Map/* String->File */sourcePathResources = new HashMap(); @@ -117,11 +117,11 @@ public class AjBuildConfig implements CompilerConfigurationChangeFlags { * * @return all source files that should be compiled. */ - public List/* File */getFiles() { + public List getFiles() { return files; } - public List/* File */getXmlFiles() { + public List getXmlFiles() { return xmlfiles; } @@ -129,7 +129,7 @@ public class AjBuildConfig implements CompilerConfigurationChangeFlags { * 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 getBinaryFiles() { return binaryFiles; } @@ -145,11 +145,11 @@ public class AjBuildConfig implements CompilerConfigurationChangeFlags { this.compilationResultDestinationManager = mgr; } - public void setFiles(List files) { + public void setFiles(List files) { this.files = files; } - public void setXmlFiles(List xmlfiles) { + public void setXmlFiles(List xmlfiles) { this.xmlfiles = xmlfiles; } @@ -217,7 +217,7 @@ public class AjBuildConfig implements CompilerConfigurationChangeFlags { inPath = dirsOrJars; // remember all the class files in directories on the inpath - binaryFiles = new ArrayList(); + binaryFiles = new ArrayList(); FileFilter filter = new FileFilter() { public boolean accept(File pathname) { return pathname.getPath().endsWith(".class"); diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java index bfe021157..a6b7ea2e7 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java @@ -34,6 +34,7 @@ import java.util.Set; 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; @@ -91,7 +92,7 @@ public class AjState implements CompilerConfigurationChangeFlags { * 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 affectedFiles = new HashSet(); // 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 @@ -100,10 +101,10 @@ public class AjState implements CompilerConfigurationChangeFlags { private StringSet simpleStrings = new StringSet(3); - private Set addedFiles; - private Set deletedFiles; - private Set /* BinarySourceFile */addedBinaryFiles; - private Set /* BinarySourceFile */deletedBinaryFiles; + private Set addedFiles; + private Set deletedFiles; + private Set addedBinaryFiles; + private Set deletedBinaryFiles; // For a particular build run, this set records the changes to classesFromName public final Set deltaAddedClasses = new HashSet(); @@ -151,7 +152,7 @@ public class AjState implements CompilerConfigurationChangeFlags { * * Refered to during addAffectedSourceFiles when calculating incremental compilation set. */ - private final Map/* */references = new HashMap(); + private final Map references = new HashMap(); /** * Holds UnwovenClassFiles (byte[]s) originating from the given file source. This could be a jar file, a directory, or an @@ -316,24 +317,24 @@ public class AjState implements CompilerConfigurationChangeFlags { } 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 oldFiles = new HashSet(buildConfig.getFiles()); + Set newFiles = new HashSet(newBuildConfig.getFiles()); - addedFiles = new HashSet(newFiles); + addedFiles = new HashSet(newFiles); addedFiles.removeAll(oldFiles); - deletedFiles = new HashSet(oldFiles); + deletedFiles = new HashSet(oldFiles); deletedFiles.removeAll(newFiles); } - Set oldBinaryFiles = new HashSet(buildConfig.getBinaryFiles()); - Set newBinaryFiles = new HashSet(newBuildConfig.getBinaryFiles()); + Set oldBinaryFiles = new HashSet(buildConfig.getBinaryFiles()); + Set newBinaryFiles = new HashSet(newBuildConfig.getBinaryFiles()); - addedBinaryFiles = new HashSet(newBinaryFiles); + addedBinaryFiles = new HashSet(newBinaryFiles); addedBinaryFiles.removeAll(oldBinaryFiles); - deletedBinaryFiles = new HashSet(oldBinaryFiles); + deletedBinaryFiles = new HashSet(oldBinaryFiles); deletedBinaryFiles.removeAll(newBinaryFiles); boolean couldStillBeIncremental = processDeletedFiles(deletedFiles); @@ -383,17 +384,17 @@ public class AjState implements CompilerConfigurationChangeFlags { return getModifiedFiles(lastSuccessfulBuildTime); } - Collection getModifiedFiles(long lastBuildTime) { - Set ret = new HashSet(); + Collection getModifiedFiles(long lastBuildTime) { + Set ret = new HashSet(); // Check if the build configuration knows what files have changed... - List/* File */modifiedFiles = buildConfig.getModifiedFiles(); + List 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 i = buildConfig.getFiles().iterator(); i.hasNext();) { + File file = i.next(); if (!file.exists()) { continue; } @@ -769,9 +770,9 @@ public class AjState implements CompilerConfigurationChangeFlags { 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> i = references.entrySet().iterator(); i.hasNext();) { + Map.Entry entry = i.next(); + ReferenceCollection refs = entry.getValue(); if (refs != null && refs.includes(qualifiedNames, simpleNames)) { if (listenerDefined()) { getListener().recordDecision( @@ -1481,7 +1482,7 @@ public class AjState implements CompilerConfigurationChangeFlags { 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()); @@ -1546,8 +1547,6 @@ public class AjState implements CompilerConfigurationChangeFlags { * 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 @@ -1679,8 +1678,8 @@ public class AjState implements CompilerConfigurationChangeFlags { // 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(); @@ -1734,6 +1733,9 @@ public class AjState implements CompilerConfigurationChangeFlags { if (!modifiersEqual(method.getModifiers(), existingMs[j].getModifiers())) { return true; } + if (exceptionClausesDiffer(existingMs[j], method)) { + return true; + } continue new_method_loop; } } @@ -1744,6 +1746,31 @@ public class AjState implements CompilerConfigurationChangeFlags { 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; -- 2.39.5