Skip to main content

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

Hi Andrew,

On 11/15/2013 09:02 PM, Andrew Eisenberg wrote:
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.

Is "Preconditions" in fact "com.google.common.base.Preconditions"?
If so, https://bugs.eclipse.org/382069 should've taken care of this.
(Which went into Kepler R).


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?

No, that option only affects the 'assert' keyword, not the
assert utilities handled by bug 382069.

HTH,
Stephan



Back to the top