author | xdono |
Wed, 02 Jul 2008 12:55:45 -0700 | |
changeset 715 | f16baef3a20e |
parent 309 | bda219d843f6 |
child 5506 | 202f599c92aa |
permissions | -rw-r--r-- |
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
1 |
/* |
715 | 2 |
* Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
|
21 |
* have any questions. |
|
22 |
*/ |
|
23 |
||
24 |
/* @test |
|
25 |
* @bug 4353388 |
|
26 |
* @summary After an instance of UnicastRemoteObject has been unexported, |
|
27 |
* if it gets marshalled, an InternalError should not be thrown; instead, |
|
28 |
* the marshalling should succeed. Also, if its "local" LiveRef gets |
|
29 |
* marshalled, by way of the stub returned by RemoteObject.toStub, for |
|
30 |
* example, then that should also succeed, instead of throwing an |
|
31 |
* IOException (see fix for bugid 4017232). |
|
32 |
* @author Peter Jones |
|
33 |
* |
|
34 |
* @build MarshalAfterUnexport |
|
35 |
* @build MarshalAfterUnexport_Stub |
|
36 |
* @run main/othervm MarshalAfterUnexport |
|
37 |
*/ |
|
38 |
||
39 |
import java.rmi.MarshalledObject; |
|
40 |
import java.rmi.Remote; |
|
41 |
import java.rmi.RemoteException; |
|
42 |
import java.rmi.server.RemoteObject; |
|
43 |
import java.rmi.server.UnicastRemoteObject; |
|
44 |
||
45 |
public class MarshalAfterUnexport |
|
46 |
extends UnicastRemoteObject |
|
47 |
implements Receiver |
|
48 |
{ |
|
49 |
public MarshalAfterUnexport() throws RemoteException { |
|
50 |
} |
|
51 |
||
52 |
public void receive(Remote obj) { |
|
53 |
} |
|
54 |
||
55 |
public static void main(String[] args) throws Exception { |
|
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
56 |
Remote impl2 = null; |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
57 |
try { |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
58 |
Remote impl = new MarshalAfterUnexport(); |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
59 |
System.err.println("created impl extending URO: " + impl); |
2 | 60 |
|
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
61 |
Receiver stub = (Receiver) RemoteObject.toStub(impl); |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
62 |
System.err.println("stub for impl: " + stub); |
2 | 63 |
|
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
64 |
UnicastRemoteObject.unexportObject(impl, true); |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
65 |
System.err.println("unexported impl"); |
2 | 66 |
|
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
67 |
impl2 = new MarshalAfterUnexport(); |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
68 |
Receiver stub2 = (Receiver) RemoteObject.toStub(impl2); |
2 | 69 |
|
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
70 |
System.err.println("marshalling unexported object:"); |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
71 |
MarshalledObject mobj = new MarshalledObject(impl); |
2 | 72 |
|
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
73 |
System.err.println("passing unexported object via RMI-JRMP:"); |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
74 |
stub2.receive(stub); |
2 | 75 |
|
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
76 |
System.err.println("TEST PASSED"); |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
77 |
} finally { |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
78 |
if (impl2 != null) { |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
79 |
try { |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
80 |
UnicastRemoteObject.unexportObject(impl2, true); |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
81 |
} catch (Throwable t) { |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
82 |
} |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
83 |
} |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
84 |
} |
2 | 85 |
} |
86 |
} |
|
87 |
||
88 |
interface Receiver extends Remote { |
|
89 |
void receive(Remote obj) throws RemoteException; |
|
90 |
} |