Skip to content

Commit d2ac052

Browse files
author
duke
committed
Backport 5a442197d21e1dfb89cdbf5f0ad5596869ab333a
1 parent 4addb57 commit d2ac052

File tree

3 files changed

+46
-61
lines changed

3 files changed

+46
-61
lines changed

test/jdk/ProblemList.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,8 +619,6 @@ java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency.java 7140992 generi
619619

620620
java/rmi/transport/rapidExportUnexport/RapidExportUnexport.java 7146541 linux-all
621621

622-
java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java 7191877 generic-all
623-
624622
java/rmi/registry/readTest/CodebaseTest.java 8173324 windows-all
625623
java/rmi/registry/multipleRegistries/MultipleRegistries.java 8268182 macosx-all
626624

test/jdk/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java

Lines changed: 45 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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
@@ -54,12 +54,11 @@
5454

5555
import java.rmi.*;
5656
import java.rmi.server.*;
57-
import sun.rmi.transport.*;
58-
import sun.rmi.*;
5957
import java.util.Map;
6058
import java.io.*;
6159
import java.lang.reflect.*;
6260
import java.rmi.registry.*;
61+
import sun.rmi.transport.*;
6362

6463
public 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

test/jdk/java/rmi/transport/checkLeaseInfoLeak/LeaseLeakClient.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2012, 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
@@ -27,7 +27,6 @@
2727

2828
public class LeaseLeakClient {
2929
public static void main(String args[]) {
30-
TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
3130

3231
try {
3332
LeaseLeak leaseLeak = null;

0 commit comments

Comments
 (0)