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


Java ClassFile.getName方法代码示例

本文整理汇总了Java中com.sun.tools.classfile.ClassFile.getName方法的典型用法代码示例。如果您正苦于以下问题:Java ClassFile.getName方法的具体用法?Java ClassFile.getName怎么用?Java ClassFile.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.tools.classfile.ClassFile的用法示例。


在下文中一共展示了ClassFile.getName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkMethod

import com.sun.tools.classfile.ClassFile; //导入方法依赖的package包/类
static int checkMethod(ClassFile cf, String mthd) throws Exception {
    if (cf.major_version < 52) {
        throw new RuntimeException("unexpected class file version, in "
                + cf.getName() + "expected 52, got " + cf.major_version);
    }
    int count = 0;
    for (Method m : cf.methods) {
        String mname = m.getName(cf.constant_pool);
        if (mname.equals(mthd)) {
            for (Attribute a : m.attributes) {
                if ("Code".equals(a.getName(cf.constant_pool))) {
                    count++;
                    checkMethod(cf.getName(), mname, cf.constant_pool,
                            (Code_attribute) a);
                }
            }
        }
    }
    return count;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:LambdaAsm.java

示例2: readClass

import com.sun.tools.classfile.ClassFile; //导入方法依赖的package包/类
private void readClass(ClassFile c) throws IOException,
                                           ConstantPoolException,
                                           InvalidDescriptor {
    klass = new Element("Class");
    cfile.add(klass);
    String thisk = c.getName();

    klass.setAttr("name", thisk);

    AccessFlags af = new AccessFlags(c.access_flags.flags);
    klass.setAttr("flags", flagString(af, klass));
    if (!"java/lang/Object".equals(thisk)) {
        klass.setAttr("super", c.getSuperclassName());
    }
    for (int i : c.interfaces) {
        klass.add(new Element("Interface", "name", getCpString(i)));
    }
    readFields(c, klass);
    readMethods(c, klass);
    readAttributesFor(c, c.attributes, klass);
    klass.trimToSize();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:ClassReader.java

示例3: checkDebugAttributes

import com.sun.tools.classfile.ClassFile; //导入方法依赖的package包/类
private void checkDebugAttributes(byte[] strippedClassFile) throws IOException, ConstantPoolException {
    ClassFile classFile = ClassFile.read(new ByteArrayInputStream(strippedClassFile));
    String[] debugAttributes = new String[]{
            Attribute.LineNumberTable,
            Attribute.LocalVariableTable,
            Attribute.LocalVariableTypeTable
    };
    for (Method method : classFile.methods) {
        String methodName = method.getName(classFile.constant_pool);
        Code_attribute code = (Code_attribute) method.attributes.get(Attribute.Code);
        for (String attr : debugAttributes) {
            if (code.attributes.get(attr) != null) {
                throw new AssertionError("Debug attribute was not removed: " + attr +
                        " from method " + classFile.getName() + "#" + methodName);
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:StripDebugPluginTest.java

示例4: readClass

import com.sun.tools.classfile.ClassFile; //导入方法依赖的package包/类
private void readClass(ClassFile c) throws IOException,
                                           ConstantPoolException,
                                           InvalidDescriptor {
    klass = new Element("Class");
    cfile.add(klass);
    String thisk = c.getName();

    klass.setAttr("name", thisk);

    AccessFlags af = new AccessFlags(c.access_flags.flags);
    klass.setAttr("flags", flagString(af, klass));
    if (!"java/lang/Object".equals(thisk)) {
        if (c.super_class != 0) {
            klass.setAttr("super", c.getSuperclassName());
        }
    }
    for (int i : c.interfaces) {
        klass.add(new Element("Interface", "name", getCpString(i)));
    }
    readFields(c, klass);
    readMethods(c, klass);
    readAttributesFor(c, c.attributes, klass);
    klass.trimToSize();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:ClassReader.java

示例5: scan

import com.sun.tools.classfile.ClassFile; //导入方法依赖的package包/类
protected Set<String> scan() {
    try {
        ClassFile cf = ClassFile.read(path);
        String name = cf.access_flags.is(AccessFlags.ACC_MODULE)
            ? "module-info" : cf.getName();
        return Collections.singleton(name);
    } catch (ConstantPoolException|IOException e) {
        throw new ClassFileError(e);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:ClassFileReader.java

示例6: parse

import com.sun.tools.classfile.ClassFile; //导入方法依赖的package包/类
private Optional<FutureTask<Set<Location>>> parse(Archive archive, Finder finder) {
    if (parsedArchives.get(finder).contains(archive))
        return Optional.empty();

    parsedArchives.get(finder).add(archive);

    trace("parsing %s %s%n", archive.getName(), archive.path());
    FutureTask<Set<Location>> task = new FutureTask<>(() -> {
        Set<Location> targets = new HashSet<>();
        for (ClassFile cf : archive.reader().getClassFiles()) {
            if (cf.access_flags.is(AccessFlags.ACC_MODULE))
                continue;

            String classFileName;
            try {
                classFileName = cf.getName();
            } catch (ConstantPoolException e) {
                throw new ClassFileError(e);
            }

            // filter source class/archive
            String cn = classFileName.replace('/', '.');
            if (!finder.accept(archive, cn, cf.access_flags))
                continue;

            // tests if this class matches the -include
            if (!filter.matches(cn))
                continue;

            for (Dependency d : finder.findDependencies(cf)) {
                if (filter.accepts(d)) {
                    archive.addClass(d.getOrigin(), d.getTarget());
                    targets.add(d.getTarget());
                } else {
                    // ensure that the parsed class is added the archive
                    archive.addClass(d.getOrigin());
                }
                parsedClasses.putIfAbsent(d.getOrigin(), archive);
            }
        }

        return targets;
    });
    tasks.add(task);
    pool.submit(task);
    return Optional.of(task);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:48,代码来源:DependencyFinder.java


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