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

Add message parameter to castNonNull(@Nullable T ref) so the exceptions can be easier to read #3424

Closed
vlsi opened this issue Jul 4, 2020 · 2 comments · Fixed by #3427
Closed

Comments

@vlsi
Copy link
Contributor

vlsi commented Jul 4, 2020

The current method org.checkerframework.checker.nullness.NullnessUtil#castNonNull(@Nullable T ref) does not provde a way to describe the reference, so the assertion error would be hard to understand.

What do you think if an extra parameter was added?

Sample:

public void addFunctions(ResultSet rs) throws SQLException {
  while (rs.next()) {
    func.put(castNonNull(rs.getString(1), "function_name"), rs.getInt(2));
  }
}
@mernst
Copy link
Member

mernst commented Jul 6, 2020

@vlsi Thanks for the suggestion. You can use the extra arguments if you build from source, or you can wait for the next release at the beginning of August.

@vlsi
Copy link
Contributor Author

vlsi commented Jul 6, 2020

For now I've added my own castNonNull method, and the key driver was that IntelliJ IDEA somehow fails to decompile checkerframework.jar (I've filed an issue), so it doesn't understand castNonNull ensures non-nullness.

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

Successfully merging a pull request may close this issue.

2 participants