当前位置: 首页>>代码示例>>Java>>正文


Java SharedSecrets类代码示例

本文整理汇总了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);
            }
        }
    });
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:Finalizer.java

示例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);
            }}});
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:Finalizer.java

示例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();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:PolicyFile.java

示例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);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:PreserveCombinerTest.java

示例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();
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:26,代码来源:PriorityQueue.java

示例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);
    }
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:28,代码来源:IdentityHashMap.java

示例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);
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:26,代码来源:CopyOnWriteArrayList.java

示例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();
        }
    }
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:28,代码来源:ArrayList.java

示例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();
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:20,代码来源:ArrayDeque.java

示例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;
}
 
开发者ID:ZhaoX,项目名称:jdk-1.7-annotated,代码行数:31,代码来源:TimeZone.java

示例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;
}
 
开发者ID:vincentzhang96,项目名称:DDS4J,代码行数:18,代码来源:InternalUtils.java

示例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();
    }
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:17,代码来源:PolicyFile.java


注:本文中的sun.misc.SharedSecrets类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。