mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 06:14:49 +02:00
8349145: Make Class.getProtectionDomain() non-native
Reviewed-by: liach, dholmes, yzheng
This commit is contained in:
parent
e700460b49
commit
ed17c55ea3
13 changed files with 31 additions and 50 deletions
|
@ -236,12 +236,13 @@ public final class Class<T> implements java.io.Serializable,
|
|||
* This constructor is not used and prevents the default constructor being
|
||||
* generated.
|
||||
*/
|
||||
private Class(ClassLoader loader, Class<?> arrayComponentType, int mods) {
|
||||
private Class(ClassLoader loader, Class<?> arrayComponentType, int mods, ProtectionDomain pd) {
|
||||
// Initialize final field for classLoader. The initialization value of non-null
|
||||
// prevents future JIT optimizations from assuming this final field is null.
|
||||
classLoader = loader;
|
||||
componentType = arrayComponentType;
|
||||
modifiers = mods;
|
||||
protectionDomain = pd;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2697,17 +2698,7 @@ public final class Class<T> implements java.io.Serializable,
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@code ProtectionDomain} of this class.
|
||||
*
|
||||
* @return the ProtectionDomain of this class
|
||||
*
|
||||
* @see java.security.ProtectionDomain
|
||||
* @since 1.2
|
||||
*/
|
||||
public ProtectionDomain getProtectionDomain() {
|
||||
return protectionDomain();
|
||||
}
|
||||
private transient final ProtectionDomain protectionDomain;
|
||||
|
||||
/** Holder for the protection domain returned when the internal domain is null */
|
||||
private static class Holder {
|
||||
|
@ -2719,21 +2710,22 @@ public final class Class<T> implements java.io.Serializable,
|
|||
}
|
||||
}
|
||||
|
||||
// package-private
|
||||
ProtectionDomain protectionDomain() {
|
||||
ProtectionDomain pd = getProtectionDomain0();
|
||||
if (pd == null) {
|
||||
/**
|
||||
* Returns the {@code ProtectionDomain} of this class.
|
||||
*
|
||||
* @return the ProtectionDomain of this class
|
||||
*
|
||||
* @see java.security.ProtectionDomain
|
||||
* @since 1.2
|
||||
*/
|
||||
public ProtectionDomain getProtectionDomain() {
|
||||
if (protectionDomain == null) {
|
||||
return Holder.allPermDomain;
|
||||
} else {
|
||||
return pd;
|
||||
return protectionDomain;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ProtectionDomain of this class.
|
||||
*/
|
||||
private native ProtectionDomain getProtectionDomain0();
|
||||
|
||||
/*
|
||||
* Returns the Class object for the named primitive type. Type parameter T
|
||||
* avoids redundant casts for trusted code.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1994, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -2148,7 +2148,7 @@ public final class System {
|
|||
}
|
||||
|
||||
public ProtectionDomain protectionDomain(Class<?> c) {
|
||||
return c.protectionDomain();
|
||||
return c.getProtectionDomain();
|
||||
}
|
||||
|
||||
public MethodHandle stringConcatHelper(String name, MethodType methodType) {
|
||||
|
|
|
@ -56,7 +56,7 @@ public class Reflection {
|
|||
fieldFilterMap = Map.of(
|
||||
Reflection.class, ALL_MEMBERS,
|
||||
AccessibleObject.class, ALL_MEMBERS,
|
||||
Class.class, Set.of("classLoader", "classData", "modifiers"),
|
||||
Class.class, Set.of("classLoader", "classData", "modifiers", "protectionDomain"),
|
||||
ClassLoader.class, ALL_MEMBERS,
|
||||
Constructor.class, ALL_MEMBERS,
|
||||
Field.class, ALL_MEMBERS,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue