Example usage for java.lang VirtualMachineError getLocalizedMessage

List of usage examples for java.lang VirtualMachineError getLocalizedMessage

Introduction

In this page you can find the example usage for java.lang VirtualMachineError getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:org.opencms.setup.CmsUpdateBean.java

/**
 * Preloads classes from the same jar file as a given class.<p>
 * /*from  w ww.java 2 s.  c  om*/
 * @param cls the class for which the classes from the same jar file should be loaded 
 */
public void preload(Class<?> cls) {

    try {
        File jar = new File(cls.getProtectionDomain().getCodeSource().getLocation().getFile());
        java.util.jar.JarFile jarfile = new JarFile(jar);
        try {
            Enumeration<JarEntry> entries = jarfile.entries();
            while (entries.hasMoreElements()) {
                JarEntry entry = entries.nextElement();
                String name = entry.getName();
                if (name.endsWith(".class")) {
                    String className = name.replaceFirst("\\.class$", "");
                    className = className.replace('/', '.');
                    try {
                        Class.forName(className);
                    } catch (VirtualMachineError e) {
                        throw e;
                    } catch (Throwable e) {
                        LOG.error(e.getLocalizedMessage(), e);
                    }
                }
            }
        } finally {
            jarfile.close();
        }
    } catch (VirtualMachineError e) {
        throw e;
    } catch (Throwable e) {
        LOG.error(e.getLocalizedMessage(), e);
    }
}