author | stefank |
Mon, 25 Aug 2014 09:10:13 +0200 | |
changeset 26314 | f8bc1966fb30 |
parent 23010 | 6dadb192ad81 |
child 30820 | 0d4717a011d3 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
23010
6dadb192ad81
8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents:
14778
diff
changeset
|
2 |
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. 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 |
* |
|
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
2 | 22 |
*/ |
23 |
||
24 |
/* @test |
|
25 |
* @bug 4117427 |
|
26 |
* @summary When marshalling an object that implements java.rmi.Remote, |
|
27 |
* but is not a RemoteStub and its corresponding stub class is not known |
|
28 |
* by the RMI runtime, RMI's MarshalOutputStream should assume that the |
|
29 |
* object is a proxy of some sort (like an RMI/IIOP stub) and simply |
|
30 |
* allow the object to be serialized. |
|
31 |
* @author Ann Wollrath |
|
32 |
* |
|
33 |
* @library ../../../../../java/rmi/testlibrary |
|
14778 | 34 |
* @build TestLibrary Receiver MarshalForeignStub_Stub |
2 | 35 |
* @run main/othervm/policy=security.policy MarshalForeignStub |
36 |
*/ |
|
37 |
||
38 |
import java.io.Serializable; |
|
39 |
import java.rmi.*; |
|
40 |
import java.rmi.server.*; |
|
41 |
||
42 |
public class MarshalForeignStub |
|
43 |
extends UnicastRemoteObject |
|
44 |
implements Receiver |
|
45 |
{ |
|
46 |
||
47 |
public static class ForeignStub implements Remote, Serializable { |
|
48 |
} |
|
49 |
||
50 |
public MarshalForeignStub() throws RemoteException { |
|
51 |
} |
|
52 |
||
53 |
public void receive(Object obj) { |
|
54 |
System.err.println("+ receive(): received object " + obj); |
|
55 |
} |
|
56 |
||
57 |
public static void main(String[] args) { |
|
58 |
||
59 |
System.err.println("\nRegression test for bug 4117427\n"); |
|
60 |
||
61 |
TestLibrary.suggestSecurityManager(null); |
|
62 |
||
63 |
System.err.println("Creating remote object."); |
|
64 |
MarshalForeignStub obj = null; |
|
65 |
try { |
|
66 |
obj = new MarshalForeignStub(); |
|
67 |
} catch (RemoteException e) { |
|
68 |
TestLibrary.bomb(e); |
|
69 |
} |
|
70 |
||
71 |
try { |
|
72 |
Receiver stub = (Receiver) RemoteObject.toStub(obj); |
|
73 |
||
74 |
/* |
|
75 |
* Pass an instance of ForeignStub to the remote object. |
|
76 |
* This should succeed, because MarshalOutputStream now |
|
77 |
* allows objects that implement Remote, but not RemoteStub |
|
78 |
* to be serialized in an RMI call. |
|
79 |
*/ |
|
80 |
System.err.println( |
|
81 |
"Passing a foreign stub to remote object."); |
|
82 |
stub.receive(new ForeignStub()); |
|
83 |
||
84 |
System.err.println("TEST SUCCEEDED"); |
|
85 |
} catch (Exception e) { |
|
86 |
System.err.println("TEST FAILED: "); |
|
87 |
e.printStackTrace(); |
|
88 |
throw new RuntimeException("TEST FAILED: " + e.toString()); |
|
89 |
} finally { |
|
90 |
try { |
|
91 |
UnicastRemoteObject.unexportObject(obj, true); |
|
92 |
} catch (Throwable e) { |
|
93 |
} |
|
94 |
} |
|
95 |
} |
|
96 |
} |