Пример #1
0
 def __init__(self, class_file: ClassFile, stream: Stream):
     self.access_flags = stream.read_u2()
     self.name_index = stream.read_u2()
     self.descriptor_index = stream.read_u2()
     self.attributes: List[Attribute] = [
         Attribute.read(class_file, stream) for _ in range(stream.read_u2())
     ]
     print(class_file.constants[self.name_index], self.attributes)
Пример #2
0
 def __init__(self, stream: Stream):
     magic = stream.read_u4()
     if magic != 0xCAFEBABE:
         raise Exception('Wrong magic')
     self.minor_version = stream.read_u2()
     self.major_version = stream.read_u2()
     self.constants: List[Constant] = self.read_constants(stream)
     self.access_flags = stream.read_u2()
     self.this_class = stream.read_u2()
     self.super_class = stream.read_u2()
     self.interfaces = [stream.read_u2() for _ in range(stream.read_u2())]
     self.fields: List[FieldMethodInfo] = [
         FieldMethodInfo(self, stream) for _ in range(stream.read_u2())
     ]
     self.methods: List[FieldMethodInfo] = [
         FieldMethodInfo(self, stream) for _ in range(stream.read_u2())
     ]
     self.attributes: List[Attribute] = [
         Attribute.read(self, stream) for _ in range(stream.read_u2())
     ]
     print(self.attributes)