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

Java UnexpectedEntry类代码示例

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

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



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

示例1: checkMethod

import com.sun.tools.classfile.ConstantPool.UnexpectedEntry; //导入依赖的package包/类
void checkMethod(ConstantPool constantPool, Method method, AliveRanges ranges)
        throws InvalidIndex, UnexpectedEntry, ConstantPoolException {
    Code_attribute code = (Code_attribute) method.attributes.get(Attribute.Code);
    LocalVariableTable_attribute lvt =
        (LocalVariableTable_attribute) (code.attributes.get(Attribute.LocalVariableTable));
    List<String> infoFromRanges = convertToStringList(ranges);
    List<String> infoFromLVT = convertToStringList(constantPool, lvt);

    // infoFromRanges most be contained in infoFromLVT
    int i = 0;
    int j = 0;
    while (i < infoFromRanges.size() && j < infoFromLVT.size()) {
        int comparison = infoFromRanges.get(i).compareTo(infoFromLVT.get(j));
        if (comparison == 0) {
            i++; j++;
        } else if (comparison > 0) {
            j++;
        } else {
            break;
        }
    }

    if (i < infoFromRanges.size()) {
        error(infoFromLVT, infoFromRanges, method.getName(constantPool).toString());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:LVTHarness.java


示例2: compare

import com.sun.tools.classfile.ConstantPool.UnexpectedEntry; //导入依赖的package包/类
public static boolean compare(Map<String, TypeAnnotation.Position> expectedAnnos,
        List<TypeAnnotation> actualAnnos, ClassFile cf) throws InvalidIndex, UnexpectedEntry {
    if (actualAnnos.size() != expectedAnnos.size()) {
        throw new ComparisionException("Wrong number of annotations",
                expectedAnnos,
                actualAnnos);
    }

    for (Map.Entry<String, TypeAnnotation.Position> e : expectedAnnos.entrySet()) {
        String aName = e.getKey();
        TypeAnnotation.Position expected = e.getValue();
        TypeAnnotation actual = findAnnotation(aName, actualAnnos, cf);
        if (actual == null)
            throw new ComparisionException("Expected annotation not found: " + aName);

        if (!areEquals(expected, actual.position)) {
            throw new ComparisionException("Unexpected position for annotation : " + aName +
                    "\n  Expected: " + expected.toString() +
                    "\n  Found: " + actual.position.toString());
        }
    }
    return true;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:ReferenceInfoUtil.java


示例3: compare

import com.sun.tools.classfile.ConstantPool.UnexpectedEntry; //导入依赖的package包/类
public static boolean compare(Map<String, TypeAnnotation.Position> expectedAnnos,
        List<TypeAnnotation> actualAnnos, ClassFile cf) throws InvalidIndex, UnexpectedEntry {
    if (actualAnnos.size() != expectedAnnos.size()) {
        throw new ComparisionException("Wrong number of annotations",
                expectedAnnos,
                actualAnnos);
    }

    for (Map.Entry<String, TypeAnnotation.Position> e : expectedAnnos.entrySet()) {
        String aName = e.getKey();
        TypeAnnotation.Position expected = e.getValue();
        TypeAnnotation actual = findAnnotation(aName, actualAnnos, cf);
        if (actual == null)
            throw new ComparisionException("Expected annotation not found: " + aName);

        // TODO: you currently get an exception if the test case does not use all necessary
        // annotation attributes, e.g. forgetting the offset for a local variable.
        // It would be nicer to give an understandable warning instead.
        if (!areEquals(expected, actual.position)) {
            throw new ComparisionException("Unexpected position for annotation : " + aName +
                    "\n  Expected: " + expected.toString() +
                    "\n  Found: " + actual.position.toString());
        }
    }
    return true;
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:27,代码来源:ReferenceInfoUtil.java


示例4: checkMethod

import com.sun.tools.classfile.ConstantPool.UnexpectedEntry; //导入依赖的package包/类
void checkMethod(ConstantPool constantPool, Method method, AliveRanges ranges)
        throws InvalidIndex, UnexpectedEntry {
    Code_attribute code = (Code_attribute) method.attributes.get(Attribute.Code);
    LocalVariableTable_attribute lvt =
        (LocalVariableTable_attribute) (code.attributes.get(Attribute.LocalVariableTable));
    List<String> infoFromRanges = convertToStringList(ranges);
    List<String> infoFromLVT = convertToStringList(constantPool, lvt);

    // infoFromRanges most be contained in infoFromLVT
    int i = 0;
    int j = 0;
    while (i < infoFromRanges.size() && j < infoFromLVT.size()) {
        int comparison = infoFromRanges.get(i).compareTo(infoFromLVT.get(j));
        if (comparison == 0) {
            i++; j++;
        } else if (comparison > 0) {
            j++;
        } else {
            break;
        }
    }

    if (i < infoFromRanges.size()) {
        error(infoFromLVT, infoFromRanges);
    }
}
 
开发者ID:infobip,项目名称:infobip-open-jdk-8,代码行数:27,代码来源:LVTHarness.java


示例5: compare

import com.sun.tools.classfile.ConstantPool.UnexpectedEntry; //导入依赖的package包/类
public static boolean compare(List<Pair<String, TypeAnnotation.Position>> expectedAnnos,
        List<TypeAnnotation> actualAnnos, ClassFile cf) throws InvalidIndex, UnexpectedEntry {
    if (actualAnnos.size() != expectedAnnos.size()) {
        throw new ComparisionException("Wrong number of annotations",
                expectedAnnos,
                actualAnnos);
    }

    for (Pair<String, TypeAnnotation.Position> e : expectedAnnos) {
        String aName = e.first;
        TypeAnnotation.Position expected = e.second;
        TypeAnnotation actual = findAnnotation(aName, expected, actualAnnos, cf);
        if (actual == null) {
            throw new ComparisionException("Expected annotation not found: " + aName + " position: " + expected,
                expectedAnnos,
                actualAnnos);
        }
    }
    return true;
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:21,代码来源:ReferenceInfoUtil.java


示例6: checkMatch

import com.sun.tools.classfile.ConstantPool.UnexpectedEntry; //导入依赖的package包/类
/**
 * Indicate whether an annotation matches this expected
 * annotation.
 *
 * @param ConstantPool The constant pool to use.
 * @param anno The annotation to check.
 * @return Whether the annotation matches.
 */
protected boolean checkMatch(ConstantPool cpool,
                             Annotation anno) {
    try {
        return cpool.getUTF8Info(anno.type_index).value.equals("L" + expectedName + ";");
    } catch (InvalidIndex | UnexpectedEntry e) {
        return false;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:ClassfileInspector.java


示例7: convertToStringList

import com.sun.tools.classfile.ConstantPool.UnexpectedEntry; //导入依赖的package包/类
List<String> convertToStringList(ConstantPool constantPool,
        LocalVariableTable_attribute lvt) throws InvalidIndex, UnexpectedEntry {
    List<String> result = new ArrayList<>();
    for (Entry entry : lvt.local_variable_table) {
        String str = formatLocalVariableData(constantPool.getUTF8Value(entry.name_index),
                entry.start_pc, entry.length);
        result.add(str);
    }
    Collections.sort(result);
    return result;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:LVTHarness.java


示例8: findAnnotation

import com.sun.tools.classfile.ConstantPool.UnexpectedEntry; //导入依赖的package包/类
private static TypeAnnotation findAnnotation(String name, List<TypeAnnotation> annotations, ClassFile cf) throws InvalidIndex, UnexpectedEntry {
    String properName = "L" + name + ";";
    for (TypeAnnotation anno : annotations) {
        String actualName = cf.constant_pool.getUTF8Value(anno.annotation.type_index);
        if (properName.equals(actualName))
            return anno;
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:ReferenceInfoUtil.java


示例9: findAnnotation

import com.sun.tools.classfile.ConstantPool.UnexpectedEntry; //导入依赖的package包/类
private static TypeAnnotation findAnnotation(String name, TypeAnnotation.Position expected, List<TypeAnnotation> annotations, ClassFile cf) throws InvalidIndex, UnexpectedEntry {
    String properName = "L" + name + ";";
    for (TypeAnnotation anno : annotations) {
        String actualName = cf.constant_pool.getUTF8Value(anno.annotation.type_index);
        if (properName.equals(actualName) &&
            areEquals(expected, anno.position))
            return anno;
    }
    return null;
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:11,代码来源:ReferenceInfoUtil.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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