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
+18-10Lines changed: 18 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -47,14 +47,15 @@ As long as declarations in source have not changed, `@stableABI` annotated class
47
47
48
48
In this document we use term `Public API` to refer both to methods and fields defined as `ACC_PUBLIC` and `ACC_PROTECTED`.
49
49
Changes do binary descriptors of Public API may lead to runtime linkage failures.
50
-
* ####Binary compatibility
50
+
* #####Binary compatibility
51
51
52
52
Two versions of the same class are called binary compatible if there are no changes to the Public API of this class,
53
53
meaning that those two classes can be substituted in runtime without linkage errors.
54
54
55
55
## Use cases
56
56
57
-
2. Defining a class which is supposed to be also used from Java\Kotlin.
57
+
1. Publishing a library that would work across major Scala versions, such as 2.12 & 2.13 and Dotty.
58
+
2. Defining a class which is supposed to be also used from other JVM languages such as Java\Kotlin.
58
59
`@stableABI` will ensure both binary compatibility and that there are no unexpected methods
59
60
that would show up in members of a class or an interface.
60
61
@@ -70,9 +71,6 @@ SBT additionally compiles on demand the compiler bridge, which implements this J
70
71
2. Dotty\[[7]\] currently uses java defined interfaces as public API for IntelliJ in order to ensure binary compatibility.
71
72
These interfaces can be replaced by `@stableABI` annotated traits to reach the same goal.
72
73
73
-
74
-
75
-
76
74
## Design Guidelines
77
75
`@stableABI` is a feature which is supposed to be used by a small subset of the ecosystem to be binary compatible across major versions of Scala.
78
76
Thus this is designed as an advanced feature that is used rarely and thus is intentionally verbose.
@@ -163,7 +161,13 @@ which would have benefit of sharing the same source for two ecosystems.
163
161
164
162
Scala.js currently is binary compatible as long as original bytecode compiled by Scala JVM is binary compatible.
165
163
Providing stronger binary compatibility guarantees for JVM will automatically provide stronger guarantees for Scala.js.
164
+
165
+
166
+
## Binary compatibility and transitivity ##
167
+
TODO
166
168
169
+
## The case of the standard library ##
170
+
TODO
167
171
168
172
## Comparison with MiMa ##
169
173
The Migration Manager for Scala (MiMa in short) is a tool for diagnosing binary incompatibilities for Scala libraries.
@@ -184,13 +188,17 @@ This provides early guidance and warning when designing long-living APIs before
184
188
185
189
## Compilation scheme ##
186
190
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:
187
-
- classes and traits annotated as `@stableABI` are on the top level;
188
-
- no non-private members where introduced inside classes and traits annotated as `@stableABI` by compiler using phase travel;
189
-
- no non-private members inside classes and traits annotated as `@stableABI` has changed their binary descriptor from the one written by developer.
191
+
- classes, traits and objects annotated as `@stableABI` are on the top level;
192
+
- compiler did not introduce new Public API methods or fields inside `@stableABI` classes, traits and objects;
193
+
- compiler did not change descriptors of existing Public API methods or fields inside `@stableABI` classes, traits and objects.
194
+
195
+
This phase additionally warns if Public API method or field takes an argument or returns a value that isn't marked as `@stableABI`.
196
+
This warning can be suppressed by annotating with `@unchecked`.
190
197
191
-
The current prototype is implemented for Dotty and supports everything described in this SIP.
198
+
The current prototype is implemented for Dotty and supports everything described in this SIP, except warnings.
192
199
The implementation is simple with less than 50 lines of non-boilerplate code.
193
-
The current implementation has a scope for improvement of error messages that will report domain specific details for disallowed features, but it already prohibits them.
200
+
The current implementation has a scope for improvement of error messages that will report domain specific details for disallowed features,
201
+
but it already prohibits them.
194
202
195
203
## Addendum: Default methods ##
196
204
By `default methods` we mean non-abstract methods defined and implemented by a trait.
0 commit comments