Skip to content

Commit 7852b6a

Browse files
authored
Merge pull request scala/scala#6729 from smarter/replace/Cloneable-Serializable
Replace Cloneable/Serializable traits with type aliases
2 parents 5d6baac + d3d7495 commit 7852b6a

File tree

4 files changed

+7
-40
lines changed

4 files changed

+7
-40
lines changed

library/src/scala/Cloneable.scala

Lines changed: 0 additions & 14 deletions
This file was deleted.

library/src/scala/Serializable.scala

Lines changed: 0 additions & 14 deletions
This file was deleted.

library/src/scala/package.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import scala.annotation.migration
1414
* @contentDiagram hideNodes "scala.Serializable"
1515
*/
1616
package object scala {
17+
type Cloneable = java.lang.Cloneable
18+
type Serializable = java.io.Serializable
19+
1720
type Throwable = java.lang.Throwable
1821
type Exception = java.lang.Exception
1922
type Error = java.lang.Error

library/src/scala/runtime/LambdaDeserializer.scala

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@ object LambdaDeserializer {
1919
* concurrent deserialization of the same lambda expression may spin up more than one class.
2020
*
2121
* Assumptions:
22-
* - No additional marker interfaces are required beyond `{java.io,scala.}Serializable`. These are
22+
* - No additional marker interfaces are required beyond `java.io.Serializable`. These are
2323
* not stored in `SerializedLambda`, so we can't reconstitute them.
2424
* - No additional bridge methods are passed to `altMetafactory`. Again, these are not stored.
2525
*
2626
* @param lookup The factory for method handles. Must have access to the implementation method, the
27-
* functional interface class, and `java.io.Serializable` or `scala.Serializable` as
28-
* required.
27+
* functional interface class, and `java.io.Serializable`.
2928
* @param cache A cache used to avoid spinning up a class for each deserialization of a given lambda. May be `null`
3029
* @param serialized The lambda to deserialize. Note that this is typically created by the `readResolve`
3130
* member of the anonymous class created by `LambdaMetaFactory`.
@@ -77,20 +76,15 @@ object LambdaDeserializer {
7776
throw new IllegalArgumentException("Illegal lambda deserialization")
7877
}
7978

80-
val flags: Int = LambdaMetafactory.FLAG_SERIALIZABLE | LambdaMetafactory.FLAG_MARKERS
81-
val isScalaFunction = functionalInterfaceClass.getName.startsWith("scala.Function")
82-
val markerInterface: Class[_] = loader.loadClass(if (isScalaFunction) ScalaSerializable else JavaIOSerializable)
79+
val flags: Int = LambdaMetafactory.FLAG_SERIALIZABLE
8380

8481
LambdaMetafactory.altMetafactory(
8582
lookup, getFunctionalInterfaceMethodName, invokedType,
8683

8784
/* samMethodType = */ funcInterfaceSignature,
8885
/* implMethod = */ implMethod,
8986
/* instantiatedMethodType = */ instantiated,
90-
/* flags = */ flags.asInstanceOf[AnyRef],
91-
/* markerInterfaceCount = */ 1.asInstanceOf[AnyRef],
92-
/* markerInterfaces[0] = */ markerInterface,
93-
/* bridgeCount = */ 0.asInstanceOf[AnyRef]
87+
/* flags = */ flags.asInstanceOf[AnyRef]
9488
)
9589
}
9690

@@ -111,8 +105,6 @@ object LambdaDeserializer {
111105
factory.invokeWithArguments(captures: _*)
112106
}
113107

114-
private[this] val ScalaSerializable = "scala.Serializable"
115-
116108
private[this] val JavaIOSerializable = {
117109
// We could actually omit this marker interface as LambdaMetaFactory will add it if
118110
// the FLAG_SERIALIZABLE is set and of the provided markers extend it. But the code

0 commit comments

Comments
 (0)