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


Java VM.getNonBootstrapClassLoader方法代码示例

本文整理汇总了Java中org.apache.harmony.kernel.vm.VM.getNonBootstrapClassLoader方法的典型用法代码示例。如果您正苦于以下问题:Java VM.getNonBootstrapClassLoader方法的具体用法?Java VM.getNonBootstrapClassLoader怎么用?Java VM.getNonBootstrapClassLoader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.harmony.kernel.vm.VM的用法示例。


在下文中一共展示了VM.getNonBootstrapClassLoader方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolveProxyClass

import org.apache.harmony.kernel.vm.VM; //导入方法依赖的package包/类
/**
 * Creates the proxy class that implements the interfaces specified in
 * {@code interfaceNames}.
 * 
 * @param interfaceNames
 *            the interfaces used to create the proxy class.
 * @return the proxy class.
 * @throws ClassNotFoundException
 *             if the proxy class or any of the specified interfaces cannot
 *             be created.
 * @throws IOException
 *             if an error occurs while reading from the source stream.
 * @see ObjectOutputStream#annotateProxyClass(Class)
 */
protected Class<?> resolveProxyClass(String[] interfaceNames)
        throws IOException, ClassNotFoundException {
        
    // TODO: This method is opportunity for performance enhancement
    //       We can cache the classloader and recently used interfaces.        
    ClassLoader loader = VM.getNonBootstrapClassLoader();
    Class<?>[] interfaces = new Class<?>[interfaceNames.length];
    for (int i = 0; i < interfaceNames.length; i++) {
        interfaces[i] = Class.forName(interfaceNames[i], false, loader);
    }
    try {
        return Proxy.getProxyClass(loader, interfaces);
    } catch (IllegalArgumentException e) {
        throw new ClassNotFoundException(e.toString(), e);
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:31,代码来源:ObjectInputStream.java

示例2: resolveProxyClass

import org.apache.harmony.kernel.vm.VM; //导入方法依赖的package包/类
/**
 * Retrieves the proxy class corresponding to the interface names.
 * 
 * @param interfaceNames
 *            The interfaces used to create the proxy class
 * @return A proxy class
 * 
 * @throws IOException
 *             If any IO problem occurred when trying to load the class.
 * @throws ClassNotFoundException
 *             If the proxy class cannot be created
 */
protected Class<?> resolveProxyClass(String[] interfaceNames)
        throws IOException, ClassNotFoundException {
    ClassLoader loader = VM.getNonBootstrapClassLoader();
    Class<?>[] interfaces = new Class<?>[interfaceNames.length];
    for (int i = 0; i < interfaceNames.length; i++) {
        interfaces[i] = Class.forName(interfaceNames[i], false, loader);
    }
    try {
        return Proxy.getProxyClass(loader, interfaces);
    } catch (IllegalArgumentException e) {
        throw new ClassNotFoundException(e.toString(), e);
    }
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:26,代码来源:ObjectInputStream.java

示例3: readObject

import org.apache.harmony.kernel.vm.VM; //导入方法依赖的package包/类
private Object readObject(boolean unshared) throws OptionalDataException,
        ClassNotFoundException, IOException {
    boolean restoreInput = (primitiveData == input);
    if (restoreInput) {
        primitiveData = emptyStream;
    }

    // This is the spec'ed behavior in JDK 1.2. Very bizarre way to allow
    // behavior overriding.
    if (subclassOverridingImplementation && !unshared) {
        return readObjectOverride();
    }

    // If we still had primitive types to read, should we discard them
    // (reset the primitiveTypes stream) or leave as is, so that attempts to
    // read primitive types won't read 'past data' ???
    Object result;
    try {
        // We need this so we can tell when we are returning to the
        // original/outside caller
        if (++nestedLevels == 1) {
            // Remember the caller's class loader
            callerClassLoader = VM.getNonBootstrapClassLoader();
        }

        result = readNonPrimitiveContent(unshared);
        if (restoreInput) {
            primitiveData = input;
        }
    } finally {
        // We need this so we can tell when we are returning to the
        // original/outside caller
        if (--nestedLevels == 0) {
            // We are going to return to the original caller, perform
            // cleanups.
            // No more need to remember the caller's class loader
            callerClassLoader = null;
        }
    }

    // Done reading this object. Is it time to return to the original
    // caller? If so we need to perform validations first.
    if (nestedLevels == 0 && validations != null) {
        // We are going to return to the original caller. If validation is
        // enabled we need to run them now and then cleanup the validation
        // collection
        try {
            for (InputValidationDesc element : validations) {
                element.validator.validateObject();
            }
        } finally {
            // Validations have to be renewed, since they are only called
            // from readObject
            validations = null;
        }
    }
    return result;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:59,代码来源:ObjectInputStream.java


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