com.sun.tools.classfile.ConstantPool.InvalidIndex Java Examples

The following examples show how to use com.sun.tools.classfile.ConstantPool.InvalidIndex. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LVTHarness.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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());
    }
}
 
Example #2
Source File: ReferenceInfoUtil.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #3
Source File: LVTHarness.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #4
Source File: ReferenceInfoUtil.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #5
Source File: LVTHarness.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #6
Source File: ReferenceInfoUtil.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #7
Source File: LVTHarness.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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());
    }
}
 
Example #8
Source File: ClassReader.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public String visitNameAndType(CONSTANT_NameAndType_info c, Integer p) {
    String value = slist.get(p);
    if (value == null) {
        try {
            value = visit(cfpool.get(c.name_index), c.name_index);
            value = value.concat(" " +
                    visit(cfpool.get(c.type_index), c.type_index));
            slist.set(p, value);
            xpool.add(new Element("CONSTANT_NameAndType",
                      new String[]{"id", p.toString()},
                      value));
        } catch (InvalidIndex ex) {
            ex.printStackTrace();
        }
    }
    return value;
}
 
Example #9
Source File: ClassReader.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void readCP(ClassFile c) throws IOException {
    cpool = new Element("ConstantPool", c.constant_pool.size());
    ConstantPoolVisitor cpv = new ConstantPoolVisitor(cpool, c,
            c.constant_pool.size());
    for (int i = 1 ; i < c.constant_pool.size() ; i++) {
        try {
            cpv.visit(c.constant_pool.get(i), i);
        } catch (InvalidIndex ex) {
            // can happen periodically when accessing doubles etc. ignore it
            // ex.printStackTrace();
        }
    }
    thePool = cpv.getPoolList();
    if (verbose) {
        for (int i = 0; i < thePool.size(); i++) {
            System.out.println("[" + i + "]: " + thePool.get(i));
        }
    }
    if (keepCP) {
        cfile.add(cpool);
    }
}
 
Example #10
Source File: ReferenceInfoUtil.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #11
Source File: LVTHarness.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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());
    }
}
 
Example #12
Source File: ReferenceInfoUtil.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #13
Source File: LVTHarness.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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());
    }
}
 
Example #14
Source File: ReferenceInfoUtil.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #15
Source File: LVTHarness.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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());
    }
}
 
Example #16
Source File: ReferenceInfoUtil.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #17
Source File: ReferenceInfoUtil.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #18
Source File: LVTHarness.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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());
    }
}
 
Example #19
Source File: LVTHarness.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #20
Source File: DeadCodeGeneratedForEmptyTryTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
void checkIndirectRefToString(int cp_index) {
    try {
        CPInfo cInfo = constantPool.get(cp_index);
        if (cInfo instanceof CONSTANT_String_info) {
            CONSTANT_String_info strInfo = (CONSTANT_String_info)cInfo;
            if (strInfo.string_index == utf8Index) {
                numberOfRefToStr++;
            }
        }
    } catch (InvalidIndex ex) {
        throw new AssertionError("invalid constant pool index at " + cp_index);
    }
}
 
Example #21
Source File: DeadCodeGeneratedForEmptyTryTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
void checkIndirectRefToString(int cp_index) {
    try {
        CPInfo cInfo = constantPool.get(cp_index);
        if (cInfo instanceof CONSTANT_String_info) {
            CONSTANT_String_info strInfo = (CONSTANT_String_info)cInfo;
            if (strInfo.string_index == utf8Index) {
                numberOfRefToStr++;
            }
        }
    } catch (InvalidIndex ex) {
        throw new AssertionError("invalid constant pool index at " + cp_index);
    }
}
 
Example #22
Source File: ReferenceInfoUtil.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #23
Source File: LVTHarness.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #24
Source File: DeadCodeGeneratedForEmptyTryTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
void checkIndirectRefToString(int cp_index) {
    try {
        CPInfo cInfo = constantPool.get(cp_index);
        if (cInfo instanceof CONSTANT_String_info) {
            CONSTANT_String_info strInfo = (CONSTANT_String_info)cInfo;
            if (strInfo.string_index == utf8Index) {
                numberOfRefToStr++;
            }
        }
    } catch (InvalidIndex ex) {
        throw new AssertionError("invalid constant pool index at " + cp_index);
    }
}
 
Example #25
Source File: ReferenceInfoUtil.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #26
Source File: ReferenceInfoUtil.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #27
Source File: DeadCodeGeneratedForEmptyTryTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
void checkIndirectRefToString(int cp_index) {
    try {
        CPInfo cInfo = constantPool.get(cp_index);
        if (cInfo instanceof CONSTANT_String_info) {
            CONSTANT_String_info strInfo = (CONSTANT_String_info)cInfo;
            if (strInfo.string_index == utf8Index) {
                numberOfRefToStr++;
            }
        }
    } catch (InvalidIndex ex) {
        throw new AssertionError("invalid constant pool index at " + cp_index);
    }
}
 
Example #28
Source File: LVTHarness.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #29
Source File: DeadCodeGeneratedForEmptyTryTest.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
void checkIndirectRefToString(int cp_index) {
    try {
        CPInfo cInfo = constantPool.get(cp_index);
        if (cInfo instanceof CONSTANT_String_info) {
            CONSTANT_String_info strInfo = (CONSTANT_String_info)cInfo;
            if (strInfo.string_index == utf8Index) {
                numberOfRefToStr++;
            }
        }
    } catch (InvalidIndex ex) {
        throw new AssertionError("invalid constant pool index at " + cp_index);
    }
}
 
Example #30
Source File: ReferenceInfoUtil.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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;
}