diff options
author | Philipp Haller <hallerp@gmail.com> | 2009-01-14 14:39:31 +0000 |
---|---|---|
committer | Philipp Haller <hallerp@gmail.com> | 2009-01-14 14:39:31 +0000 |
commit | 774176c7a6b573c8a3922ac7e8f39b3f959d19de (patch) | |
tree | e2c274181c5e63759b5561065458a7b2e4af989d /test/files | |
parent | 323e895672ba0f9426be33de485bb7a6190af74c (diff) | |
download | scala-774176c7a6b573c8a3922ac7e8f39b3f959d19de.tar.gz scala-774176c7a6b573c8a3922ac7e8f39b3f959d19de.tar.bz2 scala-774176c7a6b573c8a3922ac7e8f39b3f959d19de.zip |
Fixed #1143 (again).
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/jvm/t1143-2.check | 1 | ||||
-rw-r--r-- | test/files/jvm/t1143-2/Marker.java | 4 | ||||
-rw-r--r-- | test/files/jvm/t1143-2/t1143-2.scala | 66 |
3 files changed, 71 insertions, 0 deletions
diff --git a/test/files/jvm/t1143-2.check b/test/files/jvm/t1143-2.check new file mode 100644 index 0000000000..2ae28399f5 --- /dev/null +++ b/test/files/jvm/t1143-2.check @@ -0,0 +1 @@ +pass diff --git a/test/files/jvm/t1143-2/Marker.java b/test/files/jvm/t1143-2/Marker.java new file mode 100644 index 0000000000..e9ac045b83 --- /dev/null +++ b/test/files/jvm/t1143-2/Marker.java @@ -0,0 +1,4 @@ +import java.io.Serializable; + +public interface Marker extends Serializable { +} diff --git a/test/files/jvm/t1143-2/t1143-2.scala b/test/files/jvm/t1143-2/t1143-2.scala new file mode 100644 index 0000000000..58bc1d763e --- /dev/null +++ b/test/files/jvm/t1143-2/t1143-2.scala @@ -0,0 +1,66 @@ +object Serialize { + @throws(classOf[java.io.IOException]) + def write[A](o: A): Array[Byte] = { + val ba = new java.io.ByteArrayOutputStream(512) + val out = new java.io.ObjectOutputStream(ba) + out.writeObject(o) + out.close() + ba.toByteArray() + } + @throws(classOf[java.io.IOException]) + @throws(classOf[ClassNotFoundException]) + def read[A](buffer: Array[Byte]): A = { + val in = + new java.io.ObjectInputStream(new java.io.ByteArrayInputStream(buffer)) + in.readObject().asInstanceOf[A] + } +} + +@serializable +@SerialVersionUID(1L) +class VarModel[T]( getter: => T, setter: T => Unit ) +{ + Serialize.write(getter) + Serialize.write(setter) + + def this( getter: => T ) = this( getter, null ) + + def getObject: AnyRef = getter.asInstanceOf[AnyRef] + + def setObject( v: AnyRef ) = { + if( setter==null ) + throw new RuntimeException( "Tried to set readonly model!") + setter( v.asInstanceOf[T] ) + } + + def detach = () +} + +@serializable +@SerialVersionUID(1L) +class Printer( p: VarModel[String] ) { + def print = println( p.getObject ); +} + +class Component extends Marker { } + +class Form extends Component { } + +@serializable +@SerialVersionUID(1L) +class Main { + var pass = "pass" + def main(args : Array[String]) : Unit = { + val f = new Form { + val p = new Printer( new VarModel( pass, pass=_ ) ); + p.print + } + () + } +} + +object Test { + def main(args: Array[String]) { + (new Main).main(Array[String]()) + } +} |