scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
230 stars 21 forks source link

scala-library 2.12.12 (and later) is not binary compatible with 2.12.11 (and earlier). #12890

Closed mchwedczuk-box-com closed 8 months ago

mchwedczuk-box-com commented 8 months ago

Reproduction steps

Scala version: 2.12.12 and later.

This PR https://github.com/scala/scala/pull/8824/files introduced certain changes to List class. One of the results of this was disappearance of List.$anonfun$flatMap$1$adapted method which was marked both public and static.

This causes troubles when upgrading to 2.12.12 from 2.12.11, e.g. here we have problem with json4s 3.5.0:

java.lang.NoSuchMethodError: scala.collection.immutable.List.$anonfun$flatMap$1$adapted(Lscala/runtime/BooleanRef;Lscala/runtime/ObjectRef;Lscala/runtime/ObjectRef;Ljava/lang/Object;)Ljava/lang/Object;
java.lang.BootstrapMethodError: java.lang.NoSuchMethodError: scala.collection.immutable.List.$anonfun$flatMap$1$adapted(Lscala/runtime/BooleanRef;Lscala/runtime/ObjectRef;Lscala/runtime/ObjectRef;Ljava/lang/Object;)Ljava/lang/Object;
    at org.json4s.MonadicJValue.findDirectByName(MonadicJValue.scala:25)
    at org.json4s.MonadicJValue.$bslash(MonadicJValue.scala:18)
    at com.box.artifactory.BoxArtifactoryClient.extractMd5(BoxAr

According to official docs 2.12.12 is binary compatible with 2.12.0 but clearly this is not the case.

I did not dig into it enought to check if json4s problems where caused by inline'ing or too aggressive optimization, but clearly stating that the new version is binary compatible is an overstatement here.

Can you please provide a fix that will make 2.12.12 and later versions fully compatible with 2.12.11?

Here is a diff between List versions of 2.12.12 and 2.12.11 (dumped via javap): image

eed3si9n commented 8 months ago

This is a fault of json4s, not Scala - https://github.com/json4s/json4s/issues/455