Search in sources :

Example 1 with J9RAMConstantPoolItemPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9RAMConstantPoolItemPointer in project openj9 by eclipse.

the class VMConstantPool method getClass.

/**
 * Get a class from the constant pool.
 * @param index A J9VmconstantpoolConstants index into the constant pool.  Must be for a class reference.
 * @return Either the loaded class, or if its not in the constant pool, J9ClassPointer.NULL.
 * @throws CorruptDataException If the CPShape of the index is not a class.
 */
public static J9ClassPointer getClass(long index) throws CorruptDataException {
    if (_constantPool.length <= index || 0 > index) {
        throw new IndexOutOfBoundsException("Index outside of constant pool bounds");
    }
    int cpIndex = (int) index;
    long shapeDesc = ConstantPoolHelpers.J9_CP_TYPE(_cpShapeDescription, cpIndex);
    if (J9CPTYPE_CLASS != shapeDesc) {
        throw new CorruptDataException("VMConstantPool[" + index + "] CP_TYPE is not J9CPTYPE_CLASS");
    }
    J9ClassPointer classPointer = null;
    if (null != _constantPool[cpIndex]) {
        classPointer = (J9ClassPointer) _constantPool[cpIndex];
    } else {
        J9RAMConstantPoolItemPointer ramEntry = _ramCPStart.add(index);
        classPointer = J9RAMClassRefPointer.cast(ramEntry).value();
        _constantPool[cpIndex] = classPointer;
    }
    return classPointer;
}
Also used : J9RAMConstantPoolItemPointer(com.ibm.j9ddr.vm29.pointer.generated.J9RAMConstantPoolItemPointer) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Aggregations

CorruptDataException (com.ibm.j9ddr.CorruptDataException)1 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)1 J9RAMConstantPoolItemPointer (com.ibm.j9ddr.vm29.pointer.generated.J9RAMConstantPoolItemPointer)1