Skip to main content
PreparationZone Logo
PreparationZone
Back to Java

Java · Hard · Pro

Bridge methods — generics and overriding bytecode?

JavaTrickySenior
Model answerPreview

Bridge methods

Generics are erased at compile time, but overriding must remain type-safe in the JVM. When a subclass narrows return types or implements a generic interface with a concrete type argument, the compiler synthesizes bridge methods—synthetic methods that delegate…