Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Adding default methods to interfaces, what's CDT's policy?


From: cdt-dev-bounces@xxxxxxxxxxx <cdt-dev-bounces@xxxxxxxxxxx> on behalf of Marc-André Laperle <marc-andre.laperle@xxxxxxxxxxxx>
Sent: Monday, September 19, 2016 11:53:14 AM
To: CDT General developers list.
Subject: Re: [cdt-dev] Adding default methods to interfaces, what's CDT's policy?
 

I was planning to add a setting to ignore this in PDE. In Trace Compass, we don't want to consider this as a breaking change. But maybe we could convince PDE that it should be ignored by default? In both cases, we'll likely need a setting for projects who do want this as an error.


Marc-Andre


From: cdt-dev-bounces@xxxxxxxxxxx <cdt-dev-bounces@xxxxxxxxxxx> on behalf of Doug Schaefer <dschaefer@xxxxxxxxxxxxxx>
Sent: Monday, September 19, 2016 11:40:26 AM
To: CDT General developers list.
Subject: Re: [cdt-dev] Adding default methods to interfaces, what's CDT's policy?
 
I want to know why that’s true and “Add abstract method, If method need not be implemented by Client” is compatible. Seems like the same thing to me.

From: <cdt-dev-bounces@xxxxxxxxxxx> on behalf of Marc Khouzam <marc.khouzam@xxxxxxxxxxxx>
Reply-To: "CDT General developers list." <cdt-dev@xxxxxxxxxxx>
Date: Monday, September 19, 2016 at 11:36 AM
To: "cdt-dev@xxxxxxxxxxx" <cdt-dev@xxxxxxxxxxx>
Subject: [cdt-dev] Adding default methods to interfaces, what's CDT's policy?

Hi,


according to

https://wiki.eclipse.org/Evolving_Java-based_APIs_2#Evolving_API_Interfaces

adding a default method to an existing interface (that is implementable),

is a breaking API change.  The rule does provide an 'exception' if the benefit is felt

to outweigh the risk. See below for explanation.


I find using default method makes the code much simpler (avoiding interface2, interface3, interface4, etc).


What do others feel we should do?  Should it be on a case-by-case basis (I find that hard to establish)?

Or should we have a recommended, or allowed approach?


Thanks


P.S. We have such changes in 9.2


P.P.S. The explanation from that wiki about why the default breaks the API.


(8) Adding a default method will break an existing client type if it already implements another interface that declares a default method with a matching signature, and the client type already refers to the default method from the other interface (except when using the Interface.super.method() notation). The added default method will cause an IncompatibleClassChangeError at run time, see JLS8 13.5.6 (http://docs.oracle.com/javase/specs/jls/se8/html/jls-13.html#jls-13.5.6). Furthermore, re-compiling the type will result in a compile error.

In cases where the risk of multiple inheritance of the same method from multiple interfaces is deemed low and the added value is deemed sufficiently high, selected default methods can be added to existing interfaces. However, such a change should only be applied in an early milestone, and it should be reverted if clients report any difficulties with the change.


Back to the top