Closed Bug 875088 Opened 12 years ago Closed 12 years ago

HealthReportGenerator.java fails to compile with JDK 1.7: warning: [unchecked] unchecked call to put(K,V) as a member of the raw type HashMap

Categories

(Firefox Health Report Graveyard :: Client: Android, defect)

All
Android
defect
Not set
normal

Tracking

(firefox23 fixed, firefox24 fixed)

RESOLVED FIXED
Firefox 24
Tracking Status
firefox23 --- fixed
firefox24 --- fixed

People

(Reporter: cpeterson, Assigned: rnewman)

References

Details

Attachments

(1 file)

These methods are annotated with @SuppressWarnings("unchecked"), but JDK 1.7 apparently has a compiler bug that ignores unchecked warning suppressions: http://stackoverflow.com/questions/13829753/java-generics-suppresswarningsunchecked-mystery These unchecked warnings can be fixed by (safely) upcasting the JSONObject `document` to a HashMap<String,String> reference and then calling put() on a parameterized HashMap. Something like: JSONObject jsonDocument = new JSONObject(); HashMap<String,String> document = jsonDocument; ... document.put("thisPingDate", HealthReportUtils.getDateString(now())); ... return jsonDocument; Here is the list of warnings (treated as errors): JAR gecko-browser.jar /Users/cpeterson/Code/mozilla/inbound/mobile/android/base/background/healthreport/HealthReportGenerator.java:66: warning: [unchecked] unchecked call to put(K,V) as a member of the raw type HashMap document.put("lastPingDate", HealthReportUtils.getDateString(lastPingTime)); ^ where K,V are type-variables: K extends Object declared in class HashMap V extends Object declared in class HashMap /Users/cpeterson/Code/mozilla/inbound/mobile/android/base/background/healthreport/HealthReportGenerator.java:69: warning: [unchecked] unchecked call to put(K,V) as a member of the raw type HashMap document.put("thisPingDate", HealthReportUtils.getDateString(now())); ^ where K,V are type-variables: K extends Object declared in class HashMap V extends Object declared in class HashMap /Users/cpeterson/Code/mozilla/inbound/mobile/android/base/background/healthreport/HealthReportGenerator.java:70: warning: [unchecked] unchecked call to put(K,V) as a member of the raw type HashMap document.put("version", PAYLOAD_VERSION); ^ where K,V are type-variables: K extends Object declared in class HashMap V extends Object declared in class HashMap /Users/cpeterson/Code/mozilla/inbound/mobile/android/base/background/healthreport/HealthReportGenerator.java:72: warning: [unchecked] unchecked call to put(K,V) as a member of the raw type HashMap document.put("environments", getEnvironmentsJSON(currentEnvironment, envs)); ^ where K,V are type-variables: K extends Object declared in class HashMap V extends Object declared in class HashMap /Users/cpeterson/Code/mozilla/inbound/mobile/android/base/background/healthreport/HealthReportGenerator.java:73: warning: [unchecked] unchecked call to put(K,V) as a member of the raw type HashMap document.put("data", getDataJSON(currentEnvironment, envs, since)); ^ where K,V are type-variables: K extends Object declared in class HashMap V extends Object declared in class HashMap error: warnings found and -Werror specified Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. 1 error 5 warnings
Attached patch Proposed patch. v1 (deleted) — Splinter Review
Assignee: nobody → rnewman
Status: NEW → ASSIGNED
Attachment #753055 - Flags: review?(cpeterson)
Comment on attachment 753055 [details] [diff] [review] Proposed patch. v1 Review of attachment 753055 [details] [diff] [review]: ----------------------------------------------------------------- LGTM!
Attachment #753055 - Flags: review?(cpeterson) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/90c53f21e0d1 Clearing status-firefox23, because when Bug 858742 gets uplifted, it'll be wrong unless this goes with it :D
Target Milestone: --- → Firefox 24
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Comment on attachment 753055 [details] [diff] [review] Proposed patch. v1 [Approval Request Comment] Bug caused by (feature/regressing bug #): Earlier FHR patch. User impact if declined: None, but builds will fail on JDK7. Testing completed (on m-c, etc.): Landed ages ago. Risk to taking this patch (and alternatives if risky): None. String or IDL/UUID changes made by this patch: None.
Attachment #753055 - Flags: approval-mozilla-aurora?
Comment on attachment 753055 [details] [diff] [review] Proposed patch. v1 Approving for uplift as part of the body of work for FHR's first revision on Android.
Attachment #753055 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Product: Firefox Health Report → Firefox Health Report Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: