summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/files/detach-run/actor/Client.scala4
-rw-r--r--test/files/detach-run/actor/Server.scala9
-rw-r--r--test/files/detach-run/actor/ServerClassLoader.scala154
-rw-r--r--test/files/detach-run/actor/ServerConsole.scala10
-rw-r--r--test/files/detach-run/actor/actor.scala4
-rw-r--r--test/files/detach-run/basic/Client.scala4
-rw-r--r--test/files/detach-run/basic/Server.scala4
-rw-r--r--test/files/detach-run/basic/ServerConsole.scala5
-rw-r--r--test/files/detach-run/basic/basic.scala6
9 files changed, 38 insertions, 162 deletions
diff --git a/test/files/detach-run/actor/Client.scala b/test/files/detach-run/actor/Client.scala
index af1c26ee1b..12573e24d3 100644
--- a/test/files/detach-run/actor/Client.scala
+++ b/test/files/detach-run/actor/Client.scala
@@ -1,3 +1,7 @@
+/*
+ * @author Stephane Micheloud
+ */
+
import scala.actors.Actor._, ClientHelper._
import scala.actors.remote._, RemoteActor._
import scala.remoting._, Debug._
diff --git a/test/files/detach-run/actor/Server.scala b/test/files/detach-run/actor/Server.scala
index 84df6f5d81..b56d22f744 100644
--- a/test/files/detach-run/actor/Server.scala
+++ b/test/files/detach-run/actor/Server.scala
@@ -1,6 +1,9 @@
-import scala.actors._, Actor._
-import scala.actors.remote._, RemoteActor._
-import scala.reflect.Manifest
+/*
+ * @author Stephane Micheloud
+ */
+
+import scala.actors.Actor._
+import scala.actors.remote.RemoteActor._
object Server extends ServerConsole {
private def computation(f: Int => Int): Int = {
diff --git a/test/files/detach-run/actor/ServerClassLoader.scala b/test/files/detach-run/actor/ServerClassLoader.scala
deleted file mode 100644
index 3f5d96a1a1..0000000000
--- a/test/files/detach-run/actor/ServerClassLoader.scala
+++ /dev/null
@@ -1,154 +0,0 @@
-import java.io._
-import java.net.{JarURLConnection, URL, URLClassLoader}
-
-import scala.remoting.Debug
-
- private class ServerObjectInputStream(in: InputStream, cl: ClassLoader)
- extends ObjectInputStream(in) {
- override def resolveClass(cd: ObjectStreamClass): Class[_] = {
- println("[ServerObjectInputStream] resolveClass "+cd.getName)
- try {
- Debug.info("load class "+cd.getName+" from "+cl)
- val c = cl.loadClass(cd.getName)
- Debug.info("loaded class "+c.getName)
- c
- } catch {
- case cnf: ClassNotFoundException =>
- Debug.info("resolve class (this) "+cd.getName)
- val c = super.resolveClass(cd)
- Debug.info("resolve class (super) "+c.getName)
- c
- }
- }
- override def resolveProxyClass(interfaces: Array[String]): Class[_] = {
- println("[ServerObjectInputStream] resolveProxyClass "+interfaces.toList)
- try {
- val c = cl.loadClass(interfaces.last)
- Debug.info("loaded class "+c.getName)
- c
- } catch {
- case cnf: ClassNotFoundException =>
- Debug.info("resolve proxy class (this) "+interfaces.last)
- val c = super.resolveProxyClass(interfaces)
- Debug.info("resolve proxy class (super) "+c.getName)
- c
- }
- }
- }
-/*
- // VARIANT 1
- class ServerClassLoader extends URLClassLoader(urls) {
- import scala.reflect.Manifest
- def load[A](a: Array[Byte])(implicit expected: Manifest[A]): A = {
- val in = new ServerObjectInputStream(new ByteArrayInputStream(a), this)
- val found = in.readObject.asInstanceOf[Manifest[_]]
- if (! (found <:< expected))
- throw new ClassCastException("type mismatch;"+
- "\n found : "+found+
- "\n required: "+expected)
- val o = in.readObject.asInstanceOf[A]
- in.close()
- o
- }
- override def findClass(name: String): Class[_] = {
- println("[ServerClassLoader] findClass "+name)
- val b = loadClassData(name)
- if (b != null) defineClass(name, b, 0, b.length)
- else super.findClass(name)
- }
- private def loadClassData(name: String): Array[Byte] = {
- println("[ServerClassLoader] loadClassData "+name)
- null
- }
- }
- val serverClassLoader = new ServerClassLoader
-*/
-
-/*
- class ServerClassLoader(parent: ClassLoader) extends URLClassLoader(urls, parent) {
- import scala.reflect.Manifest
- def load[A](a: Array[Byte])(implicit expected: Manifest[A]): A = {
- val in = new ServerObjectInputStream(new ByteArrayInputStream(a), this)
- val found = in.readObject.asInstanceOf[Manifest[_]]
- if (! (found <:< expected))
- throw new ClassCastException("type mismatch;"+
- "\n found : "+found+
- "\n required: "+expected)
- val o = in.readObject.asInstanceOf[A]
- in.close()
- o
- }
- override def findClass(name: String): Class[_] = {
- println("[ServerClassLoader] findClass "+name)
- val b = loadClassData(name)
- if (b != null) defineClass(name, b, 0, b.length)
- else super.findClass(name)
- }
- private def loadClassData(name: String): Array[Byte] = {
- println("[ServerClassLoader] loadClassData "+name)
- null
- }
- }
-*/
-class ServerClassLoader(urls: Array[URL], parent: ClassLoader)
-extends URLClassLoader(urls, parent) {
-
- private val cache = new collection.mutable.HashMap[String, Class[_]]
-
- for (url <- urls) {
- val jarurl = new URL("jar:"+url+"!/")
- val con = jarurl.openConnection().asInstanceOf[JarURLConnection]
- val jar = con.getJarFile
- val e = jar.entries
- while (e.hasMoreElements) {
- val ze = e.nextElement
- val path = ze.getName
- if (path endsWith ".class") {
- val size = ze.getSize
- val name = path.replace("/", ".").substring(0, path.length - 6)
- cache += name -> this.loadClass(name)
- println("[ServerClassLoader] added "+name+" ("+size+")")
- }
- }; //jar.close()
- }
-
- override def findClass(name: String): Class[_] = {
- println("[ServerClassLoader] findClass: name="+name)
- cache get name match {
- case Some(cl) =>
- println(name+" cached"); cl
- case None =>
- println(name+" not cached"); super.findClass(name)
- }
- }
-
-}
-
-/*
-try {
- JarFile jarFile = new JarFile(srcPath);
- Enumeration<JarEntry> entries = jarFile.entries();
- String url = "file:" + srcPath;
- System.out.println(url);
- URLClassLoader classLoader = new URLClassLoader(
- new URL[] { new URL(url) });
- while (entries.hasMoreElements()) {
- JarEntry jarEntry = (JarEntry) entries
- .nextElement();
- String classPath = jarEntry.getName();
- if (classPath.endsWith(".class")) {
- String className = classPath.replace("/", ".")
- .substring(0, classPath.length() - 6);
- try {
- Class clazz = classLoader
- .loadClass(className);
- //Et là, tu fais ce que tu vexu avec la classe
- } catch (ClassNotFoundException e1) {
- e1.printStackTrace();
- }
- }
- }
-} catch (IOException e1) {
- e1.printStackTrace();
-}
-*/
diff --git a/test/files/detach-run/actor/ServerConsole.scala b/test/files/detach-run/actor/ServerConsole.scala
index f68274e927..d38725ddee 100644
--- a/test/files/detach-run/actor/ServerConsole.scala
+++ b/test/files/detach-run/actor/ServerConsole.scala
@@ -1,4 +1,8 @@
-import java.io._
+/*
+ * @author Stephane Micheloud
+ */
+
+import java.io.{BufferedReader, InputStreamReader}
import scala.compat.Platform.currentTime
import scala.remoting.Debug, Debug._
@@ -15,7 +19,7 @@ trait ServerConsole extends Thread {
import java.rmi.server.RMIClassLoader
val codebase = System.getProperty("java.rmi.server.codebase")
info("[ServerConsole] codebase="+codebase)
- RMIClassLoader.getClassLoader(codebase)
+ RMIClassLoader getClassLoader codebase
}
private var isTerminated = false
@@ -44,7 +48,7 @@ trait ServerConsole extends Thread {
}
terminate()
println("Server exited ("+mkTimeString(currentTime - startTime)+")")
- exit(0)
+ system.exit(0)
}
protected def trace(msg: String) {
diff --git a/test/files/detach-run/actor/actor.scala b/test/files/detach-run/actor/actor.scala
index f3ed4c2d26..18a6dc38fd 100644
--- a/test/files/detach-run/actor/actor.scala
+++ b/test/files/detach-run/actor/actor.scala
@@ -1,3 +1,7 @@
+/*
+ * @author Stephane Micheloud
+ */
+
object Test {
val name = "actor"
diff --git a/test/files/detach-run/basic/Client.scala b/test/files/detach-run/basic/Client.scala
index d3f159fd40..f8eddb041d 100644
--- a/test/files/detach-run/basic/Client.scala
+++ b/test/files/detach-run/basic/Client.scala
@@ -1,3 +1,7 @@
+/*
+ * @author Stephane Micheloud
+ */
+
import java.net._, Thread._, ClientHelper._
import scala.remoting._, Debug._
diff --git a/test/files/detach-run/basic/Server.scala b/test/files/detach-run/basic/Server.scala
index 02150b36ff..f8aa02a4ba 100644
--- a/test/files/detach-run/basic/Server.scala
+++ b/test/files/detach-run/basic/Server.scala
@@ -1,3 +1,7 @@
+/*
+ * @author Stephane Micheloud
+ */
+
import scala.remoting.ServerChannel
object Server extends ServerConsole {
diff --git a/test/files/detach-run/basic/ServerConsole.scala b/test/files/detach-run/basic/ServerConsole.scala
index bc96bfa329..65b81c0ca1 100644
--- a/test/files/detach-run/basic/ServerConsole.scala
+++ b/test/files/detach-run/basic/ServerConsole.scala
@@ -1,3 +1,7 @@
+/*
+ * @author Stephane Micheloud
+ */
+
import java.io._
import scala.compat.Platform.currentTime
@@ -31,7 +35,6 @@ trait ServerConsole extends Thread {
}
override def run() {
- import java.io._
val in = new BufferedReader(new InputStreamReader(System.in))
var quit = false
while (!quit) {
diff --git a/test/files/detach-run/basic/basic.scala b/test/files/detach-run/basic/basic.scala
index 03e56a74a1..c785bd6c7d 100644
--- a/test/files/detach-run/basic/basic.scala
+++ b/test/files/detach-run/basic/basic.scala
@@ -1,3 +1,7 @@
+/*
+ * @author Stephane Micheloud
+ */
+
object Test {
val name = "basic"
@@ -20,7 +24,7 @@ object Test {
private var th = new Thread(this)
def start() { th.start(); Thread.sleep(1000) }
def run() { Server.main(Array(port.toString)) }
- def terminate() { Server.terminate(); System.exit(0) }
+ def terminate() { Server.terminate(); system.exit(0) }
}
private class ClientThread(host: String, port: Int) extends Runnable {