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

RESOLVED FIXED in mozilla35


5 years ago
4 days ago


(Reporter: rnewman, Assigned: ckitching)


Dependency tree / graph

Firefox Tracking Flags

(Not tracked)



(2 attachments)

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(
 0:30.55 	at
 0:30.55 	at
 0:30.55 	at$100(
 0:30.55 	at$
 0:30.55 	at$
 0:30.55 	at Method)
 0:30.55 	at
 0:30.55 	at java.lang.ClassLoader.loadClass(
 0:30.55 	at java.lang.ClassLoader.loadClass(
 0:30.55 	at
 0:30.55 	at
 0:30.55 	at org.mozilla.gecko.annotationProcessors.AnnotationProcessor.main(
 0:30.55 make[2]: *** [GeneratedJNIWrappers.cpp] Error 1
Blocks: 1063984
Posted 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() {
                public boolean onPreDraw() {
                    if (treeObserver.isAlive()) {

                    return true;
        } else {

Found here:

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:

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:

Turns out we found a javac bug. Probably should record that here before people start questioning the apparently-arbitrary change we just checked in.
Assignee: nobody → chriskitching
Closed: 5 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.