11/*
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.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
5454
5555import java .rmi .*;
5656import java .rmi .server .*;
57- import sun .rmi .transport .*;
58- import sun .rmi .*;
5957import java .util .Map ;
6058import java .io .*;
6159import java .lang .reflect .*;
6260import java .rmi .registry .*;
61+ import sun .rmi .transport .*;
6362
6463public class CheckLeaseLeak extends UnicastRemoteObject implements LeaseLeak {
6564 public CheckLeaseLeak () throws RemoteException { }
@@ -102,8 +101,6 @@ public static void main (String[] args) {
102101 System .err .println ("Created client: " + i );
103102
104103 JavaVM jvm = new JavaVM ("LeaseLeakClient" ,
105- " -Djava.security.policy=" +
106- TestParams .defaultPolicy +
107104 " -Drmi.registry.port=" +
108105 registryPort ,
109106 "" );
@@ -128,8 +125,8 @@ public static void main (String[] args) {
128125 }
129126 }
130127
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 ) {
133130 TestLibrary .bomb ("Too many objects in DGCImpl.leaseTable: " +
134131 numLeft );
135132 } else {
@@ -156,57 +153,51 @@ private static int getDGCLeaseTableSize () {
156153 Field f ;
157154
158155 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
196188 ("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 );
200192
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
204196 ("leaseTable" );
205- reflectedLeaseTable .setAccessible (true );
197+ reflectedLeaseTable .setAccessible (true );
198+
199+ f = reflectedLeaseTable ;
206200
207- return reflectedLeaseTable ;
208- }
209- });
210201
211202 /**
212203 * This is the leaseTable that will fill up with LeaseInfo
@@ -217,9 +208,6 @@ public Object run() throws Exception {
217208 numLeaseInfosLeft = leaseTable .size ();
218209
219210 } catch (Exception e ) {
220- if (e instanceof java .security .PrivilegedActionException )
221- e = ((java .security .PrivilegedActionException ) e ).
222- getException ();
223211 TestLibrary .bomb (e );
224212 }
225213
0 commit comments