I am trying to develop an API. As part of this evolution, I need to change the return type of the method to a subclass (specialization) so that advanced clients can access new functions. Example (ignore the ugly:
public interface Entity {
boolean a();
}
public interface Intf1 {
Entity entity();
}
public interface Main {
Intf1 intf();
}
Now I want to have ExtendedEntity, Intf2, and Main as follows:
public interface ExtendedEntity extends Entity {
boolean b();
}
public interface Intf2 extends Intf1 {
ExtendedEntity entity();
}
public interface Main {
Intf2 intf();
}
However, since the return type of the method is part of its signature, the clients are already compiled with the previous version of the show linkage errors code (the method was not found by iirc).
Main . ( - , ) ( ). . , JVM, Java.
, , , ( ), Java .
public interface Main_Backward_Compatible {
Intf1 intf();
}
public interface Main extends Main_Backward_Compatible{
Intf2 intf();
}
, invokevirtual lookup ( ), , , , Intf2.
. , ( , ), .
? ( invokevirtual)?
, , - "" ? , , , .
,
.
- " " ( ):
- Clirr 0.6.
- IntelliJ "APIComparator".
Edit2 - , (think services). , , , ( Main) .