Package com.sun.tools.classfile

Examples of com.sun.tools.classfile.SourceFile_attribute


    /** Check the SourceFileAttribute is the simple name of the original source file. */
    void verifySourceFileAttribute(File f) {
        System.err.println("verify: " + f);
        try {
            ClassFile cf = ClassFile.read(f);
            SourceFile_attribute sfa = (SourceFile_attribute) cf.getAttribute(Attribute.SourceFile);
            String found = sfa.getSourceFile(cf.constant_pool);
            String expect = f.getName().replaceAll("([$.].*)?\\.class", ".java");
            if (!expect.equals(found)) {
                error("bad value found: " + found + ", expected: " + expect);
            }
        } catch (Exception e) {
View Full Code Here


        // class and the base of the source file. This avoids having to read
        // additional classes to determine the outmost class from any
        // InnerClasses and EnclosingMethod attributes.
        try {
            String className = cf.getName();
            SourceFile_attribute sf =
                    (SourceFile_attribute) cf.attributes.get(Attribute.SourceFile);
            if (sf == null) {
                report(messages.getMessage("err.no.SourceFile.attribute"));
                return null;
            }
            String sourceFile = sf.getSourceFile(cf.constant_pool);
            String fileBase = sourceFile.endsWith(".java")
                ? sourceFile.substring(0, sourceFile.length() - 5) : sourceFile;
            int sep = className.lastIndexOf("/");
            String pkgName = (sep == -1 ? "" : className.substring(0, sep+1));
            String topClassName = (pkgName + fileBase).replace('/', '.');
View Full Code Here

TOP

Related Classes of com.sun.tools.classfile.SourceFile_attribute

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.