Bug 946083: Prevent the annotation processor from choking on stale classfiles in the objdir. r=rnewman
authorChris Kitching <chriskitching@linux.com>
Wed, 18 Dec 2013 02:30:57 +0000
changeset 161003 f490d24c6aac572b41d850cf9a32976f66939097
parent 161002 b329b704e89a34f13c9ca7b80b6115de896afb80
child 161004 8d77e66558eb66d10b323c8efd48193e96736e85
push id3372
push usercbook@mozilla.com
push dateWed, 18 Dec 2013 12:06:28 +0000
treeherderb2g-inbound@0758d09c0962 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman
bugs946083
milestone29.0a1
Bug 946083: Prevent the annotation processor from choking on stale classfiles in the objdir. r=rnewman
build/annotationProcessors/classloader/JarClassIterator.java
--- a/build/annotationProcessors/classloader/JarClassIterator.java
+++ b/build/annotationProcessors/classloader/JarClassIterator.java
@@ -26,17 +26,29 @@ public class JarClassIterator implements
         return mTargetClassListIterator.hasNext();
     }
 
     @Override
     public ClassWithOptions next() {
         String className = mTargetClassListIterator.next();
         try {
             Class<?> ret = mTarget.loadClass(className);
-            if (ret.getCanonicalName() == null || "null".equals(ret.getCanonicalName())) {
+            final String canonicalName;
+
+            // Incremental builds can leave stale classfiles in the jar. Such classfiles will cause
+            // an exception at this point. We can safely ignore these classes - they cannot possibly
+            // ever be loaded as they conflict with their parent class and will be killed by Proguard
+            // later on anyway.
+            try {
+                canonicalName = ret.getCanonicalName();
+            } catch (IncompatibleClassChangeError e) {
+                return next();
+            }
+
+            if (canonicalName == null || "null".equals(canonicalName)) {
                 // Anonymous inner class - unsupported.
                 return next();
             } else {
                 String generateName = null;
                 for (Annotation annotation : ret.getAnnotations()) {
                     Class<?> annotationType = annotation.annotationType();
                     if (annotationType.getCanonicalName().equals("org.mozilla.gecko.mozglue.generatorannotations.GeneratorOptions")) {
                         try {