This issue is resolved by a simple and safe cast. The compiler generates a new method that matches the signature of the parent method. Inside this method, the parameter is downcasted, and the call is delegated to the user-defined method. This is known as a bridge method.
A bridge method can be observed using reflection. Its name matches the original method, but the parameter will be of the type to which the parent's generic has been erased. This method is marked with the
synthetic
flag, meaning it was generated by the compiler and not written by the programmer.Attempting to manually implement such a method would result in a compilation error.