Adding method to value class breaks binary compatibility but is not reported
See original GitHub issueI made the following change. From
implicit class Ops(private val s: String) extends scala.AnyVal {
def `\\` (index: Int ): String = s.substring(index, index + 1)
}
to
implicit class Ops(private val s: String) extends scala.AnyVal {
def `\\` (index: Int ): String = s.substring(index, index + 1)
def `\\` (range: Range): String = range.map(s.charAt).mkString
}
Now here are multiple things that could be involved:
- it’s a value class (my guess)
- it’s an overloaded method
- it’s an implicit class
I have created a project that demonstrates the bug: https://github.com/Sciss/mima-bug-135 To reproduce:
git clone https://github.com/Sciss/mima-bug-135.git
cd mima-bug-135
git checkout foo-0.1.0
cd foo && sbt publish-local
cd ../bar && sbt publish-local
cd ../baz && sbt run
This should run without crash. Now we publish the updated version:
git checkout foo-0.1.1
cd ../foo && sbt mimaReportBinaryIssues && sbt publish-local
cd ../baz && sbt run
(note that Bar
was compiled against foo-0.1.0; MiMa does not report any issue).
This crashes with:
error] (run-main-0) java.lang.NoSuchMethodError: de.sciss.mima.package$Ops$.$bslash$extension(Ljava/lang/String;I)Ljava/lang/String;
java.lang.NoSuchMethodError: de.sciss.mima.package$Ops$.$bslash$extension(Ljava/lang/String;I)Ljava/lang/String;
at de.sciss.mima.Bar$.apply(Bar.scala:4)
at de.sciss.mima.Baz$.main(Baz.scala:4)
at de.sciss.mima.Baz.main(Baz.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Issue about "binary compatibility" - java - Stack Overflow
Changing methods or constructors to return values on inputs for which they previously either threw exceptions that normally should not occur.
Read more >Types of breaking changes - .NET - Microsoft Learn
This article outlines changes that affect compatibility and the way in which the .NET team evaluates each type of change.
Read more >Chapter 13. Binary Compatibility - Oracle Help Center
13.4. Adding new methods or constructors that overload existing methods or constructors does not break compatibility with pre-existing binaries.
Read more >Evolving Java-based APIs 2 - Eclipsepedia
(1) Adding and deleting checked exceptions declared as thrown by an API method does not break binary compatibility; however, it breaks contract ...
Read more >clirr - Check source and binary compatibility of Java libraries
Clirr is a tool that checks Java libraries for binary and source compatibility with older releases. Basically you give it two sets of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fixed in 2.13.0-RC1 with https://github.com/scala/scala/pull/7896
cc also @kailuowang
The problem here is that any member whose decoded name contains a
$
is considered non-accessible. I think the most straight-forward fix would be to exclude names that end in$extensions
or that contain$extension$
. It feels a bit dirty but so does excluding every name with a$
in the first place.