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

RESOLVED FIXED in Firefox 35

Status

()

Firefox for Android
Build Config & IDE Support
RESOLVED FIXED
4 years ago
4 years ago

People

(Reporter: rnewman, Assigned: ckitching)

Tracking

Trunk
Firefox 35
All
Android
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Reporter)

Description

4 years ago
Created attachment 8485459 [details] [diff] [review]
Hard-code version flags.

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
(Reporter)

Updated

4 years ago
Blocks: 1063984
(Assignee)

Comment 1

4 years ago
Created attachment 8485462 [details] [diff] [review]
A workaround

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.
(Reporter)

Comment 2

4 years ago
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+
(Assignee)

Comment 4

4 years ago
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
Last Resolved: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 35
You need to log in before you can comment on or make changes to this bug.