1
1
/*
2
- * Copyright (c) 1998, 2017 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 1998, 2025 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
54
54
55
55
import java .rmi .*;
56
56
import java .rmi .server .*;
57
- import sun .rmi .transport .*;
58
- import sun .rmi .*;
59
57
import java .util .Map ;
60
58
import java .io .*;
61
59
import java .lang .reflect .*;
62
60
import java .rmi .registry .*;
61
+ import sun .rmi .transport .*;
63
62
64
63
public class CheckLeaseLeak extends UnicastRemoteObject implements LeaseLeak {
65
64
public CheckLeaseLeak () throws RemoteException { }
@@ -102,8 +101,6 @@ public static void main (String[] args) {
102
101
System .err .println ("Created client: " + i );
103
102
104
103
JavaVM jvm = new JavaVM ("LeaseLeakClient" ,
105
- " -Djava.security.policy=" +
106
- TestParams .defaultPolicy +
107
104
" -Drmi.registry.port=" +
108
105
registryPort ,
109
106
"" );
@@ -128,8 +125,8 @@ public static void main (String[] args) {
128
125
}
129
126
}
130
127
131
- /* numLeft should be 2 - if 11 there is a problem. */
132
- if (numLeft > 2 ) {
128
+ /* numLeft should be 4 - if 11 there is a problem. */
129
+ if (numLeft > 4 ) {
133
130
TestLibrary .bomb ("Too many objects in DGCImpl.leaseTable: " +
134
131
numLeft );
135
132
} else {
@@ -156,57 +153,51 @@ private static int getDGCLeaseTableSize () {
156
153
Field f ;
157
154
158
155
try {
159
- f = (Field ) java .security .AccessController .doPrivileged
160
- (new java .security .PrivilegedExceptionAction () {
161
- public Object run () throws Exception {
162
-
163
- ObjID dgcID = new ObjID (DGC_ID );
164
-
165
- /*
166
- * Construct an ObjectEndpoint containing DGC's
167
- * ObjID.
168
- */
169
- Class oeClass =
170
- Class .forName ("sun.rmi.transport.ObjectEndpoint" );
171
- Class [] constrParams =
172
- new Class []{ ObjID .class , Transport .class };
173
- Constructor oeConstructor =
174
- oeClass .getDeclaredConstructor (constrParams );
175
- oeConstructor .setAccessible (true );
176
- Object oe =
177
- oeConstructor .newInstance (
178
- new Object []{ dgcID , null });
179
-
180
- /*
181
- * Get Target that contains DGCImpl in ObjectTable
182
- */
183
- Class objTableClass =
184
- Class .forName ("sun.rmi.transport.ObjectTable" );
185
- Class getTargetParams [] = new Class [] { oeClass };
186
- Method objTableGetTarget =
187
- objTableClass .getDeclaredMethod ("getTarget" ,
188
- getTargetParams );
189
- objTableGetTarget .setAccessible (true );
190
- Target dgcTarget = (Target )
191
- objTableGetTarget .invoke (null , new Object []{ oe });
192
-
193
- /* get the DGCImpl from its Target */
194
- Method targetGetImpl =
195
- dgcTarget .getClass ().getDeclaredMethod
156
+ ObjID dgcID = new ObjID (DGC_ID );
157
+ /*
158
+ * Construct an ObjectEndpoint containing DGC's
159
+ * ObjID.
160
+ */
161
+ Class oeClass =
162
+ Class .forName ("sun.rmi.transport.ObjectEndpoint" );
163
+ Class [] constrParams =
164
+ new Class []{ ObjID .class , Transport .class };
165
+ Constructor oeConstructor =
166
+ oeClass .getDeclaredConstructor (constrParams );
167
+ oeConstructor .setAccessible (true );
168
+ Object oe =
169
+ oeConstructor .newInstance (
170
+ new Object []{ dgcID , null });
171
+
172
+ /*
173
+ * Get Target that contains DGCImpl in ObjectTable
174
+ */
175
+ Class objTableClass =
176
+ Class .forName ("sun.rmi.transport.ObjectTable" );
177
+ Class getTargetParams [] = new Class [] { oeClass };
178
+ Method objTableGetTarget =
179
+ objTableClass .getDeclaredMethod ("getTarget" ,
180
+ getTargetParams );
181
+ objTableGetTarget .setAccessible (true );
182
+ Target dgcTarget = (Target )
183
+ objTableGetTarget .invoke (null , new Object []{ oe });
184
+
185
+ /* get the DGCImpl from its Target */
186
+ Method targetGetImpl =
187
+ dgcTarget .getClass ().getDeclaredMethod
196
188
("getImpl" , null );
197
- targetGetImpl .setAccessible (true );
198
- dgcImpl [0 ] =
199
- (Remote ) targetGetImpl .invoke (dgcTarget , null );
189
+ targetGetImpl .setAccessible (true );
190
+ dgcImpl [0 ] =
191
+ (Remote ) targetGetImpl .invoke (dgcTarget , null );
200
192
201
- /* Get the lease table from the DGCImpl. */
202
- Field reflectedLeaseTable =
203
- dgcImpl [0 ].getClass ().getDeclaredField
193
+ /* Get the lease table from the DGCImpl. */
194
+ Field reflectedLeaseTable =
195
+ dgcImpl [0 ].getClass ().getDeclaredField
204
196
("leaseTable" );
205
- reflectedLeaseTable .setAccessible (true );
197
+ reflectedLeaseTable .setAccessible (true );
198
+
199
+ f = reflectedLeaseTable ;
206
200
207
- return reflectedLeaseTable ;
208
- }
209
- });
210
201
211
202
/**
212
203
* This is the leaseTable that will fill up with LeaseInfo
@@ -217,9 +208,6 @@ public Object run() throws Exception {
217
208
numLeaseInfosLeft = leaseTable .size ();
218
209
219
210
} catch (Exception e ) {
220
- if (e instanceof java .security .PrivilegedActionException )
221
- e = ((java .security .PrivilegedActionException ) e ).
222
- getException ();
223
211
TestLibrary .bomb (e );
224
212
}
225
213
0 commit comments