Hi all,

Bug 1457255 added the javac options -Xlint:all and -Werror to all
gradle projects in m-c (except for the "third-party" project). That
means we now emit some extra warnings and all warnings are now treated
as errors during compilation.

Some commonly affected issues include,

* Override of equals() but not hashCode(). To fix it, add an override
of hashCode() every time equals() is overridden.

* Use of raw generic types (e.g. ArrayList without parameters). To fix
it, switch to generic types (e.g. ArrayList<String> or ArrayList<?>).

* Casting to generic types (e.g. (ArrayList<String>) someObject). To
fix it, use @SuppressWarnings("unchecked"), but you have to be certain
the casting will always succeed.

* Use of fall-through switch cases. To fix it, use
@SuppressWarnings("fallthrough") on the method. I thought about
disabling this warning, but it seems better to me to enable it and use
@SuppressWarnings.

* Use of parameterized varargs (e.g. <T> void foo(T... args)). To fix
it, use @SafeVarargs [1], but you have to be certain such usage is
safe.

Let me know if you run into any issues. Cheers!

Jim

[1] https://docs.oracle.com/javase/7/docs/api/java/lang/SafeVarargs.html
_______________________________________________
mobile-firefox-dev mailing list
mobile-firefox-dev@mozilla.org
https://mail.mozilla.org/listinfo/mobile-firefox-dev

Reply via email to