FileDocCategorySizeDatePackage
ClassNameReader.javaAPI DocApache Ant 1.704343Wed Dec 13 06:16:24 GMT 2006org.apache.tools.ant.taskdefs.optional.jlink

ConstantPool

public class ConstantPool extends Object
Reads just enough of a class file to determine the class' full name.

Extremely minimal constant pool implementation, mainly to support extracting strings from a class file.

Fields Summary
static final byte
UTF8
static final byte
UNUSED
static final byte
INTEGER
static final byte
FLOAT
static final byte
LONG
static final byte
DOUBLE
static final byte
CLASS
static final byte
STRING
static final byte
FIELDREF
static final byte
METHODREF
static final byte
INTERFACEMETHODREF
static final byte
NAMEANDTYPE
byte[]
types
Object[]
values
Constructors Summary
ConstantPool(DataInput data)
Create a constant pool.

param
data the data input containing the class.
throws
IOException if there is an error.

    // CheckStyle:VisibilityModifier ON

                            
        
        super();

        int count = data.readUnsignedShort();
        types = new byte [ count ];
        values = new Object [ count ];
        // read in all constant pool entries.
        for (int i = 1; i < count; i++) {
            byte type = data.readByte();
            types[i] = type;
            switch (type) {
            case UTF8 :
                values[i] = data.readUTF();
                break;

            case UNUSED :
                break;

            case INTEGER :
                values[i] = new Integer(data.readInt());
                break;

            case FLOAT :
                values[i] = new Float(data.readFloat());
                break;

            case LONG :
                values[i] = new Long(data.readLong());
                ++i;
                break;

            case DOUBLE :
                values[i] = new Double(data.readDouble());
                ++i;
                break;

            case CLASS :
            case STRING :
                values[i] = new Integer(data.readUnsignedShort());
                break;

            case FIELDREF :
            case METHODREF :
            case INTERFACEMETHODREF :
            case NAMEANDTYPE :
                values[i] = new Integer(data.readInt());
                break;
            default:
                // Do nothing
            }
        }
    
Methods Summary