Skip to content
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

transient annotations in traits not inherited in Scala 2.8 #2511

Closed
scabug opened this issue Oct 22, 2009 · 4 comments
Closed

transient annotations in traits not inherited in Scala 2.8 #2511

scabug opened this issue Oct 22, 2009 · 4 comments
Assignees

Comments

@scabug
Copy link

scabug commented Oct 22, 2009

Using today's nightly build (2.8.0.r19180-b20091021023451), the following test code returns "foo" for Test.run under 2.8 but null under 2.7 (the latter is the expect behaviour). It appears that in Scala 2.8, the @transient annotation in the trait is being ignored by the classes that extends the trait.

object Test {

  import java.io._
  
  trait IMyMessage extends Serializable {
    @transient var message:String = null
  }
  
  class MyMessage extends IMyMessage
 
  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
  }
}
@scabug
Copy link
Author

scabug commented Oct 22, 2009

Imported From: https://issues.scala-lang.org/browse/SI-2511?orig=1
Reporter: Sam Stainsby (stainsby)

@scabug
Copy link
Author

scabug commented Oct 22, 2009

Sam Stainsby (stainsby) said:
I should also mention that this affects things like Wicket and DB4O severely, where models have transient links to database-related objects.

@scabug
Copy link
Author

scabug commented Oct 23, 2009

Sam Stainsby (stainsby) said:
This appears to be a regression of #289 .

@scabug
Copy link
Author

scabug commented Nov 10, 2009

@lrytz said:
(In r19481) fixed #2511. it broke because now by default, field annotations now only end up on fields, but not on accessors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants