author | alanb |
Thu, 01 Dec 2016 08:57:53 +0000 | |
changeset 42338 | a60f280f803c |
parent 41768 | b9d599d18150 |
permissions | -rw-r--r-- |
41608
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
1 |
/* |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
4 |
* |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
10 |
* |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
15 |
* accompanied this code). |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
16 |
* |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
20 |
* |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
23 |
* questions. |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
24 |
*/ |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
25 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
26 |
import java.io.Serializable; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
27 |
import java.lang.reflect.InvocationTargetException; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
28 |
import java.lang.reflect.Method; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
29 |
import java.math.BigDecimal; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
30 |
import java.math.BigInteger; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
31 |
import java.net.InetAddress; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
32 |
import java.net.UnknownHostException; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
33 |
import java.rmi.Remote; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
34 |
import java.rmi.RemoteException; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
35 |
import java.time.LocalTime; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
36 |
import java.util.ArrayList; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
37 |
import java.util.Arrays; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
38 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
39 |
import java.util.EnumSet; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
40 |
import java.util.HashSet; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
41 |
import java.util.HashMap; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
42 |
import java.util.Objects; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
43 |
import java.util.PropertyPermission; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
44 |
import java.util.Set; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
45 |
import java.util.concurrent.atomic.LongAdder; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
46 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
47 |
import javax.rmi.CORBA.Util; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
48 |
import javax.rmi.PortableRemoteObject; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
49 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
50 |
import org.omg.CORBA_2_3.ORB; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
51 |
import org.omg.CORBA_2_3.portable.OutputStream; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
52 |
import org.omg.CORBA_2_3.portable.InputStream; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
53 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
54 |
import org.testng.Assert; |
41768
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
55 |
import org.testng.annotations.AfterClass; |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
56 |
import org.testng.annotations.BeforeClass; |
41608
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
57 |
import org.testng.annotations.Test; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
58 |
import org.testng.annotations.DataProvider; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
59 |
import org.testng.TestNG; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
60 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
61 |
/* |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
62 |
* @test |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
63 |
* @library /test/lib |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
64 |
* @build jdk.test.lib.* |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41768
diff
changeset
|
65 |
* @compile ObjectStreamTest.java ObjectStreamTest$_Echo_Stub.java |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41768
diff
changeset
|
66 |
* ObjectStreamTest$_Server_Tie.java |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41768
diff
changeset
|
67 |
* @modules java.base/java.io:open |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41768
diff
changeset
|
68 |
* java.corba/com.sun.corba.se.impl.io:+open |
41768
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
69 |
* java.corba/com.sun.corba.se.impl.activation |
41608
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
70 |
* @summary Tests of ReflectionFactory use in IIOP Serialization |
41768
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
71 |
* @run testng/othervm ObjectStreamTest |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
72 |
* @run testng/othervm/policy=security.policy ObjectStreamTest |
41608
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
73 |
*/ |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
74 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
75 |
@Test |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
76 |
public class ObjectStreamTest { |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
77 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
78 |
enum Colors {RED, GREEN, YELLOW} |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
79 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
80 |
static Set<Colors> colorSet = new HashSet<>(); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
81 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
82 |
static { |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
83 |
colorSet.add(Colors.RED); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
84 |
colorSet.add(Colors.GREEN); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
85 |
} |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
86 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
87 |
@DataProvider(name = "Objects") |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
88 |
static Object[][] patterns() { |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
89 |
BigInteger bigInteger = new BigInteger("8943892002309239"); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
90 |
InetAddress inetAddr; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
91 |
try { |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
92 |
inetAddr = java.net.InetAddress.getByAddress(new byte[]{127, 0, 0, 1}); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
93 |
} catch (UnknownHostException ignored) { |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
94 |
inetAddr = null; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
95 |
// ignored |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
96 |
} |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
97 |
HashMap<String, Object> hashMap = new HashMap<>(); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
98 |
hashMap.put("BigInteger", bigInteger); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
99 |
hashMap.put("InetAddress", inetAddr); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
100 |
hashMap.put("String", "bString"); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
101 |
Object[][] patterns = new Object[][]{ |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
102 |
{"aString"}, |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
103 |
{Integer.valueOf(5)}, |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
104 |
{new SimpleObject(4, 4.0f)}, |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
105 |
{Arrays.asList("a", "b", "c")}, |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
106 |
{new String[]{"x", "y", "z"}}, |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
107 |
{new ArrayList<Object>(1)}, // uses readObject/writeObject |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
108 |
{new StringBuffer("abc")}, // Has serialPersistentFields |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
109 |
{new StringBuilder("abc")}, |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
110 |
{Colors.RED}, |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
111 |
{inetAddr}, |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
112 |
{LocalTime.MIDNIGHT}, // uses writeReplace/readResolve |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
113 |
{new LongAdder()}, // uses writeReplace/readResolve |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
114 |
{EnumSet.allOf(Colors.class)}, // used writeReplace/readResolve |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
115 |
{bigInteger}, |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
116 |
{new BigDecimal(bigInteger)}, |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
117 |
{hashMap}, |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
118 |
{new PropertyPermission("abc", "read")}, // has serialPersistentFields |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
119 |
}; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
120 |
return patterns; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
121 |
} |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
122 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
123 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
124 |
/** |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
125 |
* Check ObjectStreamClass facts match between core serialization and CORBA. |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
126 |
* |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
127 |
* @param value |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
128 |
*/ |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
129 |
@Test(dataProvider = "Objects") |
41768
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
130 |
void factCheck(Serializable value) { |
41608
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
131 |
Class<?> clazz = value.getClass(); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
132 |
java.io.ObjectStreamClass sOSC = java.io.ObjectStreamClass.lookup(clazz); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
133 |
java.io.ObjectStreamField[] sFields = sOSC.getFields(); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
134 |
com.sun.corba.se.impl.io.ObjectStreamClass cOSC = corbaLookup(clazz); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
135 |
com.sun.corba.se.impl.io.ObjectStreamField[] cFields = cOSC.getFields(); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
136 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
137 |
Assert.assertEquals(sFields.length, cFields.length, "Different number of fields"); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
138 |
for (int i = 0; i < sFields.length; i++) { |
41768
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
139 |
Assert.assertEquals(sFields[i].getName(), cFields[i].getName(), |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
140 |
"different field names " + cFields[i].getName()); |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
141 |
Assert.assertEquals(sFields[i].getType(), cFields[i].getType(), |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
142 |
"different field types " + cFields[i].getName()); |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
143 |
Assert.assertEquals(sFields[i].getTypeString(), cFields[i].getTypeString(), |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
144 |
"different field typestrings " + cFields[i].getName()); |
41608
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
145 |
} |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
146 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
147 |
Assert.assertEquals(baseMethod("hasReadObjectMethod", sOSC, (Class<?>[]) null), |
41768
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
148 |
corbaMethod("hasReadObject", cOSC, (Class<?>[]) null), |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
149 |
"hasReadObject: " + value.getClass()); |
41608
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
150 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
151 |
Assert.assertEquals(baseMethod("hasWriteObjectMethod", sOSC, (Class<?>[]) null), |
41768
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
152 |
corbaMethod("hasWriteObject", cOSC, (Class<?>[]) null), |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
153 |
"hasWriteObject: " + value.getClass()); |
41608
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
154 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
155 |
Assert.assertEquals(baseMethod("hasWriteReplaceMethod", sOSC, (Class<?>[]) null), |
41768
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
156 |
corbaMethod("hasWriteReplaceMethod", cOSC, (Class<?>[]) null), |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
157 |
"hasWriteReplace: " + value.getClass()); |
41608
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
158 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
159 |
Assert.assertEquals(baseMethod("hasReadResolveMethod", sOSC, (Class<?>[]) null), |
41768
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
160 |
corbaMethod("hasReadResolveMethod", cOSC, (Class<?>[]) null), |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
161 |
"hasReadResolve: " + value.getClass()); |
41608
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
162 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
163 |
Assert.assertEquals(baseMethod("getSerialVersionUID", sOSC, (Class<?>[]) null), |
41768
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
164 |
corbaMethod("getSerialVersionUID", cOSC, (Class<?>[]) null), |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
165 |
"getSerialVersionUID: " + value.getClass()); |
41608
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
166 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
167 |
} |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
168 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
169 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
170 |
/** |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
171 |
* Test that objects written using Util.writeAny can be serialized |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
172 |
* and deserialized using Util.readAny to equivalent objects. |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
173 |
*/ |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
174 |
@Test(dataProvider = "Objects", enabled = true, dependsOnMethods = {"factCheck"}) |
41768
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
175 |
void WriteValueObjectStreamTest01(Serializable value) throws Exception { |
41608
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
176 |
ORB orb = (ORB) ORB.init(new String[0], null); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
177 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
178 |
OutputStream out = (OutputStream) orb.create_output_stream(); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
179 |
Util.writeAny(out, value); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
180 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
181 |
InputStream in = (InputStream) out.create_input_stream(); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
182 |
Object actual = Util.readAny(in); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
183 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
184 |
checkEquals(actual, value); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
185 |
} |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
186 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
187 |
/** |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
188 |
* Test that objects can be echoed to a server and come back equivalent. |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
189 |
*/ |
41768
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
190 |
@Test(dataProvider = "Objects", enabled = true, dependsOnMethods = {"factCheck"}) |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
191 |
void echoObjects(Serializable value) throws Exception { |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
192 |
Echo echo = getEchoStub(); |
41608
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
193 |
Object actual = echo.echo(value); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
194 |
checkEquals(actual, value); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
195 |
} |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
196 |
|
41768
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
197 |
|
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
198 |
/** |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
199 |
* Initialize the ORB and the singleton Echo server stub. |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
200 |
* @return the stub for the Echo server. |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
201 |
* @throws RemoteException if an error occurs |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
202 |
*/ |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
203 |
synchronized Echo getEchoStub() throws RemoteException { |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
204 |
if (echoStub == null) { |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
205 |
ORB orb = (ORB) ORB.init(new String[0], null); |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
206 |
Echo server = new Server(); |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
207 |
echoStub = (javax.rmi.CORBA.Stub) PortableRemoteObject.toStub(server); |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
208 |
echoStub.connect(orb); |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
209 |
} |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
210 |
return (Echo)echoStub; |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
211 |
} |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
212 |
|
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
213 |
/** |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
214 |
* The stub for the Echo Server class. Initialized on first use. |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
215 |
*/ |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
216 |
private javax.rmi.CORBA.Stub echoStub; |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
217 |
|
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
218 |
/** |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
219 |
* After all the tests run shutdown the orb. |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
220 |
*/ |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
221 |
@AfterClass |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
222 |
void shutdownOrb() { |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
223 |
ORB orb = (ORB) ORB.init(new String[0], null); |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
224 |
orb.shutdown(true); |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
225 |
} |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
226 |
|
41608
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
227 |
/** |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
228 |
* Check if the value and result are equals, with some tests depending on the type. |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
229 |
* @param expected the expected value |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
230 |
* @param actual the actual value |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
231 |
*/ |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
232 |
static void checkEquals(Object actual, Object expected) { |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
233 |
Class<?> cl = expected.getClass(); |
41768
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
234 |
Assert.assertEquals(actual.getClass(), cl, |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
235 |
"type of value not equal to class of result"); |
41608
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
236 |
try { |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
237 |
if (cl.isArray() || !(cl.getDeclaredMethod("equals", cl) == null)) { |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
238 |
Assert.assertEquals(actual, expected, "echo'd object not equal"); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
239 |
} else { |
41768
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
240 |
Assert.assertEquals(toString(actual), toString(expected), |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
241 |
"toString values not equal"); |
41608
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
242 |
} |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
243 |
} catch (NoSuchMethodException ex) { |
41768
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
244 |
Assert.assertEquals(toString(actual), toString(expected), |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
245 |
"toString values not equal"); |
41608
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
246 |
} |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
247 |
} |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
248 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
249 |
/** |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
250 |
* Convert an object to a String, and correctly for arrays. |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
251 |
* @param obj an object |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
252 |
* @return the tostring for the object. |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
253 |
*/ |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
254 |
static String toString(Object obj) { |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
255 |
return obj.getClass().isArray() |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
256 |
? Arrays.toString((Object[]) obj) |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
257 |
: Objects.toString(obj); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
258 |
} |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
259 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
260 |
/** |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
261 |
* SimpleObject to test round trip. |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
262 |
*/ |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
263 |
static class SimpleObject implements Serializable { |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
264 |
private static final long serialVersionUID = 5217577841494640354L; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
265 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
266 |
private int i = 0; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
267 |
private float f = 0.0f; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
268 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
269 |
SimpleObject(int i, float f) { |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
270 |
this.i = i; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
271 |
this.f = f; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
272 |
} |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
273 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
274 |
@Override |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
275 |
public boolean equals(Object o) { |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
276 |
if (this == o) return true; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
277 |
if (o == null || getClass() != o.getClass()) return false; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
278 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
279 |
SimpleObject that = (SimpleObject) o; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
280 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
281 |
if (i != that.i) return false; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
282 |
return Float.compare(that.f, f) == 0; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
283 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
284 |
} |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
285 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
286 |
@Override |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
287 |
public int hashCode() { |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
288 |
int result = i; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
289 |
result = 31 * result + (f != +0.0f ? Float.floatToIntBits(f) : 0); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
290 |
return result; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
291 |
} |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
292 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
293 |
@Override |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
294 |
public String toString() { |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
295 |
return "SimpleObject{" + |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
296 |
"i=" + i + |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
297 |
", f=" + f + |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
298 |
'}'; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
299 |
} |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
300 |
} |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
301 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
302 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
303 |
/** |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
304 |
* Lookup the CORBA ObjectStreamClass instance for a class. |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
305 |
* @param clazz the class |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
306 |
* @return the CORBA ObjectStreamClass instance for the class |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
307 |
*/ |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
308 |
static com.sun.corba.se.impl.io.ObjectStreamClass corbaLookup(Class<?> clazz) { |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
309 |
Class<?> oscClass = com.sun.corba.se.impl.io.ObjectStreamClass.class; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
310 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
311 |
try { |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
312 |
Method meth = oscClass.getDeclaredMethod("lookup", Class.class); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
313 |
meth.setAccessible(true); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
314 |
return (com.sun.corba.se.impl.io.ObjectStreamClass) meth.invoke(null, clazz); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
315 |
} catch (NoSuchMethodException noMeth) { |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
316 |
throw new RuntimeException("missing method", noMeth); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
317 |
} catch (IllegalAccessException | InvocationTargetException rex) { |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
318 |
throw new RuntimeException("invocation failed", rex); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
319 |
} |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
320 |
} |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
321 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
322 |
/** |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
323 |
* Lookup aand invoke method on a serializable object via the CORBA ObjectStreamClass. |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
324 |
* @param methodName method name |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
325 |
* @param osc CORBA ObjectStreamClass |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
326 |
* @param argClasses method arguments |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
327 |
* @return the value returned from invoking the method |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
328 |
*/ |
41768
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
329 |
static Object corbaMethod(String methodName, |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
330 |
com.sun.corba.se.impl.io.ObjectStreamClass osc, |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
331 |
Class<?>... argClasses) { |
41608
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
332 |
Class<?> oscClass = com.sun.corba.se.impl.io.ObjectStreamClass.class; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
333 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
334 |
try { |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
335 |
Method meth = oscClass.getDeclaredMethod(methodName, argClasses); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
336 |
meth.setAccessible(true); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
337 |
return meth.invoke(osc); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
338 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
339 |
} catch (NoSuchMethodException noMeth) { |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
340 |
throw new RuntimeException("missing method" + osc.getName() |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
341 |
+ "::" + methodName, noMeth); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
342 |
} catch (IllegalAccessException | InvocationTargetException rex) { |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
343 |
throw new RuntimeException("invocation failed", rex); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
344 |
} |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
345 |
} |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
346 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
347 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
348 |
/** |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
349 |
* Lookup aand invoke method on a serializable object via java.io.ObjectStreamClass. |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
350 |
* @param methodName method name |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
351 |
* @param osc java.io.ObjectStreamClass |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
352 |
* @param argClasses method arguments |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
353 |
* @return the value returned from invoking the method |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
354 |
*/ |
41768
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
355 |
static Object baseMethod(String methodName, java.io.ObjectStreamClass osc, |
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
356 |
Class<?>... argClasses) { |
41608
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
357 |
Class<?> oscClass = java.io.ObjectStreamClass.class; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
358 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
359 |
try { |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
360 |
Method meth = oscClass.getDeclaredMethod(methodName, argClasses); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
361 |
meth.setAccessible(true); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
362 |
return meth.invoke(osc); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
363 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
364 |
} catch (NoSuchMethodException noMeth) { |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
365 |
throw new RuntimeException("missing method: " + osc.getName() |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
366 |
+ "::" + methodName, noMeth); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
367 |
} catch (IllegalAccessException | InvocationTargetException rex) { |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
368 |
throw new RuntimeException("invocation failed", rex); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
369 |
} |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
370 |
} |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
371 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
372 |
/** |
41768
b9d599d18150
8168613: CORBA ObjectStreamTest fails with address in use
rriggs
parents:
41609
diff
changeset
|
373 |
* Simple echo interface to check IIOP serialization/deserialization. |
41608
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
374 |
*/ |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
375 |
interface Echo extends Remote { |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
376 |
Object echo(Object obj) throws RemoteException; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
377 |
} |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
378 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
379 |
static class Server extends PortableRemoteObject implements Echo { |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
380 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
381 |
public Server() throws RemoteException { |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
382 |
super(); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
383 |
} |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
384 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
385 |
public Object echo(Object obj) { |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
386 |
return obj; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
387 |
} |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
388 |
} |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
389 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
390 |
// Main can be used to run the tests from the command line with only testng.jar. |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
391 |
@SuppressWarnings("raw_types") |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
392 |
@Test(enabled = false) |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
393 |
public static void main(String[] args) { |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
394 |
Class<?>[] testclass = {ObjectStreamTest.class}; |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
395 |
TestNG testng = new TestNG(); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
396 |
testng.setTestClasses(testclass); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
397 |
testng.run(); |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
398 |
} |
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
399 |
|
bb724835848f
8164908: ReflectionFactory support for IIOP and custom serialization
rriggs
parents:
diff
changeset
|
400 |
} |