Open cushon opened 6 years ago
For what it's worth I did not see this is in real-world code, I just got curious how the implementation handled this case and was surprised by the result. I don't consider it particularly high priority.
I'm curious what your take is, though. Is this an oversight in the spec?
In the following example, the canonical type of
B<Object>.I
isA<@Nullable Object>.I
. javac's type annotation handling appears to emittype_path
s for type annotations as they appears in the source type, which don't always correspond to the canonical type that appears in bytecide. For example, below there's a@NonNull
annotation on the fieldi
at location[TYPE_ARGUMENT(0)]
, which is correct for the non-canonical typeB<Object>.I
that appears in source and incorrect for the canonical typeA<Object>.I
that appears in bytecode.I'm not sure that javac's behaviour here is desirable (see JDK-8198566).
The example compiles cleanly but results in an NPE at runtime: