本文整理汇总了Java中sun.misc.SharedSecrets类的典型用法代码示例。如果您正苦于以下问题:Java SharedSecrets类的具体用法?Java SharedSecrets怎么用?Java SharedSecrets使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SharedSecrets类属于sun.misc包,在下文中一共展示了SharedSecrets类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runFinalization
import sun.misc.SharedSecrets; //导入依赖的package包/类
static void runFinalization() {
if (!VM.isBooted()) {
return;
}
forkSecondaryFinalizer(new Runnable() {
private volatile boolean running;
public void run() {
if (running)
return;
final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
running = true;
for (;;) {
Finalizer f = (Finalizer)queue.poll();
if (f == null) break;
f.runFinalizer(jla);
}
}
});
}
示例2: runAllFinalizers
import sun.misc.SharedSecrets; //导入依赖的package包/类
static void runAllFinalizers() {
if (!VM.isBooted()) {
return;
}
forkSecondaryFinalizer(new Runnable() {
private volatile boolean running;
public void run() {
if (running)
return;
final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
running = true;
for (;;) {
Finalizer f;
synchronized (lock) {
f = unfinalized;
if (f == null) break;
unfinalized = f.next;
}
f.runFinalizer(jla);
}}});
}
示例3: PolicyInfo
import sun.misc.SharedSecrets; //导入依赖的package包/类
PolicyInfo(int numCaches) {
policyEntries = new ArrayList<>();
identityPolicyEntries =
Collections.synchronizedList(new ArrayList<PolicyEntry>(2));
aliasMapping = Collections.synchronizedMap(new HashMap<>(11));
pdMapping = new ProtectionDomainCache[numCaches];
JavaSecurityProtectionDomainAccess jspda
= SharedSecrets.getJavaSecurityProtectionDomainAccess();
for (int i = 0; i < numCaches; i++) {
pdMapping[i] = jspda.getProtectionDomainCache();
}
if (numCaches > 1) {
random = new java.util.Random();
}
}
示例4: main
import sun.misc.SharedSecrets; //导入依赖的package包/类
public static void main(String[]args) throws Exception {
final DomainCombiner dc = new DomainCombiner() {
@Override
public ProtectionDomain[] combine(ProtectionDomain[] currentDomains, ProtectionDomain[] assignedDomains) {
return currentDomains; // basically a no-op
}
};
// Get an instance of the saved ACC
AccessControlContext saved = AccessController.getContext();
// Simulate the stack ACC with a DomainCombiner attached
AccessControlContext stack = new AccessControlContext(AccessController.getContext(), dc);
// Now try to run JavaSecurityAccess.doIntersectionPrivilege() and assert
// whether the DomainCombiner from the stack ACC is preserved
boolean ret = SharedSecrets.getJavaSecurityAccess().doIntersectionPrivilege(new PrivilegedAction<Boolean>() {
@Override
public Boolean run() {
return dc == AccessController.getContext().getDomainCombiner();
}
}, stack, saved);
if (!ret) {
System.exit(1);
}
}
示例5: readObject
import sun.misc.SharedSecrets; //导入依赖的package包/类
/**
* Reconstitutes the {@code PriorityQueue} instance from a stream
* (that is, deserializes it).
*
* @param s the stream
*/
private void readObject(java.io.ObjectInputStream s)
throws java.io.IOException, ClassNotFoundException {
// Read in size, and any hidden stuff
s.defaultReadObject();
// Read in (and discard) array length
s.readInt();
SharedSecrets.getJavaOISAccess().checkArray(s, Object[].class, size);
queue = new Object[size];
// Read in all elements.
for (int i = 0; i < size; i++)
queue[i] = s.readObject();
// Elements are guaranteed to be in "proper order", but the
// spec has never explained what that might be.
heapify();
}
示例6: readObject
import sun.misc.SharedSecrets; //导入依赖的package包/类
/**
* Reconstitutes the <tt>IdentityHashMap</tt> instance from a stream (i.e.,
* deserializes it).
*/
private void readObject(java.io.ObjectInputStream s)
throws java.io.IOException, ClassNotFoundException {
// Read in any hidden stuff
s.defaultReadObject();
// Read in size (number of Mappings)
int size = s.readInt();
if (size < 0)
throw new java.io.StreamCorruptedException
("Illegal mappings count: " + size);
int cap = capacity(size);
SharedSecrets.getJavaOISAccess().checkArray(s, Object[].class, cap);
init(cap);
// Read the keys and values, and put the mappings in the table
for (int i=0; i<size; i++) {
@SuppressWarnings("unchecked")
K key = (K) s.readObject();
@SuppressWarnings("unchecked")
V value = (V) s.readObject();
putForCreate(key, value);
}
}
示例7: readObject
import sun.misc.SharedSecrets; //导入依赖的package包/类
/**
* Reconstitutes this list from a stream (that is, deserializes it).
* @param s the stream
* @throws ClassNotFoundException if the class of a serialized object
* could not be found
* @throws java.io.IOException if an I/O error occurs
*/
private void readObject(java.io.ObjectInputStream s)
throws java.io.IOException, ClassNotFoundException {
s.defaultReadObject();
// bind to new lock
resetLock();
// Read in array length and allocate array
int len = s.readInt();
SharedSecrets.getJavaOISAccess().checkArray(s, Object[].class, len);
Object[] elements = new Object[len];
// Read in all elements in the proper order.
for (int i = 0; i < len; i++)
elements[i] = s.readObject();
setArray(elements);
}
示例8: readObject
import sun.misc.SharedSecrets; //导入依赖的package包/类
/**
* Reconstitute the <tt>ArrayList</tt> instance from a stream (that is,
* deserialize it).
*/
private void readObject(java.io.ObjectInputStream s)
throws java.io.IOException, ClassNotFoundException {
elementData = EMPTY_ELEMENTDATA;
// Read in size, and any hidden stuff
s.defaultReadObject();
// Read in capacity
s.readInt(); // ignored
if (size > 0) {
// be like clone(), allocate array based upon size not capacity
int capacity = calculateCapacity(elementData, size);
SharedSecrets.getJavaOISAccess().checkArray(s, Object[].class, capacity);
ensureCapacityInternal(size);
Object[] a = elementData;
// Read in all elements in the proper order.
for (int i=0; i<size; i++) {
a[i] = s.readObject();
}
}
}
示例9: readObject
import sun.misc.SharedSecrets; //导入依赖的package包/类
/**
* Reconstitutes this deque from a stream (that is, deserializes it).
*/
private void readObject(java.io.ObjectInputStream s)
throws java.io.IOException, ClassNotFoundException {
s.defaultReadObject();
// Read in size and allocate array
int size = s.readInt();
int capacity = calculateSize(size);
SharedSecrets.getJavaOISAccess().checkArray(s, Object[].class, capacity);
allocateElements(size);
head = 0;
tail = size;
// Read in all elements in the proper order.
for (int i = 0; i < size; i++)
elements[i] = s.readObject();
}
示例10: getDefaultInAppContext
import sun.misc.SharedSecrets; //导入依赖的package包/类
/**
* Returns the default TimeZone in an AppContext if any AppContext
* has ever used. null is returned if any AppContext hasn't been
* used or if the AppContext doesn't have the default TimeZone.
* null is also returned if allowSetDefault is false.
*
* Note that javaAWTAccess may be null if sun.awt.AppContext class hasn't
* been loaded. If so, it implies that AWTSecurityManager is not our
* SecurityManager and we can use a local static variable.
* This works around a build time issue.
*/
private static TimeZone getDefaultInAppContext() {
if (allowSetDefault) {
// JavaAWTAccess provides access implementation-private methods without using reflection.
JavaAWTAccess javaAWTAccess = SharedSecrets.getJavaAWTAccess();
if (System.getSecurityManager() == null || javaAWTAccess == null) {
return mainAppContextDefault;
} else if (javaAWTAccess.isDisposed()) {
return null;
} else {
TimeZone tz = (TimeZone) javaAWTAccess.get(TimeZone.class);
if (tz == null && javaAWTAccess.isMainAppContext()) {
return mainAppContextDefault;
} else {
return tz;
}
}
}
return null;
}
示例11: bitsToSet
import sun.misc.SharedSecrets; //导入依赖的package包/类
static <T extends Enum<T> & IntSupplier> Set<T> bitsToSet(int bits, Class<T> tClass) {
EnumSet<T> ret = EnumSet.noneOf(tClass);
// Internal/Unsafe
T[] enums;
if (useSharedSecrets) {
enums = SharedSecrets.getJavaLangAccess().getEnumConstantsShared(tClass);
} else {
enums = tClass.getEnumConstants();
}
tClass.getEnumConstants();
for (T t : enums) {
if ((bits & t.getAsInt()) != 0) {
ret.add(t);
}
}
return ret;
}
示例12: PolicyInfo
import sun.misc.SharedSecrets; //导入依赖的package包/类
PolicyInfo(int numCaches) {
policyEntries = new ArrayList<PolicyEntry>();
identityPolicyEntries =
Collections.synchronizedList(new ArrayList<PolicyEntry>(2));
aliasMapping = Collections.synchronizedMap(new HashMap(11));
pdMapping = new ProtectionDomainCache[numCaches];
JavaSecurityProtectionDomainAccess jspda
= SharedSecrets.getJavaSecurityProtectionDomainAccess();
for (int i = 0; i < numCaches; i++) {
pdMapping[i] = jspda.getProtectionDomainCache();
}
if (numCaches > 1) {
random = new java.util.Random();
}
}