Logo Search packages:      
Sourcecode: visualvm version File versions  Download package

static ClassInfo org::netbeans::lib::profiler::classfile::ClassRepository::classInfoForFile ( File  f  )  throws ClassNotFoundException, IOException, ClassFormatError [inline, static]

Utility method - read .class file and return class name stored in it.

Definition at line 360 of file ClassRepository.java.

References org::netbeans::lib::profiler::classfile::BaseClassInfo::getName().

                                                                                                                  { // TODO CHECK: unused method

        byte[] buf = MiscUtils.readFileIntoBuffer(new FileOrZipEntry(f));
        ClassInfo clazz = new ClassInfo(buf) {
            protected byte[] getClassFileBytes() {
                return null;
            }
        };

        String fileName = f.getCanonicalPath();
        String className = clazz.getName() + ".class"; // NOI18N
        String expectedClassName = fileName.substring(fileName.length() - className.length()).replace('\\', '/'); // NOI18N

        if (!className.equals(expectedClassName)) {
            throw new ClassNotFoundException("Mismatch between name in .class file and location for " + fileName // NOI18N
                                             + "\nYour class path setting may be incorrect." // NOI18N
                                             ); // NOI18N
        }

        return clazz;
    }


Generated by  Doxygen 1.6.0   Back to index