def read_constant_pool(self) -> List[T]: constant_pool_items: List[T] = [Empty] for c in range(self.constant_pool_count - 1): tag = ConstantPoolTag(utils.CalculationUtils.hex_to_decimal(self.file.read(1).hex())) if tag == ConstantPoolTag.CONSTANT_UTF8: length = read_unsigned_short(self.file) designated_bytes: str = codecs.decode(read_designated_bytes(self.file, length).hex(), 'hex_codec').decode('utf-8') constant_pool_items.append(Utf8(length, designated_bytes)) elif tag == ConstantPoolTag.CONSTANT_CLASS: name_index: int = read_unsigned_short(self.file) constant_pool_items.append(Class(name_index)) elif tag == ConstantPoolTag.CONSTANT_String: string_index = read_unsigned_short(self.file) constant_pool_items.append(String(string_index)) elif tag == ConstantPoolTag.CONSTANT_FIELD_REF: class_index = read_unsigned_short(self.file) name_and_type_index = read_unsigned_short(self.file) constant_pool_items.append(FieldRef(class_index, name_and_type_index)) elif tag == ConstantPoolTag.CONSTANT_METHOD_REF: class_index = read_unsigned_short(self.file) name_and_type_index = read_unsigned_short(self.file) constant_pool_items.append(MethodRef(class_index, name_and_type_index)) elif tag == ConstantPoolTag.CONSTANT_NAME_AND_TYPE: class_index = read_unsigned_short(self.file) name_and_type_index = read_unsigned_short(self.file) constant_pool_items.append(NameAndType(class_index, name_and_type_index)) return constant_pool_items
def read_attributes_count(self) -> int: return read_unsigned_short(self.file)
def read_constant_pool_count(self) -> int: return read_unsigned_short(self.file)
def read_methods_count(self) -> int: return read_unsigned_short(self.file)
def read_interfaces_count(self) -> int: return read_unsigned_short(self.file)