Sometimes get " warning: [cast] redundant cast..." when building




Firefox for Android
6 years ago
6 years ago


(Reporter: drs, Unassigned)


Firefox Tracking Flags

(Not tracked)




6 years ago
I using OpenJDK 7, I sometimes get the following error when building: warning: [cast] redundant cast to org.mozilla.gecko.GeckoApplication
            ((GeckoApplication) getApplication()).onActivityPause(this);
             ^ warning: [cast] redundant cast to org.mozilla.gecko.GeckoApplication
            ((GeckoApplication) getApplication()).onActivityResume(this);
             ^ warning: [cast] redundant cast to org.mozilla.gecko.GeckoApplication
        return ((GeckoApplication) getApplication()).isApplicationInBackground();
error: warnings found and -Werror specified
1 error
3 warnings
make[6]: *** [classes.dex] Error 1
make[6]: Leaving directory `/home/dsherk/mozilla-central/objdir-droid/mobile/android/base'
make[5]: *** [libs] Error 2
make[5]: Leaving directory `/home/dsherk/mozilla-central/objdir-droid/mobile/android'
make[4]: *** [libs_tier_app] Error 2
make[4]: Leaving directory `/home/dsherk/mozilla-central/objdir-droid'
make[3]: *** [tier_app] Error 2
make[3]: Leaving directory `/home/dsherk/mozilla-central/objdir-droid'
make[2]: *** [default] Error 2
make[2]: Leaving directory `/home/dsherk/mozilla-central/objdir-droid'
make[1]: *** [realbuild] Error 2
make[1]: Leaving directory `/home/dsherk/mozilla-central'
make: *** [build] Error 2

This never happens on a fresh checkout. Clobbering fixes it. kats suspects that it is caused by the instanceof check directly above the cast, which causes there to be two instanceof calls in the bytecode.
Assignee: nobody → bugmail.mozilla


6 years ago
Ever confirmed: true
I'm unable to reproduce this locally building with OpenJDK 7 on Linux. I'm also confused as to why it would never happen on a clobber build or fresh checkout; that implies it's not what I thought but that something is being cached somewhere. Does your compiler have any modifications or extensions or anything of that sort?
Unassigning to myself since I can't repro it and therefore can't debug it.
Assignee: bugmail.mozilla → nobody

Comment 3

6 years ago
Can you provide a suggested fix so I can try it next time I get it?
My best guess involves removing the two "instanceof GeckoApplication" checks entirely. The isApplicationInBackground function doesn't do the instanceof check, which the compiler might mistake as a hint that getApplication() always returns a GeckoApplication, making the casts redundant.

Comment 5

6 years ago
I haven't had this in several days, in contrast to before where it was several times a day. I haven't applied any fix so I'm not sure whether it has just gone away or I was unlucky before. I'm closing this for now and I'll re-open it if it comes up again.
Last Resolved: 6 years ago
Resolution: --- → WORKSFORME
This is happening for me, 3 times today.
Resolution: WORKSFORME → ---
It's a javac bug; doing a clean in mobile/android/base resolves it.
You need to log in before you can comment on or make changes to this bug.