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: _overviews/tutorials/binary-compatibility-for-library-authors.md
+28-9Lines changed: 28 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -52,9 +52,8 @@ if we say that any library release of `v1.x.x` will be forwards compatible, we c
52
52
53
53
(For the rest of this guide, when you see the word "compatible" assume backwards compatibility, as it is the more common case of compatibility guarantee)
54
54
55
-
An important note to make is that while breaking source compatibility normally results in breaking binary compatibility, they are actually orthogonal
56
-
(breaking one does not imply breaking the other). See below for more examples (TODO: make sure we have examples?)
57
-
TODO: more facts?
55
+
An important note to make is that while source compatibility breakages normally results in binary compatibility breakages as well, they are actually orthogonal
56
+
(breaking one does not imply breaking the other).
58
57
59
58
## Why binary compatibility matters
60
59
@@ -88,19 +87,39 @@ How can we, as library authors, spare our users of runtime errors and dependency
88
87
***Avoid breaking binary compatibility** through careful design and evolution of your library interfaces
89
88
* Communicate binary compatibility breakages clearly through **versioning**
90
89
91
-
## MiMa - Check Binary Compatibility with Previous Library Versions
90
+
## MiMa - Check binary compatibility with previous library versions
92
91
93
-
The [Migration Manager for Scala](https://github.com/typesafehub/migration-manager) (MiMa) is a tool for diagnosing binary incompatibilities between different library versions.
92
+
The [Migration Manager for Scala](https://github.com/typesafehub/migration-manager) (MiMa) is a tool for diagnosing binary incompatibilities between different library versions.
93
+
It works by comparing the class files of two provided JARs and report any binary incompatibilities found.
94
94
95
-
When run standalone in the command line, it will compare the .class files in the two provided JARs and report any binary incompatibilities found. Most library authors use the [SBT plugin](https://github.com/typesafehub/migration-manager/wiki/Sbt-plugin)
96
-
to help spot binary incompatibility between library releases. (Follow the link for instructions on how to use it in your project)
95
+
By incorporating [MiMa SBT plugin](https://github.com/typesafehub/migration-manager/wiki/Sbt-plugin) into your SBT build, you can easily check whether
96
+
you have accidentally introduced binary incompatible changes. Detailed instruction on how to use the SBT plugin can be found in the link.
97
97
98
-
## Designing for Evolution - without breaking binary compatibility
98
+
We strongly encourage every library author to incorporate MiMa into their library release workflow.
99
99
100
-
TODO
100
+
## Evolving code without breaking binary compatibility
101
+
102
+
Binary compatibility breakages can often be avoided through careful use of certain Scala features as well as some techniques you can apply when modifying code.
103
+
104
+
Some language features may break binary compatibility:
105
+
106
+
* Default parameter values for methods or classes
107
+
* Case classes
108
+
* Default methods on traits (doesn't cause breakages since 2.12)
109
+
110
+
Techniques you can use to avoid breaking binary compatibility:
111
+
112
+
* Annotate public methods's return type explicitly
113
+
* Mark methods as package private when you want to remove a method or modify its signature
114
+
* Don't use inlining (for libraries)
115
+
116
+
For brevity of this guide, detailed explanation and runnable code examples can be found in [Binary Compatibility Code Examples & Explanation](https://github.com/jatcwang/binary-compatibility-guide).
117
+
118
+
Again, we recommend using MiMa to double check that you have not broken binary compatibility after making changes.
0 commit comments