This code produces a warning when compiled with javac:
public class WarningDemo {
List<Integer> makeList() {
return null;
}
@Getter(lazy=true) private final List<Integer> list = makeList();
}
With -Xlint I get
src/WarningDemo.java:10: warning: [unchecked] unchecked cast
@Getter(lazy=true) private final List<Integer> list = makeList();
^
required: List<Integer>
found: Object
The delomboked code has @java.lang.SuppressWarnings("all"), but either it doesn't help or the compilation works differently.
Here's how we solved this:
@Getter(lazy = true, onMethod = @__({@SuppressWarnings("unchecked")}))
This indeed helps, but
@Getter(lazy = true, onMethod = @__({@SuppressWarnings("all")}))
does not. So "all" does not mean "all" at all. This helps too:
@Getter(lazy = true, onMethod = @__({@SuppressWarnings({"unchecked", "all"})}))
Duplicate of https://github.com/rzwitserloot/lombok/issues/880
Most helpful comment
This indeed helps, but
does not. So "all" does not mean "all" at all. This helps too: