Incompatible types in argument

927 views Asked by At

When I compile my code with The Checker Framwork it complains:

incompatible types in argument.
  found   : null
  required: @NonNull String

for the first argument of:

ResultSet rs = connection.getMetaData().getColumns(null, schemaName, tableName, null)

I know that DatabaseMetadata.getColumns() allows a null catalog (the first argument). How do I tell the Checker Framework as much?

3

There are 3 answers

0
Jonathan Burke On BEST ANSWER

As Gili answered, you can use stub-files but, if you find a missing/incorrect annotation in the JDK, please report it to the Checker Framework mailing list [email protected] or report it as an issue in the issue tracker.

With each release, an Annotated JDK is bundled with the Checker Framework. It is used solely to retrieve annotations for common methods in the JDK. It is used automatically when you use the Checker Framework.

This annotation has been included since of Checker Framework release 1.8.0.

1
UFL1138 On

I'm not familiar with that framework; does it respect @SuppressWarnings in the context you're interested in?

https://checkerframework.org/manual/#suppressing-warnings-nullness

0
Gili On

In section Annotating Libraries the authors write you can either provide stub-files or rewrite the class files in question.

I ended up using stub files as they seemed easier to get started with.