You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: sips/pending/_posts/2017-01-13-binary-compatibility.md
+6Lines changed: 6 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,7 @@ As defined by the JVM spec\[[4]\]:
36
36
runtime as they no longer link to the changed field.
37
37
38
38
In this document we use the term `binary descriptor` to refer to both method and field descriptors used by the JVM.
39
+
39
40
*##### Public API
40
41
41
42
Methods and fields marked with `ACC_PUBLIC`\[[5]\] may be accessed from any class and package.
@@ -50,6 +51,7 @@ As defined by the JVM spec\[[4]\]:
50
51
51
52
In this document we use the term `Public API` to refer both to methods and fields defined as `ACC_PUBLIC` and `ACC_PROTECTED`.
52
53
Changes do binary descriptors of Public API may lead to runtime linkage failures.
54
+
53
55
*##### Binary compatibility
54
56
55
57
Two versions of the same class are called binary compatible if there are no changes to the Public API of this class,
@@ -101,6 +103,7 @@ This is because we will be able to allow more features later, but we won't have
101
103
102
104
## Overview ##
103
105
In order for a class, trait or an object to succeed compilation with the `@stableABI` annotation it has to be:
106
+
104
107
- defined on the top level;
105
108
- if a class or an object has a companion annotated with `@stableABI`, than annotation applies to both of them;
106
109
- use a subset of Scala that during compilation does not require changes to public API of the class, including
@@ -164,6 +167,7 @@ Note that while those features are prohibited in the public API, they can be saf
164
167
- case classes. Can be simulated by explicitly defining getters and other members synthesized for a case class(`copy`, `productArity`, `apply`, `unapply`, etc).
165
168
166
169
The features listed below cannot be easily re-implemented in a class or trait annotated with `@stableABI`.
170
+
167
171
- default arguments;
168
172
- default methods. See Addendum;
169
173
- constant types(both explicit and inferred);
@@ -194,6 +198,7 @@ While in perfect world it would be nice to require all `@stableABI` classes and
194
198
and only return `@stableABI` values, we believe that all-or-nothing system will be a lot harder to adopt and migrate to.
195
199
196
200
Because of this we propose to emmit warnings in those cases:
201
+
197
202
- non-`@stableABI` value is returned from a method or field defined inside a `@stableABI` class or trait;
198
203
- an invocation to a method not-defined inside a `@stableABI` class is used in
199
204
implementation of a method or a field initializer inside a `@stableABI` class or trait.
@@ -237,6 +242,7 @@ This provides early guidance and warning when designing long-living APIs before
237
242
238
243
## Compilation scheme ##
239
244
No modification of typer or any existing phase is planned. The current proposed scheme introduces a late phase that runs before the very bytecode emission that checks that:
245
+
240
246
- classes, traits and objects annotated as `@stableABI` are on the top level;
241
247
- compiler did not introduce new Public API methods or fields inside `@stableABI` classes, traits and objects;
242
248
- compiler did not change descriptors of existing Public API methods or fields inside `@stableABI` classes, traits and objects.
0 commit comments