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


Java VM类代码示例

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


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

示例1: setLocale

import org.apache.harmony.kernel.vm.VM; //导入依赖的package包/类
/**
 * Changes the locale of the messages.
 * 
 * @param locale
 *            Locale the locale to change to.
 */
static public ResourceBundle setLocale(final Locale locale,
        final String resource) {
    try {
        final ClassLoader loader = VM.bootCallerClassLoader();
        return (ResourceBundle) AccessController
                .doPrivileged(new PrivilegedAction<Object>() {
                    public Object run() {
                        return ResourceBundle.getBundle(resource, locale,
                                loader != null ? loader : ClassLoader.getSystemClassLoader());
                    }
                });
    } catch (MissingResourceException e) {
    }
    return null;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:22,代码来源:Messages.java

示例2: setLocale

import org.apache.harmony.kernel.vm.VM; //导入依赖的package包/类
/**
 * Changes the locale of the messages.
 *
 * @param locale
 *            Locale the locale to change to.
 */
static public ResourceBundle setLocale(final Locale locale,
        final String resource) {
    try {
        final ClassLoader loader = VM.bootCallerClassLoader();
        return (ResourceBundle) AccessController
                .doPrivileged(new PrivilegedAction<Object>() {
                    public Object run() {
                        return ResourceBundle.getBundle(resource, locale,
                                loader != null ? loader : ClassLoader
                                        .getSystemClassLoader());
                    }
                });
    } catch (MissingResourceException e) {
        // ignore
    }
    return null;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:24,代码来源:Messages.java

示例3: setLocale

import org.apache.harmony.kernel.vm.VM; //导入依赖的package包/类
/**
 * Changes the locale of the messages.
 * 
 * @param locale
 *            Locale the locale to change to.
 */
static public ResourceBundle setLocale(final Locale locale,
        final String resource) {
    try {
        final ClassLoader loader = VM.bootCallerClassLoader();
        return (ResourceBundle) AccessController
                .doPrivileged(new PrivilegedAction<Object>() {
                    public Object run() {
                        return ResourceBundle.getBundle(resource, locale,
                                loader != null ? loader : ClassLoader
                                        .getSystemClassLoader());
                    }
                });
    } catch (MissingResourceException e) {
    }
    return null;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:23,代码来源:Messages.java

示例4: Level

import org.apache.harmony.kernel.vm.VM; //导入依赖的package包/类
/**
 * Constructs an instance of {@code Level} taking the supplied name, level
 * value and resource bundle name.
 * 
 * @param name
 *            the name of the level.
 * @param level
 *            an integer value indicating the level.
 * @param resourceBundleName
 *            the name of the resource bundle to use.
 * @throws NullPointerException
 *             if {@code name} is {@code null}.
 */
protected Level(String name, int level, String resourceBundleName) {
    if (name == null) {
        // logging.1C=The 'name' parameter is null.
        throw new NullPointerException(Messages.getString("logging.1C")); //$NON-NLS-1$
    }
    this.name = name;
    this.value = level;
    this.resourceBundleName = resourceBundleName;
    if (resourceBundleName != null) {
        try {
            rb = ResourceBundle.getBundle(resourceBundleName, Locale
                    .getDefault(), VM.callerClassLoader());
        } catch (MissingResourceException e) {
            rb = null;
        }
    }
    synchronized (levels) {
        levels.add(this);
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:34,代码来源:Level.java

示例5: setLocale

import org.apache.harmony.kernel.vm.VM; //导入依赖的package包/类
/**
 * Changes the locale of the messages.
 * 
 * @param locale
 *            Locale the locale to change to.
 */
static public ResourceBundle setLocale(final Locale locale,
        final String resource) {
    try {
        final ClassLoader loader = VM.bootCallerClassLoader();
        return (ResourceBundle) AccessController
                .doPrivileged(new PrivilegedAction<Object>() {
                    public Object run() {
                        return ResourceBundle.getBundle(resource, locale,
                                loader != null ? loader : ClassLoader.getSystemClassLoader());
                    }
                });
    } catch (MissingResourceException e) {
        return null;
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:22,代码来源:Messages.java

示例6: getUnsafe

import org.apache.harmony.kernel.vm.VM; //导入依赖的package包/类
/**
 * <p>
 * Retrieves an instance of this service.
 * </p>
 * 
 * @return An instance of Unsafe.
 */
public static Unsafe getUnsafe() {
    /* Check that the caller of this method is in system code (i.e. on the
     * bootclasspath).  Unsafe methods are not designed to be called directly
     * by applications.  We assume that system code will not reveal the instance.
     */
    if (VM.callerClassLoader() != null) {
        throw new SecurityException("Unsafe");
    }

    return AccessController.doPrivileged(new PrivilegedAction<Unsafe>() {
        public Unsafe run() {
            return INSTANCE;
        }
    });
}
 
开发者ID:shannah,项目名称:cn1,代码行数:23,代码来源:Unsafe.java

示例7: deregisterDriver

import org.apache.harmony.kernel.vm.VM; //导入依赖的package包/类
/**
 * Removes a driver from the {@code DriverManager}'s registered driver list.
 * This will only succeed when the caller's class loader loaded the driver
 * that is to be removed. If the driver was loaded by a different class
 * loader, the removal of the driver fails silently.
 * <p>
 * If the removal succeeds, the {@code DriverManager} will not use this
 * driver in the future when asked to get a {@code Connection}.
 *
 * @param driver
 *            the JDBC driver to remove.
 * @throws SQLException
 *             if there is a problem interfering with accessing the
 *             database.
 */
public static void deregisterDriver(Driver driver) throws SQLException {
    if (driver == null) {
        return;
    }
    ClassLoader callerClassLoader = VM.callerClassLoader();

    if (!DriverManager.isClassFromClassLoader(driver, callerClassLoader)) {
        // sql.1=DriverManager: calling class not authorized to deregister
        // JDBC driver
        throw new SecurityException(Messages.getString("sql.1")); //$NON-NLS-1$
    } // end if
    synchronized (theDrivers) {
        theDrivers.remove(driver);
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:31,代码来源:DriverManager.java

示例8: getDriver

import org.apache.harmony.kernel.vm.VM; //导入依赖的package包/类
/**
 * Tries to find a driver that can interpret the supplied URL.
 * 
 * @param url
 *            the URL of a database.
 * @return a {@code Driver} that matches the provided URL. {@code null} if
 *         no {@code Driver} understands the URL
 * @throws SQLException
 *             if there is any kind of problem accessing the database.
 */
public static Driver getDriver(String url) throws SQLException {
    ClassLoader callerClassLoader = VM.callerClassLoader();

    synchronized (theDrivers) {
        /*
         * Loop over the drivers in the DriverSet checking to see if one
         * does understand the supplied URL - return the first driver which
         * does understand the URL
         */
        Iterator<Driver> theIterator = theDrivers.iterator();
        while (theIterator.hasNext()) {
            Driver theDriver = theIterator.next();
            if (theDriver.acceptsURL(url)
                    && DriverManager.isClassFromClassLoader(theDriver,
                            callerClassLoader)) {
                return theDriver;
            }
        }
    }
    // If no drivers understand the URL, throw an SQLException
    // sql.6=No suitable driver
    // SQLState: 08 - connection exception
    // 001 - SQL-client unable to establish SQL-connection
    throw new SQLException(Messages.getString("sql.6"), "08001"); //$NON-NLS-1$ //$NON-NLS-2$
}
 
开发者ID:shannah,项目名称:cn1,代码行数:36,代码来源:DriverManager.java

示例9: getDrivers

import org.apache.harmony.kernel.vm.VM; //导入依赖的package包/类
/**
 * Returns an {@code Enumeration} that contains all of the loaded JDBC
 * drivers that the current caller can access.
 * 
 * @return An {@code Enumeration} containing all the currently loaded JDBC
 *         {@code Drivers}.
 */
public static Enumeration<Driver> getDrivers() {
    ClassLoader callerClassLoader = VM.callerClassLoader();
    /*
     * Synchronize to avoid clashes with additions and removals of drivers
     * in the DriverSet
     */
    synchronized (theDrivers) {
        /*
         * Create the Enumeration by building a Vector from the elements of
         * the DriverSet
         */
        Vector<Driver> theVector = new Vector<Driver>();
        Iterator<Driver> theIterator = theDrivers.iterator();
        while (theIterator.hasNext()) {
            Driver theDriver = theIterator.next();
            if (DriverManager.isClassFromClassLoader(theDriver,
                    callerClassLoader)) {
                theVector.add(theDriver);
            }
        }
        return theVector.elements();
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:31,代码来源:DriverManager.java

示例10: 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


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