You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Chesnay Schepler (JIRA)" <ji...@apache.org> on 2019/08/08 08:58:00 UTC
[jira] [Commented] (FLINK-13647) Allow default methods and static
methods to be added to public interfaces
[ https://issues.apache.org/jira/browse/FLINK-13647?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16902801#comment-16902801 ]
Chesnay Schepler commented on FLINK-13647:
------------------------------------------
According to [JLS 13.5.6|https://docs.oracle.com/javase/specs/jls/se8/html/jls-13.html#jls-13.5.6], adding default methods can lead to errors at runtime:
{code}
Adding a default method, or changing a method from abstract to default, does not break compatibility with pre-existing binaries, but may cause an IncompatibleClassChangeError if a pre-existing binary attempts to invoke the method. This error occurs if the qualifying type, T, is a subtype of two interfaces, I and J, where both I and J declare a default method with the same signature and result, and neither I nor J is a subinterface of the other.
{code}
I couldn't find anything specific on static methods added to interface, but [JLS 13.4.19|https://docs.oracle.com/javase/specs/jls/se8/html/jls-13.html#jls-13.4.19] could be relevant:
{code}
If a method that is not declared private is also declared static (that is, a class method) and is changed to not be declared static (that is, to an instance method), or vice versa, then compatibility with pre-existing binaries may be broken, resulting in a linkage time error, namely an IncompatibleClassChangeError, if these methods are used by the pre-existing binaries. Such changes are not recommended in code that has been widely distributed.
{code}
> Allow default methods and static methods to be added to public interfaces
> -------------------------------------------------------------------------
>
> Key: FLINK-13647
> URL: https://issues.apache.org/jira/browse/FLINK-13647
> Project: Flink
> Issue Type: Improvement
> Components: Build System
> Affects Versions: 1.9.0, 1.10.0
> Reporter: Till Rohrmann
> Priority: Major
> Fix For: 1.10.0
>
>
> Since Java 8, it is possible to extend interfaces by adding default methods and static methods. Flink's current japicmp plugin won't allow this and complains with a {{METHOD_ADDED_TO_INTERFACE}}.
> I think we should allow this in order to extend existing public interfaces. There is also a japicmp issue which addresses this problem: https://github.com/siom79/japicmp/issues/201.
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)