Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jdt-core-dev] (no subject)

I have a method that looks like this:

  void foo(@Nullable String str) {
    Preconditions.checkNonNull(str); // throws exception if str is null
    str.charAt(0); // Warning: Potential null pointer access
  }

Is there any way to have the null analysis engine avoid raising a
warning on the charAt method?  At runtime, str.charAt(0) will never
throw an NPE.

Note that for various reasons, we must have @Nullable on the str
parameter and we would like to avoid @SuppressWarnings in the method
since this would preclude any null analysis in the method.

There is an option "include 'assert' in null analysis". I wonder if
this can help at all.  Is this a limitation of null analysis, or is
there something I can do to address this?

thanks,
Andrew


Back to the top