|
1 | 1 | Evolving Java-based APIs 2
|
2 | 2 | ==========================
|
3 | 3 |
|
4 |
| -Part 2 of [Evolving\_Java-based\_APIs](https://github.com/eclipse-platform/eclipse.platform/blob/master/docs/Evolving-Java-based-APIs.md). |
5 |
| - |
6 |
| -Contents |
7 |
| --------- |
8 |
| - |
9 |
| -* [1 Achieving API Binary Compatibility](#Achieving-API-Binary-Compatibility) |
10 |
| - * [1.1 Evolving API packages](#Evolving-API-packages) |
11 |
| - * [1.2 Evolving API Interfaces](#Evolving-API-Interfaces) |
12 |
| - * [1.2.1 Evolving API interfaces - API methods](#Evolving-API-interfaces---API-methods) |
13 |
| - * [1.2.2 Evolving API interfaces - API fields](#Evolving-API-interfaces---API-fields) |
14 |
| - * [1.2.3 Evolving API interfaces - API type members](#Evolving-API-interfaces---API-type-members) |
15 |
| - * [1.3 Evolving API Classes](#Evolving-API-Classes) |
16 |
| - * [1.3.1 Evolving API classes - API methods and constructors](#Evolving-API-classes---API-methods-and-constructors) |
17 |
| - * [1.3.2 Evolving API classes - API fields](#Evolving-API-classes---API-fields) |
18 |
| - * [1.3.3 Evolving API classes - API type members](#Evolving-API-classes---API-type-members) |
19 |
| - * [1.4 Evolving non-API packages](#Evolving-non-API-packages) |
20 |
| - * [1.5 Turning non-generic types and methods into generic ones](#Turning-non-generic-types-and-methods-into-generic-ones) |
21 |
| - * [1.6 Evolving annotations on API elements](#Evolving-annotations-on-API-elements) |
22 |
| -* [2 Other Notes](#Other-Notes) |
| 4 | +Part 2 of [Evolving\_Java-based\_APIs](Evolving-Java-based-APIs.md). |
| 5 | + |
23 | 6 |
|
24 | 7 | Achieving API Binary Compatibility
|
25 | 8 | ----------------------------------
|
@@ -95,13 +78,13 @@ Evolving API interfaces is somewhat more straightforward than API classes since
|
95 | 78 | | Delete element from annotation type | - | **Breaks compatibility** (6) |
|
96 | 79 |
|
97 | 80 | (0) Although adding a new method to an API interface which need not be reimplemented by Clients does not break binary compatibility, a pre-existing Client subclass of an existing implementation might still provide a pre-existing implementation of a method by this name.
|
98 |
| -See [Evolving Java-based APIs#Example 4 - Adding an API method](https://github.com/eclipse-platform/eclipse.platform/blob/master/docs/Evolving-Java-based-APIs.md#Achieving-API-Binary-Compatibility) in the preceding section for why this breaks API contract compatibility. |
| 81 | +See [Evolving Java-based APIs#Example 4 - Adding an API method](Evolving-Java-based-APIs.md#Achieving-API-Binary-Compatibility) in the preceding section for why this breaks API contract compatibility. |
99 | 82 |
|
100 | 83 | (1) Adding a new method to an API interface that is implemented by Clients (e.g., a callback, listener, or visitor interface) breaks compatibility because hypothetical pre-existing implementations do not implement the new method.
|
101 | 84 |
|
102 | 85 | (2) Adding an API field to an API interface that is implemented by Clients is dangerous in two respects:
|
103 | 86 |
|
104 |
| -* It may break API contract compatibility similar to [Evolving\_Java-based\_APIs#Example\_4\_-\_Adding\_an\_API\_method](https://github.com/eclipse-platform/eclipse.platform/blob/master/docs/Evolving-Java-based-APIs.md#Achieving-API-Binary-Compatibility) in case of name clashes. |
| 87 | +* It may break API contract compatibility similar to [Evolving\_Java-based\_APIs#Example\_4\_-\_Adding\_an\_API\_method](Evolving-Java-based-APIs.md#Achieving-API-Binary-Compatibility) in case of name clashes. |
105 | 88 | * It may cause linkage errors in case an instance (respectively static) field hides a static (respectively instance) field, see [JLS8 13.4.8](https://docs.oracle.com/javase/specs/jls/se8/html/jls-13.html#jls-13.4.8). This can not happen if all field declarations follow the usual naming conventions from [JLS8 6.1](https://docs.oracle.com/javase/specs/jls/se8/html/jls-6.html#jls-6.1) and classes only have API fields that are either
|
106 | 89 | * "static final" (and hence have a name that doesn't contain any lowercase letters), or
|
107 | 90 | * non-static and non-final (and hence have a name that contains a least one lowercase letter)
|
@@ -225,15 +208,15 @@ Evolving API classes is somewhat more complex than API interfaces due to the wid
|
225 | 208 | | Re-order enum constants | - | Binary compatible (8) |
|
226 | 209 |
|
227 | 210 | (0) Although adding a new method to an API class which need not be reimplemented by Clients does not break binary compatibility, a pre-existing subclass might still provide a pre-existing implementation of a method by this name.
|
228 |
| -See [Evolving Java-based APIs#Example 4 - Adding an API method](https://github.com/eclipse-platform/eclipse.platform/blob/master/docs/Evolving-Java-based-APIs.md#Achieving-API-Binary-Compatibility) in the preceding section for why this breaks API contract compatibility. |
| 211 | +See [Evolving Java-based APIs#Example 4 - Adding an API method](Evolving-Java-based-APIs.md#Achieving-API-Binary-Compatibility) in the preceding section for why this breaks API contract compatibility. |
229 | 212 |
|
230 | 213 | (1) Adding a new method to an API class that must be reimplemented by Clients breaks compatibility because pre-existing subclasses would not provide any such implementation.
|
231 | 214 |
|
232 | 215 | (2) Adding the first constructor to an API class causes the compiler to no longer generate a default (public, 0 argument) constructor, thereby breaking compatibility with pre-existing code that invoked this API constructor. To avoid this pitfall, API classes should always explicitly declare at least one constructor.
|
233 | 216 |
|
234 | 217 | (3) Adding an API field to an API class that is extended by Clients is dangerous in two respects:
|
235 | 218 |
|
236 |
| -* It may break API contract compatibility similar to [Evolving\_Java-based\_APIs#Example\_4\_-\_Adding\_an\_API\_method](https://github.com/eclipse-platform/eclipse.platform/blob/master/docs/Evolving-Java-based-APIs.md#Achieving-API-Binary-Compatibility) in case of name clashes. |
| 219 | +* It may break API contract compatibility similar to [Evolving\_Java-based\_APIs#Example\_4\_-\_Adding\_an\_API\_method](Evolving-Java-based-APIs.md#Achieving-API-Binary-Compatibility) in case of name clashes. |
237 | 220 | * It may cause linkage errors in case an instance (respectively static) field hides a static (respectively instance) field, see [JLS8 13.4.8](https://docs.oracle.com/javase/specs/jls/se8/html/jls-13.html#jls-13.4.8). This can not happen if all field declarations follow the usual naming conventions from [JLS8 6.1](https://docs.oracle.com/javase/specs/jls/se8/html/jls-6.html#jls-6.1) and classes only have API fields that are either
|
238 | 221 | * "static final" (and hence have a name that doesn't contain any lowercase letters), or
|
239 | 222 | * non-static and non-final (and hence have a name that contains a least one lowercase letter)
|
@@ -390,5 +373,5 @@ Parties that declare annotation types should try to provide helpful guidance for
|
390 | 373 | Other Notes
|
391 | 374 | -----------
|
392 | 375 |
|
393 |
| -See [Part 3](https://github.com/eclipse-platform/eclipse.platform/blob/master/docs/Evolving-Java-based-APIs-3.md). |
| 376 | +See [Part 3](Evolving-Java-based-APIs-3.md). |
394 | 377 |
|
0 commit comments