]> source.dussan.org Git - aspectj.git/commitdiff
318884: incremental: throws clause change
authoraclement <aclement>
Mon, 5 Jul 2010 22:16:23 +0000 (22:16 +0000)
committeraclement <aclement>
Mon, 5 Jul 2010 22:16:23 +0000 (22:16 +0000)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/ConfigParser.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java

index 88357a0149eef5923defce3fff8d5f9277f8b765..b193f46043bddb02babcd4647927c3e7141e0577 100644 (file)
@@ -146,11 +146,11 @@ public class BuildArgParser extends Main {
 
                        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");
@@ -159,7 +159,7 @@ public class BuildArgParser extends Main {
                                }
                        }
 
-                       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");
@@ -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) {
index 8ab62e231e74f550b1d9c6191358646d5713ca69..b4175043e1ca3ae7c94a2c3b142e551d60c6d4be 100644 (file)
@@ -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<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;
        }
 
@@ -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();
                }
        }
index 180832fb1c08b951e892beb4990e895ea35c6240..40ab2ebc53f1b74de82147c11a25dd45c9b6c9e5 100644 (file)
@@ -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<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();
@@ -117,11 +117,11 @@ public class AjBuildConfig implements CompilerConfigurationChangeFlags {
         * 
         * @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;
        }
 
@@ -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<BinarySourceFile> getBinaryFiles() {
                return binaryFiles;
        }
 
@@ -145,11 +145,11 @@ public class AjBuildConfig implements CompilerConfigurationChangeFlags {
                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;
        }
 
@@ -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<BinarySourceFile>();
                FileFilter filter = new FileFilter() {
                        public boolean accept(File pathname) {
                                return pathname.getPath().endsWith(".class");
index bfe021157fc2f815330f346bfbe4a3d24be79516..a6b7ea2e7c3a85e46c635894058ae20c3790b058 100644 (file)
@@ -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<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
@@ -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<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();
 
@@ -151,7 +152,7 @@ public class AjState implements CompilerConfigurationChangeFlags {
         * 
         * 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
@@ -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<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);
@@ -383,17 +384,17 @@ public class AjState implements CompilerConfigurationChangeFlags {
                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;
                                }
@@ -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<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(
@@ -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;