private static ConstantPoolEntry getConstant(ClassInput in) throws IOException {

    ConstantPoolEntry item;
    int tag;
    tag = in.readUnsignedByte();

    switch (tag) {
      case VMDescriptor.CONSTANT_Class:
      case VMDescriptor.CONSTANT_String:
        item = new CONSTANT_Index_info(tag, in.getU2(), 0);
        break;

      case VMDescriptor.CONSTANT_NameAndType:
      case VMDescriptor.CONSTANT_Fieldref:
      case VMDescriptor.CONSTANT_Methodref:
      case VMDescriptor.CONSTANT_InterfaceMethodref:
        item = new CONSTANT_Index_info(tag, in.getU2(), in.getU2());
        break;

      case VMDescriptor.CONSTANT_Integer:
        item = new CONSTANT_Integer_info(in.getU4());
        break;

      case VMDescriptor.CONSTANT_Float:
        item = new CONSTANT_Float_info(in.readFloat());
        break;

      case VMDescriptor.CONSTANT_Long:
        item = new CONSTANT_Long_info(in.readLong());
        break;

      case VMDescriptor.CONSTANT_Double:
        item = new CONSTANT_Double_info(in.readDouble());
        break;

      case VMDescriptor.CONSTANT_Utf8:
        item = new CONSTANT_Utf8_info(in.readUTF());
        break;
      default:
        throw new ClassFormatError();
    }

    return item;
  }