Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unchecked cast warning in javac #994

Closed
Maaartinus opened this issue Jan 5, 2016 · 3 comments
Closed

Unchecked cast warning in javac #994

Maaartinus opened this issue Jan 5, 2016 · 3 comments

Comments

@Maaartinus
Copy link
Contributor

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.

@sgrimm-sg
Copy link

Here's how we solved this:

@Getter(lazy = true, onMethod = @__({@SuppressWarnings("unchecked")}))

@Maaartinus
Copy link
Contributor Author

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

@Maaartinus
Copy link
Contributor Author

Duplicate of #880

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants