If the compiler eliminates an annotated cast, it is required to retain the annotations on the cast in the class file (if the annotation type has at least RetentionPolicy.CLASS retention). When a cast is removed, the compiler may need to adjust (the locations of) the annotations, to account for the relationship between the expression’s type and the casted-to type. Consider:
class C<S, T> { ... } class D<A, B> extends C<B, A> { ... } ... ... (C<@A1 X, @A2 Y>) myD ...
The compiler may leave out the upcast, but in that case it must record that @A1 is attached to the second type argument of D, even though it was originally attached to the first type argument of C.
===