[JSR308] Some general questions

Federico Mancini mancini.federico at gmail.com
Fri Jan 9 06:34:30 EST 2009


Hi,
I am new to the field of static analysis and I would like to understand
a bit more, so I am sorry if some questions will be very trivial.

1) The Null checker provided with the jsr308 should guarantee (up to a a
certain limit that I would like to understand better) that there won't
be a NullPointerException in the program.
However a type checker (as I understood it) should guarantee only that
the null type system is enforced, i.e., no variable declared @NonNull
will ever be assigned a null value.
However this alsone should not not guarantee that there won't be a
NullPointerException in the program. In fact a @Nullable variable can
have value null, and this is fine for the type checker, but can still be
dereferenced (and that is the programmer fault for not handling this
case correctly).
Now, that makes me think that checking for possible
NullPointerExceptions is a different task than to guarantee that the
null type system is satisfied. So who takes care of the first problem?
A flow analysis system as the one in Findbugs? And in this case how can
you guarantee that no NullPointerExceptions will be thrown if the other
static analysis tools can't? Does it have to do with the type checking
or did I get it all wrong?

2) I think there might be a bug in the checker. Is it possible that it
does not check "if..else.." statements written implicitly  as
"(..?..:...)"?
I have a program that throws a NullPointerException, in particular it
explicitly returns a null value if the condition in the if statement is
satisfied, and it dereferences it at once. However no warning is issued
when I write the if-else statement in the implicit way.

3) Is it possible to define a new type by the kind of values that are
valid for that type? For example the type @Date that defines all strings
that matches the regular expression "[1-31]/[1-12]/[2000-2010]".
If so, how to extend the basic checker for this type?

Thanks in advance for any help and sorry if some of this was already
discussed previously or it is well known.

Federico Mancini



More information about the JSR308 mailing list