mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8190733: Use Class::getPackageName in java.base implementation
Reviewed-by: mchung, rriggs
This commit is contained in:
parent
73f177ea06
commit
5d7c797278
5 changed files with 10 additions and 36 deletions
|
@ -675,12 +675,11 @@ public abstract class ClassLoader {
|
|||
return;
|
||||
}
|
||||
|
||||
final String name = cls.getName();
|
||||
final int i = name.lastIndexOf('.');
|
||||
if (i != -1) {
|
||||
final String packageName = cls.getPackageName();
|
||||
if (!packageName.isEmpty()) {
|
||||
AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
public Void run() {
|
||||
sm.checkPackageAccess(name.substring(0, i));
|
||||
sm.checkPackageAccess(packageName);
|
||||
return null;
|
||||
}
|
||||
}, new AccessControlContext(new ProtectionDomain[] {pd}));
|
||||
|
|
|
@ -1034,11 +1034,8 @@ public class Proxy implements java.io.Serializable {
|
|||
|
||||
// do permission check if the caller is in a different runtime package
|
||||
// of the proxy class
|
||||
int n = proxyClass.getName().lastIndexOf('.');
|
||||
String pkg = (n == -1) ? "" : proxyClass.getName().substring(0, n);
|
||||
|
||||
n = caller.getName().lastIndexOf('.');
|
||||
String callerPkg = (n == -1) ? "" : caller.getName().substring(0, n);
|
||||
String pkg = proxyClass.getPackageName();
|
||||
String callerPkg = caller.getPackageName();
|
||||
|
||||
if (pcl != ccl || !pkg.equals(callerPkg)) {
|
||||
sm.checkPermission(new ReflectPermission("newProxyInPackage." + pkg));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue