def parse_class(data): from classfile.ClassFile import ClassFile class_file = ClassFile() cf, err = class_file.parse(data) if err: raise RuntimeError("java.lang.ClassFormatError!") else: return Class.new_class(cf)
def load_class(class_name, class_path): class_data, _, error = class_path.read_class(class_name) class_file = ClassFile() cf = class_file.parse(class_data) return cf
def get_source_file(classFile: ClassFile): source_file_attr = classFile.source_file_attribute() if source_file_attr is not None: return source_file_attr.file_name return "Unknown"