Example usage for java.lang NoClassDefFoundError getClass

List of usage examples for java.lang NoClassDefFoundError getClass

Introduction

In this page you can find the example usage for java.lang NoClassDefFoundError getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.curl.orb.generator.ClassPathLoader.java

private void searchPath(File dir, int rootPathLength) throws GeneratorException {
    File[] files = dir.listFiles();
    for (File file : files) {
        if (file.isDirectory()) {
            searchPath(file, rootPathLength);
        } else if (file.isFile()) {
            String filename = null;
            try {
                filename = file.getCanonicalPath();
                if (filename.endsWith(".jar")) {
                    if (!(filename.endsWith("curl-orb-server.jar") || filename.endsWith("curl-serializer.jar")))
                        classProperties.addAll(JarFileLoader.loadJarFileProperty(filename));
                } else if (filename.endsWith(".class")) {
                    // Windows and UNIX
                    String className = filename.substring(rootPathLength + 1, filename.length() - 6)
                            .replace('\\', '.').replace('/', '.');
                    ClassProperty classProperty = new ClassProperty(className);
                    if (classProperty.isPublic())
                        classProperties.add(classProperty); // if not public, it will be skipped.
                }//from ww  w  . ja va 2 s .c  o  m
            } catch (IOException e) {
                throw new GeneratorException(e);
            }
            /* skiped Exception */
            catch (NoClassDefFoundError skip) {
                log.warn(
                        filename + " was skiped due to " + skip.getClass().getName() + " " + skip.getMessage());
            } catch (UnsatisfiedLinkError skip) {
                log.warn(
                        filename + " was skiped due to " + skip.getClass().getName() + " " + skip.getMessage());
            }
            // TODO: all exceptions should be skipped?
            catch (Throwable skip) {
                log.error(
                        filename + " was skiped due to " + skip.getClass().getName() + " " + skip.getMessage());
            }
        }
    }
}