Closed Bug 1063991 Opened 10 years ago Closed 10 years ago

ClassFormatError: Absent Code attribute in method that is not native or abstract in class file org/mozilla/gecko/animation/PropertyAnimator$1

Categories

(Firefox Build System :: Android Studio and Gradle Integration, defect)

All
Android
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla35

People

(Reporter: rnewman, Assigned: ckitching)

References

Details

Attachments

(2 files)

Apply the attached patch, which simply hard-codes version ranges. Build.

 0:30.55 Exception in thread "main" java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file org/mozilla/gecko/animation/PropertyAnimator$1
 0:30.55 	at java.lang.ClassLoader.defineClass1(Native Method)
 0:30.55 	at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
 0:30.55 	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
 0:30.55 	at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
 0:30.55 	at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
 0:30.55 	at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
 0:30.55 	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
 0:30.55 	at java.security.AccessController.doPrivileged(Native Method)
 0:30.55 	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
 0:30.55 	at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
 0:30.55 	at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
 0:30.55 	at org.mozilla.gecko.annotationProcessors.classloader.JarClassIterator.next(JarClassIterator.java:33)
 0:30.55 	at org.mozilla.gecko.annotationProcessors.classloader.JarClassIterator.next(JarClassIterator.java:15)
 0:30.55 	at org.mozilla.gecko.annotationProcessors.AnnotationProcessor.main(AnnotationProcessor.java:72)
 0:30.55 make[2]: *** [GeneratedJNIWrappers.cpp] Error 1
Blocks: 1063984
Attached patch A workaroundSplinter Review
Well, this is stupid.

The problematic secrtion of code:

if (Versions.feature11Plus && treeObserver != null && treeObserver.isAlive()) {
            treeObserver.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
                @Override
                public boolean onPreDraw() {
                    if (treeObserver.isAlive()) {
                        treeObserver.removeOnPreDrawListener(this);
                    }

                    mFramePoster.postFirstAnimationFrame();
                    return true;
                }
            });
        } else {
            mFramePoster.postFirstAnimationFrame();
        }

Found here: http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/animation/PropertyAnimator.java#166

There's nothing wrong with this code as such, but it reveals a weird behaviour of javac.

feature11Plus is constant, so it's within the grasp of javac's dead code eliminator. But the block that's subject to deletion includes the declaration of an anonymous inner class.
Unfortunately, javac fails to properly delete this inner class. Instead of doing so, it just creates a broken, empty inner class:

https://pastebin.mozilla.org/6357856

This then trips up the annotation processor when it attempts to load the class.

This patch provides a (terrible) workaround. By moving the inner class declaration out of the conditional, we always get valid bytecode. Since dead code elimination will strip the only use of the new local variable, Proguard will subsequently come along and delete the anonymous inner class for us.
Comment on attachment 8485462 [details] [diff] [review]
A workaround

Review of attachment 8485462 [details] [diff] [review]:
-----------------------------------------------------------------

r+ with the AppConstants changed and the commit message made more descriptive. I'll land this.
Attachment #8485462 - Flags: review+
As a point of interest, I reduced PropertyAnimator's offending code to a minimal testcase and found something very interesting:

http://mail.openjdk.java.net/pipermail/compiler-dev/2014-September/008965.html

Turns out we found a javac bug. Probably should record that here before people start questioning the apparently-arbitrary change we just checked in.
https://hg.mozilla.org/mozilla-central/rev/5f773f541a85
Assignee: nobody → chriskitching
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 35
Product: Firefox for Android → Firefox Build System
Target Milestone: Firefox 35 → mozilla35
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: