postbuild: CP tag 15 (MethodHandle) + rename Cif/Cdo class files to if/do; BUILD SUCCESSFUL
This commit is contained in:
parent
036d94952c
commit
9a98af08a4
4 changed files with 119 additions and 3 deletions
|
|
@ -50,6 +50,9 @@ def rewrite_class(data: bytes) -> bytes:
|
|||
elif tag in (7, 8, 16, 19, 20):
|
||||
entries.append(bytes([tag]) + data[i : i + 2])
|
||||
i += 2
|
||||
elif tag == 15:
|
||||
entries.append(bytes([tag]) + data[i : i + 3])
|
||||
i += 3
|
||||
elif tag in (9, 10, 11, 12, 17, 18):
|
||||
entries.append(bytes([tag]) + data[i : i + 4])
|
||||
i += 4
|
||||
|
|
@ -65,6 +68,15 @@ def rewrite_class(data: bytes) -> bytes:
|
|||
return bytes(out)
|
||||
|
||||
|
||||
def rename_stem(name: str, sep: str) -> str:
|
||||
parts = name.split(sep)
|
||||
stem = parts[-1][: -len(".class")] if parts[-1].endswith(".class") else None
|
||||
if stem in RENAME:
|
||||
parts[-1] = RENAME[stem] + ".class"
|
||||
return sep.join(parts)
|
||||
return name
|
||||
|
||||
|
||||
def process_dir(root: str) -> tuple[int, int]:
|
||||
moved = 0
|
||||
touched = 0
|
||||
|
|
@ -78,13 +90,20 @@ def process_dir(root: str) -> tuple[int, int]:
|
|||
rel = os.path.relpath(path, root)
|
||||
prefix = "defpackage" + os.sep
|
||||
if rel.startswith(prefix):
|
||||
target = os.path.join(root, rel[len(prefix) :])
|
||||
target = os.path.join(root, rename_stem(rel[len(prefix) :], os.sep))
|
||||
else:
|
||||
target = os.path.join(root, rename_stem(rel, os.sep))
|
||||
if target != path:
|
||||
os.makedirs(os.path.dirname(target), exist_ok=True)
|
||||
open(target, "wb").write(new)
|
||||
out = open(target, "wb")
|
||||
out.write(new)
|
||||
out.close()
|
||||
os.remove(path)
|
||||
moved += 1
|
||||
elif new != data:
|
||||
open(path, "wb").write(new)
|
||||
out = open(path, "wb")
|
||||
out.write(new)
|
||||
out.close()
|
||||
touched += 1
|
||||
return moved, touched
|
||||
|
||||
|
|
@ -105,6 +124,10 @@ def process_jar(path: str) -> tuple[int, int]:
|
|||
moved += 1
|
||||
elif new != data:
|
||||
touched += 1
|
||||
renamed = rename_stem(name, "/")
|
||||
if renamed != name:
|
||||
name = renamed
|
||||
touched += 1
|
||||
data = new
|
||||
dst.writestr(info, data)
|
||||
dst.close()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue