diff c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/server/CompilationServer.java @ 2288:8c426c2891c8

client/server: new interface Remote marks classes that should not be serialized, but called remotely
author Lukas Stadler <lukas.stadler@jku.at>
date Mon, 11 Apr 2011 10:37:24 +0200
parents 762de4b26788
children 34354e2e40a3
line wrap: on
line diff
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/server/CompilationServer.java	Fri Apr 08 13:47:56 2011 +0200
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/server/CompilationServer.java	Mon Apr 11 10:37:24 2011 +0200
@@ -21,18 +21,13 @@
 package com.sun.hotspot.c1x.server;
 
 import java.io.*;
-import java.lang.reflect.Proxy;
 import java.net.*;
-import java.rmi.registry.*;
 
 import javax.net.*;
 
 import com.sun.hotspot.c1x.*;
 import com.sun.hotspot.c1x.Compiler;
-import com.sun.hotspot.c1x.InvocationSocket.DelegateCallback;
 import com.sun.hotspot.c1x.logging.*;
-import com.sun.hotspot.c1x.server.ReplacingStreams.ReplacingInputStream;
-import com.sun.hotspot.c1x.server.ReplacingStreams.ReplacingOutputStream;
 
 /**
  * Server side of the client/server compilation model.
@@ -41,9 +36,6 @@
  */
 public class CompilationServer {
 
-    private ReplacingOutputStream output;
-    private ReplacingInputStream input;
-
     public static void main(String[] args) throws Exception {
         new CompilationServer().run();
     }
@@ -52,28 +44,19 @@
         ServerSocket serverSocket = ServerSocketFactory.getDefault().createServerSocket(1199);
         do {
             Socket socket = null;
-            ReplacingStreams streams = new ReplacingStreams();
             try {
                 Logger.log("Compilation server ready, waiting for client to connect...");
                 socket = serverSocket.accept();
                 Logger.log("Connected to " + socket.getRemoteSocketAddress());
 
-                output = streams.new ReplacingOutputStream(new BufferedOutputStream(socket.getOutputStream()));
-                // required, because creating an ObjectOutputStream writes a header, but doesn't flush the stream
-                output.flush();
-                input = streams.new ReplacingInputStream(new BufferedInputStream(socket.getInputStream()));
+                ReplacingStreams streams = new ReplacingStreams(socket.getOutputStream(), socket.getInputStream());
 
-                final InvocationSocket invocation = new InvocationSocket(output, input);
-                invocation.setDelegateCallback(new DelegateCallback() {
-                    public Object getDelegate() {
-                        VMEntries entries = (VMEntries) Proxy.newProxyInstance(VMEntries.class.getClassLoader(), new Class<?>[] { VMEntries.class}, invocation);
-                        Compiler compiler = CompilerImpl.initializeServer(entries);
-                        input.setCompiler(compiler);
-                        return compiler.getVMExits();
-                    }
-                });
+                VMEntries entries = (VMEntries) streams.getInvocation().waitForResult();
+                Compiler compiler = CompilerImpl.initializeServer(entries);
 
-                invocation.waitForResult();
+                streams.getInvocation().sendResult(compiler);
+
+                streams.getInvocation().waitForResult();
             } catch (IOException e) {
                 e.printStackTrace();
                 if (socket != null) {