New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unit value equality is broken when deserialized #6935
Comments
Imported From: https://issues.scala-lang.org/browse/SI-6935?orig=1 |
Stephen Haberman (shaberman) said: |
Jan Vanek (j3vanek) said: package scala.runtime; public final class BoxedUnit implements java.io.Serializable { |
Stephen Haberman (shaberman) said: Would you like to submit a pull request with that fix? I can attempt to do that if you'd rather not be bothered. |
Jan Vanek (j3vanek) said: |
Jan Vanek (j3vanek) said: |
@ViniciusMiana said: |
@ViniciusMiana said: |
When () is deserialized, it no longer passes the equality check with itself.
import java.io._
val bytes = new ByteArrayOutputStream()
val out = new ObjectOutputStream(bytes)
out.writeObject(())
out.close()
val buf = bytes.toByteArray
buf: Array[Byte] = Array(-84, -19, 0, 5, 115, 114, 0, 23, 115, 99, 97, 108,
97, 46, 114, 117, 110, 116, 105, 109, 101, 46, 66, 111, 120, 101, 100, 85,
110, 105, 116, 116, -90, 125, 71, 29, -20, -53, -102, 2, 0, 0, 120, 112)
val in = new ObjectInputStream(new ByteArrayInputStream(buf))
val unit = in.readObject()
unit == ()
res4: Boolean = false
The last "unit == ()" should evaluate to true.
The text was updated successfully, but these errors were encountered: