[Checkers] Interned checker throws ClassCastException
Matt Papi
mpapi at csail.mit.edu
Sat Mar 1 14:43:40 EST 2008
Hi Mahmood,
> 2. NullPointerException whenever we have an assignment to array access
> in a multidimential array.
> Reason:
> - For some reason, InternalUtils.symbol() returns null for array[i][j]
> Fix:
> - Haven't been resolved yet. I added a check to see if it's null. In the
> future, It should return the element of arraytype
Yeah, I think this is because symbol() doesn't recurse for ARRAY_ACCESS:
it should call itself on the expression instead of TreeInfo.symbol().
Actually, I just realized that sometimes an array access may not have a
symbol. For instance, in the expression:
(foo == bar ?
new int[@Interned] { 1, 2, 3 } : new int[@Interned] { 4, 5, 6 })[0]
The only sub-expressions that have elements are foo, bar, and int, and
none of these symbols would (or should) enable you to retrieve the
@Interned annotations on the new array expressions. If this is the case,
symbol() is only guaranteed to return an element for class, method,
and var declarations, member selects, method invocations, and
identifiers (I think).
What's the context in which you're calling symbol() on an array access?
Maybe there's a better way to get the information you need from the element?
> 4. NullPointerException and StackOverflow when visiting anonymous
> constructors for inner classes.
> I haven't investigated the issue thoroughly and it might actually a
> combination of the previous ones.
> For now, I disabled the checks for the assignments made within anonymous
> constructors.
Shouldn't it be the case that there are never illegal assignments made
in anonymous constructors? I just skimmed JLS 15.9.5.1, and it seems
like if the arguments to the "new" expression check out, the super()
call in the anonymous constructor will as well.
Also, I've noticed that some compiler-generated code ends up in the
parse tree before annotation processing and some is inserted after
(during tree translation, when generics are removed from the parse tree
and enhanced for loops are translated away. For the stuff that gets in
there beforehand, the compiler API often has incomplete data, like
missing symbols or type information.
Also, your fixes for #1 and #3 look right to me.
- Matt
P.S. This mailing list is great. I wish we'd set this up a while ago! :)
More information about the checkers
mailing list