8345565: Remove remaining SecurityManager motivated APIs from sun.reflect.util

Reviewed-by: mullan, rriggs, liach
This commit is contained in:
Alan Bateman 2024-12-05 15:22:00 +00:00
parent 97b8a09bda
commit 691e692149
10 changed files with 7 additions and 258 deletions

View file

@ -42,7 +42,6 @@ import jdk.internal.access.SharedSecrets;
import jdk.internal.event.DeserializationEvent;
import jdk.internal.misc.Unsafe;
import jdk.internal.util.ByteArray;
import sun.reflect.misc.ReflectUtil;
/**
* An ObjectInputStream deserializes primitive data and objects previously
@ -1828,12 +1827,6 @@ public class ObjectInputStream
};
}
private boolean isCustomSubclass() {
// Return true if this class is a custom subclass of ObjectInputStream
return getClass().getClassLoader()
!= ObjectInputStream.class.getClassLoader();
}
/**
* Reads in and returns class descriptor for a dynamic proxy class. Sets
* passHandle to proxy class descriptor's assigned handle. If proxy class
@ -1879,12 +1872,6 @@ public class ObjectInputStream
} else if (!Proxy.isProxyClass(cl)) {
throw new InvalidClassException("Not a proxy");
} else {
// ReflectUtil.checkProxyPackageAccess makes a test
// equivalent to isCustomSubclass so there's no need
// to condition this call to isCustomSubclass == true here.
ReflectUtil.checkProxyPackageAccess(
getClass().getClassLoader(),
cl.getInterfaces());
// Filter the interfaces
for (Class<?> clazz : cl.getInterfaces()) {
filterCheck(clazz, -1);
@ -1954,12 +1941,9 @@ public class ObjectInputStream
Class<?> cl = null;
ClassNotFoundException resolveEx = null;
bin.setBlockDataMode(true);
final boolean checksRequired = isCustomSubclass();
try {
if ((cl = resolveClass(readDesc)) == null) {
resolveEx = new ClassNotFoundException("null class");
} else if (checksRequired) {
ReflectUtil.checkPackageAccess(cl);
}
} catch (ClassNotFoundException ex) {
resolveEx = ex;

View file

@ -35,7 +35,6 @@ import java.util.StringJoiner;
import jdk.internal.util.ByteArray;
import jdk.internal.access.JavaLangAccess;
import jdk.internal.access.SharedSecrets;
import sun.reflect.misc.ReflectUtil;
import static jdk.internal.util.ModifiedUtf.putChar;
import static jdk.internal.util.ModifiedUtf.utfLen;
@ -1170,12 +1169,6 @@ public class ObjectOutputStream
}
}
private boolean isCustomSubclass() {
// Return true if this class is a custom subclass of ObjectOutputStream
return getClass().getClassLoader()
!= ObjectOutputStream.class.getClassLoader();
}
/**
* Writes class descriptor representing a dynamic proxy class to stream.
*/
@ -1193,9 +1186,6 @@ public class ObjectOutputStream
}
bout.setBlockDataMode(true);
if (isCustomSubclass()) {
ReflectUtil.checkPackageAccess(cl);
}
annotateProxyClass(cl);
bout.setBlockDataMode(false);
bout.writeByte(TC_ENDBLOCKDATA);
@ -1222,9 +1212,6 @@ public class ObjectOutputStream
Class<?> cl = desc.forClass();
bout.setBlockDataMode(true);
if (cl != null && isCustomSubclass()) {
ReflectUtil.checkPackageAccess(cl);
}
annotateClass(cl);
bout.setBlockDataMode(false);
bout.writeByte(TC_ENDBLOCKDATA);