Java 类com.sun.tools.classfile.ConstantPool.UnexpectedEntry 实例源码

项目:openjdk-jdk10    文件:LVTHarness.java   
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());
    }
}
项目:openjdk-jdk10    文件:ReferenceInfoUtil.java   
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;
}
项目:openjdk9    文件:LVTHarness.java   
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());
    }
}
项目:openjdk9    文件:ReferenceInfoUtil.java   
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;
}
项目:lookaside_java-1.8.0-openjdk    文件:LVTHarness.java   
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());
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:ReferenceInfoUtil.java   
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;
}
项目:jsr308-langtools    文件:LVTHarness.java   
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());
    }
}
项目:jsr308-langtools    文件:ReferenceInfoUtil.java   
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;
}
项目:infobip-open-jdk-8    文件:LVTHarness.java   
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);
    }
}
项目:infobip-open-jdk-8    文件:ReferenceInfoUtil.java   
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;
}
项目:OLD-OpenJDK8    文件:LVTHarness.java   
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);
    }
}
项目:OLD-OpenJDK8    文件:ReferenceInfoUtil.java   
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;
}
项目:checker-framework    文件:ReferenceInfoUtil.java   
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;
}
项目:openjdk-jdk10    文件:ClassfileInspector.java   
/**
 * 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;
    }
}
项目:openjdk-jdk10    文件:LVTHarness.java   
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;
}
项目:openjdk-jdk10    文件:ReferenceInfoUtil.java   
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;
}
项目:openjdk9    文件:ClassfileInspector.java   
/**
 * 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;
    }
}
项目:openjdk9    文件:LVTHarness.java   
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;
}
项目:openjdk9    文件:ReferenceInfoUtil.java   
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;
}
项目:lookaside_java-1.8.0-openjdk    文件:LVTHarness.java   
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;
}
项目:lookaside_java-1.8.0-openjdk    文件:ReferenceInfoUtil.java   
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;
}
项目:jsr308-langtools    文件:LVTHarness.java   
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;
}
项目:jsr308-langtools    文件:ReferenceInfoUtil.java   
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;
}
项目:infobip-open-jdk-8    文件:LVTHarness.java   
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;
}
项目:infobip-open-jdk-8    文件:ReferenceInfoUtil.java   
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;
}
项目:OLD-OpenJDK8    文件:LVTHarness.java   
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;
}
项目:OLD-OpenJDK8    文件:ReferenceInfoUtil.java   
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;
}
项目:checker-framework    文件:ReferenceInfoUtil.java   
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;
}