annotate c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/InvocationSocket.java @ 2289:6190d20bd6d6

merge
author Lukas Stadler <lukas.stadler@jku.at>
date Mon, 11 Apr 2011 11:25:06 +0200
parents 8c426c2891c8
children 160aacf936ad
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1423
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
1 /*
1437
9e5e83ca2259 Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1423
diff changeset
2 * Copyright (c) 2010 Sun Microsystems, Inc. All rights reserved.
1423
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
3 *
1437
9e5e83ca2259 Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1423
diff changeset
4 * Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product
9e5e83ca2259 Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1423
diff changeset
5 * that is described in this document. In particular, and without limitation, these intellectual property
9e5e83ca2259 Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1423
diff changeset
6 * rights may include one or more of the U.S. patents listed at http://www.sun.com/patents and one or
9e5e83ca2259 Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1423
diff changeset
7 * more additional patents or pending patent applications in the U.S. and in other countries.
1423
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
8 *
1437
9e5e83ca2259 Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1423
diff changeset
9 * U.S. Government Rights - Commercial software. Government users are subject to the Sun
9e5e83ca2259 Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1423
diff changeset
10 * Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its
9e5e83ca2259 Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1423
diff changeset
11 * supplements.
1423
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
12 *
1437
9e5e83ca2259 Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1423
diff changeset
13 * Use is subject to license terms. Sun, Sun Microsystems, the Sun logo, Java and Solaris are trademarks or
9e5e83ca2259 Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1423
diff changeset
14 * registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. All SPARC trademarks
9e5e83ca2259 Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1423
diff changeset
15 * are used under license and are trademarks or registered trademarks of SPARC International, Inc. in the
9e5e83ca2259 Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1423
diff changeset
16 * U.S. and other countries.
1423
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
17 *
1437
9e5e83ca2259 Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1423
diff changeset
18 * UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open
9e5e83ca2259 Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1423
diff changeset
19 * Company, Ltd.
1423
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
20 */
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
21 package com.sun.hotspot.c1x;
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
22
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
23 import java.io.*;
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
24 import java.lang.reflect.*;
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
25
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
26 import com.sun.hotspot.c1x.logging.*;
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
27
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
28 /**
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
29 * A java.lang.reflect proxy that communicates over a socket connection.
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
30 *
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
31 * Calling a method sends the method name and the parameters through the socket. Afterwards this class waits for a result.
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
32 * While waiting for a result three types of objects can arrive through the socket: a method invocation, a method result or an exception.
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
33 * Method invocation can thus be recursive.
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
34 *
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
35 * @author Lukas Stadler
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
36 */
2288
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
37 public class InvocationSocket {
1423
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
38
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
39 private final ObjectOutputStream output;
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
40 private final ObjectInputStream input;
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
41
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
42 public InvocationSocket(ObjectOutputStream output, ObjectInputStream input) {
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
43 this.output = output;
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
44 this.input = input;
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
45 }
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
46
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
47 private static class Invocation implements Serializable {
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
48
2288
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
49 public Object receiver;
1423
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
50 public String methodName;
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
51 public Object[] args;
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
52
2288
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
53 public Invocation(Object receiver, String methodName, Object[] args) {
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
54 this.receiver = receiver;
1423
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
55 this.methodName = methodName;
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
56 this.args = args;
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
57 }
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
58 }
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
59
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
60 private static class Result implements Serializable {
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
61
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
62 public Object result;
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
63
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
64 public Result(Object result) {
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
65 this.result = result;
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
66 }
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
67 }
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
68
2288
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
69 public class Handler implements InvocationHandler {
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
70 private Object receiver;
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
71
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
72 public Handler(Object receiver) {
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
73 this.receiver = receiver;
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
74 }
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
75
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
76 @Override
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
77 public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
78 if (!method.getDeclaringClass().isInterface()) {
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
79 return method.invoke(receiver, args);
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
80 }
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
81 try {
2289
Lukas Stadler <lukas.stadler@jku.at>
parents: 2288
diff changeset
82 Logger.startScope("invoking remote " + method.getName());
2288
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
83 output.writeObject(new Invocation(receiver, method.getName(), args));
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
84 output.flush();
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
85 return waitForResult();
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
86 } catch (Throwable t) {
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
87 t.printStackTrace();
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
88 throw t;
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
89 } finally {
2289
Lukas Stadler <lukas.stadler@jku.at>
parents: 2288
diff changeset
90 Logger.endScope("");
2288
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
91 }
1423
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
92 }
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
93 }
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
94
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
95 public Object waitForResult() throws IOException, ClassNotFoundException {
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
96 while (true) {
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
97 Object in = input.readObject();
1437
9e5e83ca2259 Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1423
diff changeset
98 if (in instanceof Result) {
1423
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
99 return ((Result) in).result;
1437
9e5e83ca2259 Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1423
diff changeset
100 } else if (in instanceof RuntimeException) {
1423
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
101 throw (RuntimeException) in;
1437
9e5e83ca2259 Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1423
diff changeset
102 } else if (in instanceof Throwable) {
1423
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
103 throw new RuntimeException((Throwable) in);
1437
9e5e83ca2259 Enabled -C1X:OPTIONS when running HotSpot/C1X. Enabled checkstyle for the HotSpotVM Java project.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1423
diff changeset
104 }
1423
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
105
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
106 Invocation invoke = (Invocation) in;
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
107 Method method = null;
2288
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
108 for (Class<?> clazz = invoke.receiver.getClass(); clazz != null; clazz = clazz.getSuperclass()) {
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
109 for (Method m : clazz.getDeclaredMethods()) {
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
110 if (invoke.methodName.equals(m.getName())) {
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
111 method = m;
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
112 break;
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
113 }
1423
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
114 }
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
115 }
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
116 if (method == null) {
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
117 Exception e = new UnsupportedOperationException("unknown method " + invoke.methodName);
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
118 e.printStackTrace();
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
119 output.writeObject(e);
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
120 output.flush();
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
121 } else {
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
122 Object result;
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
123 try {
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
124 if (invoke.args == null) {
2289
Lukas Stadler <lukas.stadler@jku.at>
parents: 2288
diff changeset
125 Logger.startScope("invoking local " + invoke.methodName);
2288
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
126 result = method.invoke(invoke.receiver);
1423
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
127 } else {
2289
Lukas Stadler <lukas.stadler@jku.at>
parents: 2288
diff changeset
128 if (Logger.ENABLED) {
Lukas Stadler <lukas.stadler@jku.at>
parents: 2288
diff changeset
129 StringBuilder str = new StringBuilder();
Lukas Stadler <lukas.stadler@jku.at>
parents: 2288
diff changeset
130 str.append("invoking local " + invoke.methodName + "(");
Lukas Stadler <lukas.stadler@jku.at>
parents: 2288
diff changeset
131 for (int i = 0; i < invoke.args.length; i++) {
Lukas Stadler <lukas.stadler@jku.at>
parents: 2288
diff changeset
132 str.append(i == 0 ? "" : ", ");
Lukas Stadler <lukas.stadler@jku.at>
parents: 2288
diff changeset
133 str.append(Logger.pretty(invoke.args[i]));
Lukas Stadler <lukas.stadler@jku.at>
parents: 2288
diff changeset
134 }
Lukas Stadler <lukas.stadler@jku.at>
parents: 2288
diff changeset
135 str.append(")");
Lukas Stadler <lukas.stadler@jku.at>
parents: 2288
diff changeset
136 Logger.startScope(str.toString());
2288
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
137 }
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
138 result = method.invoke(invoke.receiver, invoke.args);
1423
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
139 }
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
140 result = new Result(result);
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
141 } catch (IllegalArgumentException e) {
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
142 System.out.println("error while invoking " + invoke.methodName);
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
143 e.getCause().printStackTrace();
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
144 result = e.getCause();
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
145 } catch (InvocationTargetException e) {
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
146 System.out.println("error while invoking " + invoke.methodName);
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
147 e.getCause().printStackTrace();
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
148 result = e.getCause();
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
149 } catch (IllegalAccessException e) {
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
150 System.out.println("error while invoking " + invoke.methodName);
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
151 e.getCause().printStackTrace();
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
152 result = e.getCause();
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
153 } finally {
2289
Lukas Stadler <lukas.stadler@jku.at>
parents: 2288
diff changeset
154 Logger.endScope("");
1423
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
155 }
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
156 output.writeObject(result);
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
157 output.flush();
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
158 }
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
159 }
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
160 }
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
161
2288
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
162 public void sendResult(Object obj) throws IOException {
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
163 output.writeObject(new Result(obj));
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
164 output.flush();
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
165 }
8c426c2891c8 client/server: new interface Remote marks classes that should not be serialized, but called remotely
Lukas Stadler <lukas.stadler@jku.at>
parents: 2284
diff changeset
166
1423
760213a60e8b * rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
167 }