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

REOPENED
Unassigned

Status

()

Firefox for Android
General
REOPENED
6 years ago
6 years ago

People

(Reporter: drs, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

6 years ago
I using OpenJDK 7, I sometimes get the following error when building:

GeckoActivity.java:24: warning: [cast] redundant cast to org.mozilla.gecko.GeckoApplication
            ((GeckoApplication) getApplication()).onActivityPause(this);
             ^
GeckoActivity.java:33: warning: [cast] redundant cast to org.mozilla.gecko.GeckoApplication
            ((GeckoApplication) getApplication()).onActivityResume(this);
             ^
GeckoActivity.java:70: 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

Updated

6 years ago
Status: UNCONFIRMED → NEW
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
(Reporter)

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

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.
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → WORKSFORME
This is happening for me, 3 times today.
Status: RESOLVED → REOPENED
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.