[JSR308] Some general questions

Mahmood Ali mahmood at MIT.EDU
Mon Jan 12 11:26:26 EST 2009


Greetings,

> 1) In which file of the source code can i find the implementation of
> the rules that enforce the two properties that you mentioned?
> (Are they both part of the basic checker or do they use some  
> extension?)
Please review section 9 and review the code  
InterningAnnotatedTypeFactory code.  I imagine that your checker would  
be similar to InterningAnnotatedTypeFactory, but without the visitor.

I would be happy to answer any specific questions you have.

> 2) When you say that only NonNull variable can be dereferenced, what
> happens in the checker when checking this piece of code?
>
>  Integer i =somefunction(); \\somefunction can return null
>  if (i==null)
>    System.out.println("null");
>  else
>    System.out.println(i.intValue());
> [...]
> Is it because even though i can be null, the system infers that it is
> not when I dereference it (so it can be considered NonNull)[...]?
>

Correct.  The nullness checker (and the rest too) perform a flow  
sensitivity analysis for local variables to determine whether a  
variable is nullable or nonnull within a given scope.  In the provided  
example, the false clause is guaranteed to run only if (i != null).

Please read 2.7.2 of the checker manual.

Regards,
Mahmood




More information about the JSR308 mailing list