[TODO]
-
-
Save hubte1g/cb56e4f4ae656643d6a3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.ObjectOutputStream | |
import java.io.ObjectOutputStream | |
import java.io.ObjectInputStream | |
import java.io.FileOutputStream | |
import java.io.FileInputStream | |
class A {} | |
class B extends A with Serializable { | |
def f = (a: Int) => a | |
} | |
class C(val func: Int => Int) extends Serializable { } | |
object D { | |
def main(args: Array[String]) { | |
if (args.size == 0) { | |
println("Writing object to test.bin") | |
val b = new B() | |
val c = new C(b.f) | |
val fs = new FileOutputStream("test.bin") | |
val os = new ObjectOutputStream(fs) | |
os.writeObject(c) | |
os.close() | |
fs.close() | |
} | |
else { | |
println("Reading object from test.bin") | |
val fs = new FileInputStream("test.bin") | |
val os = new ObjectInputStream(fs) | |
val c = os.readObject().asInstanceOf[C] | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if [ -z $1 ]; then | |
echo "Usage: $0 scalaVersion" | |
exit -1 | |
fi | |
SCALA_VERSION=$1 | |
echo "Testing with Scala $1" | |
set -x | |
rm test.bin | |
sbt "++ $SCALA_VERSION" clean compile | |
scala -cp target/scala-*/classes/ D | |
scala -cp target/scala-*/classes/ D read | |
rm target/scala-*/classes/A.class | |
scala -cp target/scala-*/classes/ D read |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment