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
[error] Test scala.CaseObjectSerializationTest.canSerializeMatchError failed: java.io.InvalidClassException: scala.On$; no valid constructor, took 0.003 sec
[error] at java.io.ObjectStreamClass$ExceptionInfo.newInvalidClassException(ObjectStreamClass.java:158)
[error] at java.io.ObjectStreamClass.checkDeserialize(ObjectStreamClass.java:746)
[error] at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2202)
[error] at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1687)
[error] at java.io.ObjectInputStream.readObject(ObjectInputStream.java:489)
[error] at java.io.ObjectInputStream.readObject(ObjectInputStream.java:447)
[error] at scala.CaseObjectSerializationTest.canSerializeMatchError(CaseObjectSerializationTest.scala:21)
[error] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error] at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] at java.lang.reflect.Method.invoke(Method.java:566)
[error] ...
The text was updated successfully, but these errors were encountered:
Did some digging and found the cause of the issue / resolution in scala 2.13 here
scala 2.12: case object have synthetic method readResolve. This replaces the de-serialized object with the singleton instance. However, the de-serialization of the original object fails before the replacement. Indeed, a Serializable class must have access to the no-arg constructor of its first non-serializable superclass.
scala 2.13: case object have synthetic method writeReplace and uses a proxy to de-serialize the object to return the singleton instance. No failure here.
right... fundamentally a duplicate of #10412 , I think? though the failure mode is different. in any case, closing since it's fixed as of 2.13.0 and we don't keep 2.12-only tickets open
when declaring case objects that extends
class
instead oftrait
, serialization fails with scala 2.12.case objects are supposed to be serializable.
Reproduction steps
Scala version:
2.12.19
(also testing on2.12.x
scala branch)Added the test from
scala/2.12.x
branch: diffProblem
The test fails with
The text was updated successfully, but these errors were encountered: