[scala] possible bug in scala 28 with transient

View: New views
2 Messages — Rating Filter:   Alert me  

[scala] possible bug in scala 28 with transient

by Sam Stainsby-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I've just starting playing with Scala 2.8 (nightly builds) on a largish
project. I've noticed some changed behaviour for @transient annotations.
I wanted to check here with those more familiar with 2.8 before logging a
bug. Executing Test.run in the test code below returns null in Scala 2.7,
which is what I expect since 'message' is transient, and "foo" in Scala
2.8:

object Test {
 
  trait IMyMessage extends java.io.Serializable {
    @transient var message:String = null
  }
 
  class MyMessage extends IMyMessage

  import java.io._
 
  def serialize = {
    val buf = new ByteArrayOutputStream(10000)
    val out = new ObjectOutputStream(buf)
    val m = new MyMessage
    m.message = "foo"
    out.writeObject(m)
    out.flush
    buf.toByteArray
  }
   
  def unserialize(buf:Array[Byte]) = {
    val in = new ObjectInputStream(new ByteArrayInputStream(buf))
    in.readObject.asInstanceOf[MyMessage]
  }
   
  def run = {
    val m = unserialize(serialize)
    m.message
  }
}

This seems to only occur when the transient annotation is in an inherited
trait.

For me, it breaks my application when Wicket or DB4O try to serialise
something that wasn't meant to be serialised.

Cheers,
Sam.


Re: [scala] possible bug in scala 28 with transient

by Jan Kriesten-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi Sam,

please file a ticket since else these kind of problems are often overlooked by
the scala team.

And I'd hate as well if there would be trouble using Wicket with Scala in this
area again. :)

Best regards, --- Jan.