Lombok: Unchecked cast warning in javac

Created on 5 Jan 2016  路  3Comments  路  Source: projectlombok/lombok

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.

Most helpful comment

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"})}))

All 3 comments

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"})}))
Was this page helpful?
0 / 5 - 0 ratings

Related issues

rdsubhas picture rdsubhas  路  3Comments

Bryksin picture Bryksin  路  3Comments

merric picture merric  路  4Comments

lombokissues picture lombokissues  路  3Comments

gardenias picture gardenias  路  3Comments