• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Descriptor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.sun.tools.classfile.Descriptor的典型用法代码示例。如果您正苦于以下问题:Java Descriptor类的具体用法?Java Descriptor怎么用?Java Descriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Descriptor类属于com.sun.tools.classfile包,在下文中一共展示了Descriptor类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: check

import com.sun.tools.classfile.Descriptor; //导入依赖的package包/类
void check(String dir, String... fileNames)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    for (String fileName : fileNames) {
        ClassFile classFileToCheck = ClassFile.read(new File(dir, fileName));

        for (Method method : classFileToCheck.methods) {
            if ((method.access_flags.flags & ACC_STRICT) == 0) {
                errors.add(String.format(offendingMethodErrorMessage,
                        method.getName(classFileToCheck.constant_pool),
                        classFileToCheck.getName()));
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:CheckACC_STRICTFlagOnclinitTest.java


示例2: getValue

import com.sun.tools.classfile.Descriptor; //导入依赖的package包/类
String getValue(Descriptor d) {
    try {
        return d.getValue(constant_pool);
    } catch (ConstantPoolException e) {
        return report(e);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:ClassWriter.java


示例3: setStackMap

import com.sun.tools.classfile.Descriptor; //导入依赖的package包/类
void setStackMap(StackMapTable_attribute attr) {
    if (attr == null) {
        map = null;
        return;
    }

    Method m = classWriter.getMethod();
    Descriptor d = m.descriptor;
    String[] args;
    try {
        ConstantPool cp = classWriter.getClassFile().constant_pool;
        String argString = d.getParameterTypes(cp);
        args = argString.substring(1, argString.length() - 1).split("[, ]+");
    } catch (ConstantPoolException | InvalidDescriptor e) {
        return;
    }
    boolean isStatic = m.access_flags.is(AccessFlags.ACC_STATIC);

    verification_type_info[] initialLocals = new verification_type_info[(isStatic ? 0 : 1) + args.length];
    if (!isStatic)
        initialLocals[0] = new CustomVerificationTypeInfo("this");
    for (int i = 0; i < args.length; i++) {
        initialLocals[(isStatic ? 0 : 1) + i] =
                new CustomVerificationTypeInfo(args[i].replace(".", "/"));
    }

    map = new HashMap<>();
    StackMapBuilder builder = new StackMapBuilder();

    // using -1 as the pc for the initial frame effectively compensates for
    // the difference in behavior for the first stack map frame (where the
    // pc offset is just offset_delta) compared to subsequent frames (where
    // the pc offset is always offset_delta+1).
    int pc = -1;

    map.put(pc, new StackMap(initialLocals, empty));

    for (int i = 0; i < attr.entries.length; i++)
        pc = attr.entries[i].accept(builder, pc);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:41,代码来源:StackMapWriter.java


示例4: writeDescriptor

import com.sun.tools.classfile.Descriptor; //导入依赖的package包/类
private void writeDescriptor(int index, boolean resolveIndices) {
    if (resolveIndices) {
        try {
            ConstantPool constant_pool = classWriter.getClassFile().constant_pool;
            Descriptor d = new Descriptor(index);
            print(d.getFieldType(constant_pool));
            return;
        } catch (ConstantPoolException | InvalidDescriptor ignore) {
        }
    }

    print("#" + index);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:AnnotationWriter.java


示例5: check

import com.sun.tools.classfile.Descriptor; //导入依赖的package包/类
void check()
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    ClassFile classFileToCheck = ClassFile.read(new File("Test.class"));

    for (Method method : classFileToCheck.methods) {
        if ((method.access_flags.flags & ACC_STRICT) == 0) {
            errors.add(String.format(offendingMethodErrorMessage,
                    method.getName(classFileToCheck.constant_pool),
                    classFileToCheck.getName()));
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:CheckACC_STRICTFlagOnPkgAccessClassTest.java


示例6: analyzeClassFile

import com.sun.tools.classfile.Descriptor; //导入依赖的package包/类
void analyzeClassFile(ClassFile classFileToCheck)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    boolean enumClass =
            (classFileToCheck.access_flags.flags & ACC_ENUM) != 0;
    boolean nonFinalStaticEnumField;
    boolean nonFinalStaticField;

    currentFieldsToIgnore =
            classFieldsToIgnoreMap.get(classFileToCheck.getName());

    for (Field field : classFileToCheck.fields) {
        if (ignoreField(field.getName(classFileToCheck.constant_pool))) {
            continue;
        }
        nonFinalStaticEnumField =
                (field.access_flags.flags & (ACC_ENUM | ACC_FINAL)) == 0;
        nonFinalStaticField =
                (field.access_flags.flags & ACC_STATIC) != 0 &&
                (field.access_flags.flags & ACC_FINAL) == 0;
        if (enumClass ? nonFinalStaticEnumField : nonFinalStaticField) {
            errors.add("There is a mutable field named " +
                    field.getName(classFileToCheck.constant_pool) +
                    ", at class " +
                    classFileToCheck.getName());
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:DetectMutableStaticFields.java


示例7: MethodInfo

import com.sun.tools.classfile.Descriptor; //导入依赖的package包/类
MethodInfo(ClassFile cf, Method m) {
    this.method = m;

    String name;
    String paramTypes;
    String returnType;
    LineNumberTable_attribute.Entry[] lineNumberTable;
    try {
        // method name
        name = m.getName(cf.constant_pool);
        // signature
        paramTypes = m.descriptor.getParameterTypes(cf.constant_pool);
        returnType = m.descriptor.getReturnType(cf.constant_pool);
        Code_attribute codeAttr = (Code_attribute)
            m.attributes.get(Attribute.Code);
        lineNumberTable = ((LineNumberTable_attribute)
            codeAttr.attributes.get(Attribute.LineNumberTable)).line_number_table;
    } catch (ConstantPoolException|Descriptor.InvalidDescriptor e) {
        throw new RuntimeException(e);
    }
    this.name = name;
    this.paramTypes = paramTypes;
    this.returnType = returnType;
    Arrays.stream(lineNumberTable).forEach(entry ->
        bciToLineNumbers.computeIfAbsent(entry.start_pc, _n -> new TreeSet<>())
            .add(entry.line_number));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:TestBCI.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IValidationError类代码示例发布时间:2022-05-21
下一篇:
Java HadoopTestCase类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap