Open mederel opened 11 months ago
The point here is that a method with a generic return type (like public T withBlabla(int blibli)
) is translated by the compiler to public Object withBlabla(int blibli)
. Hence; the return type has changed, despite the fact that you have restricted T
to MyClass
in the super class. The restriction of MyClass
is only evaluated by the compiler, at runtime it is possible to invoke the method and assign the return value to any Object reference.
Found a narrow usecase of moving a method to a superclass adding generic return type for Builder pattern.
Before:
After:
When using the japicmp-maven-plugin against this change we get:
Plugin config is:
All that is put together in this reproducer project:
reproducer-japicmp-error.zip