Skip to content

Commit a96424b

Browse files
committed
8356694: Removed unused subclass audits in ObjectInput/OutputStream
Reviewed-by: alanb, rriggs
1 parent 4c0a0ab commit a96424b

File tree

2 files changed

+2
-71
lines changed

2 files changed

+2
-71
lines changed

src/java.base/share/classes/java/io/ObjectInputStream.java

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1996, 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
@@ -255,14 +255,6 @@ public class ObjectInputStream
255255
private static final Object unsharedMarker = new Object();
256256

257257
private static class Caches {
258-
/** cache of subclass security audit results */
259-
static final ClassValue<Boolean> subclassAudits =
260-
new ClassValue<>() {
261-
@Override
262-
protected Boolean computeValue(Class<?> type) {
263-
return auditSubclass(type);
264-
}
265-
};
266258

267259
/**
268260
* Property to permit setting a filter after objects
@@ -1544,31 +1536,6 @@ public abstract boolean get(String name, boolean val)
15441536
public abstract Object get(String name, Object val) throws IOException, ClassNotFoundException;
15451537
}
15461538

1547-
/**
1548-
* Performs reflective checks on given subclass to verify that it doesn't
1549-
* override security-sensitive non-final methods. Returns TRUE if subclass
1550-
* is "safe", FALSE otherwise.
1551-
*/
1552-
private static Boolean auditSubclass(Class<?> subcl) {
1553-
for (Class<?> cl = subcl;
1554-
cl != ObjectInputStream.class;
1555-
cl = cl.getSuperclass())
1556-
{
1557-
try {
1558-
cl.getDeclaredMethod(
1559-
"readUnshared", (Class[]) null);
1560-
return Boolean.FALSE;
1561-
} catch (NoSuchMethodException ex) {
1562-
}
1563-
try {
1564-
cl.getDeclaredMethod("readFields", (Class[]) null);
1565-
return Boolean.FALSE;
1566-
} catch (NoSuchMethodException ex) {
1567-
}
1568-
}
1569-
return Boolean.TRUE;
1570-
}
1571-
15721539
/**
15731540
* Clears internal data structures.
15741541
*/

src/java.base/share/classes/java/io/ObjectOutputStream.java

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2024, Alibaba Group Holding Limited. All Rights Reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -174,17 +174,6 @@ public class ObjectOutputStream
174174
{
175175
private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
176176

177-
private static class Caches {
178-
/** cache of subclass security audit results */
179-
static final ClassValue<Boolean> subclassAudits =
180-
new ClassValue<>() {
181-
@Override
182-
protected Boolean computeValue(Class<?> type) {
183-
return auditSubclass(type);
184-
}
185-
};
186-
}
187-
188177
/** filter stream for handling block data conversion */
189178
private final BlockDataOutputStream bout;
190179
/** obj -> wire handle map */
@@ -1003,31 +992,6 @@ void writeTypeString(String str) throws IOException {
1003992
}
1004993
}
1005994

1006-
/**
1007-
* Performs reflective checks on given subclass to verify that it doesn't
1008-
* override security-sensitive non-final methods. Returns TRUE if subclass
1009-
* is "safe", FALSE otherwise.
1010-
*/
1011-
private static Boolean auditSubclass(Class<?> subcl) {
1012-
for (Class<?> cl = subcl;
1013-
cl != ObjectOutputStream.class;
1014-
cl = cl.getSuperclass())
1015-
{
1016-
try {
1017-
cl.getDeclaredMethod(
1018-
"writeUnshared", new Class<?>[] { Object.class });
1019-
return Boolean.FALSE;
1020-
} catch (NoSuchMethodException ex) {
1021-
}
1022-
try {
1023-
cl.getDeclaredMethod("putFields", (Class<?>[]) null);
1024-
return Boolean.FALSE;
1025-
} catch (NoSuchMethodException ex) {
1026-
}
1027-
}
1028-
return Boolean.TRUE;
1029-
}
1030-
1031995
/**
1032996
* Clears internal data structures.
1033997
*/

0 commit comments

Comments
 (0)