diff options
author | Prashant Sharma <prashant.s@imaginea.com> | 2015-05-06 16:26:03 +0530 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2015-05-26 18:46:37 +1000 |
commit | a3bb887e0200cf47a1fa2382a18948b3c553cf26 (patch) | |
tree | 8a01ed0ffec7fea0b8bb499bb1a1964d260fc7f3 /test/files/run/repl-serialization.check | |
parent | e12ba55589192fc3a3cc7b441569fbcabc04dd33 (diff) | |
download | scala-a3bb887e0200cf47a1fa2382a18948b3c553cf26.tar.gz scala-a3bb887e0200cf47a1fa2382a18948b3c553cf26.tar.bz2 scala-a3bb887e0200cf47a1fa2382a18948b3c553cf26.zip |
SI-7747 Make REPL wrappers serialization friendly
Spark has been shipping a forked version of our REPL for
sometime. We have been trying to fold the patches back into
the mainline so they can defork. This is the last outstanding
issue.
Consider this REPL session:
```
scala> val x = StdIn.readInt
scala> class A(a: Int)
scala> serializedAndExecuteRemotely {
() => new A(x)
}
```
As shown by the enclosed test, the REPL, even with the
Spark friendly option `-Yrepl-class-based`, will re-initialize
`x` on the remote system.
This test simulates this by running a REPL session, and then
deserializing the resulting closure into a fresh classloader
based on the class files generated by that session. Before this
patch, it printed "evaluating x" twice.
This is based on the Spark change described:
https://github.com/mesos/spark/pull/535#discussion_r3541925
A followup commit will avoid the `val lineN$read = ` part if we
import classes or type aliases only.
[Original commit from Prashant Sharma, test case from Jason Zaugg]
Diffstat (limited to 'test/files/run/repl-serialization.check')
-rw-r--r-- | test/files/run/repl-serialization.check | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/files/run/repl-serialization.check b/test/files/run/repl-serialization.check new file mode 100644 index 0000000000..c8439ea023 --- /dev/null +++ b/test/files/run/repl-serialization.check @@ -0,0 +1,21 @@ +== evaluating lines +extract: AnyRef => Unit = <function1> + evaluating x +x: Int = 0 +y: Int = <lazy> + evaluating z + evaluating zz +defined class D +z: Int = 0 +zz: Int = 0 +defined object O +defined class A +defined type alias AA +== evaluating lambda + evaluating y + evaluating O + constructing A +== reconstituting into a fresh classloader + evaluating O +== evaluating reconstituted lambda + constructing A |