postbuild: CP tag 15 (MethodHandle) + rename Cif/Cdo class files to if/do; BUILD SUCCESSFUL

This commit is contained in:
loki5512344 2026-10-03 17:44:06 +02:00
parent 036d94952c
commit 9a98af08a4
Signed by: boba
GPG key ID: 253067914055423B
4 changed files with 119 additions and 3 deletions

36
build-logs/fullbuild1.log Normal file
View file

@ -0,0 +1,36 @@
> Configure project :
Fabric Loom: 1.17.12
> Task :compileJava UP-TO-DATE
> Task :processResources
> Task :classes
> Task :postprocessClasses FAILED
Traceback (most recent call last):
File "/storage/aboba/evovis-client/tools/postbuild.py", line 133, in <module>
sys.exit(main())
~~~~^^
File "/storage/aboba/evovis-client/tools/postbuild.py", line 122, in main
moved, touched = process_dir(target)
~~~~~~~~~~~^^^^^^^^
File "/storage/aboba/evovis-client/tools/postbuild.py", line 77, in process_dir
new = rewrite_class(data)
File "/storage/aboba/evovis-client/tools/postbuild.py", line 57, in rewrite_class
raise ValueError(f"unknown constant pool tag {tag} at offset {i - 1}")
ValueError: unknown constant pool tag 15 at offset 6234
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':postprocessClasses' (registered in build file 'build.gradle').
> Process 'command 'python3'' finished with non-zero exit value 1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights from a Build Scan (powered by Develocity).
> Get more help at https://help.gradle.org.
BUILD FAILED in 6s
3 actionable tasks: 2 executed, 1 up-to-date

32
build-logs/fullbuild2.log Normal file
View file

@ -0,0 +1,32 @@
> Configure project :
Fabric Loom: 1.17.12
> Task :compileJava
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
> Task :processResources UP-TO-DATE
> Task :classes
> Task :postprocessClasses
postbuild: moved=1311 rewritten=105 (/storage/aboba/evovis-client/build/classes/java/main)
> Task :processIncludeJars
> Task :compileTestJava NO-SOURCE
> Task :processTestResources NO-SOURCE
> Task :testClasses UP-TO-DATE
> Task :test NO-SOURCE
> Task :jar
> Task :validateAccessWidener
> Task :assemble
> Task :check
> Task :build
[Incubating] Problems report is available at: file:///storage/aboba/evovis-client/build/reports/problems/problems-report.html
BUILD SUCCESSFUL in 28s
6 actionable tasks: 5 executed, 1 up-to-date
Consider enabling configuration cache to speed up this build: https://docs.gradle.org/9.5.0/userguide/configuration_cache_enabling.html

25
build-logs/fullbuild3.log Normal file
View file

@ -0,0 +1,25 @@
> Configure project :
Fabric Loom: 1.17.12
> Task :compileJava UP-TO-DATE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :postprocessClasses
postbuild: moved=2 rewritten=0 (/storage/aboba/evovis-client/build/classes/java/main)
> Task :processIncludeJars UP-TO-DATE
> Task :compileTestJava NO-SOURCE
> Task :processTestResources NO-SOURCE
> Task :testClasses UP-TO-DATE
> Task :test NO-SOURCE
> Task :validateAccessWidener UP-TO-DATE
> Task :check UP-TO-DATE
> Task :jar
> Task :assemble
> Task :build
BUILD SUCCESSFUL in 8s
6 actionable tasks: 2 executed, 4 up-to-date
Consider enabling configuration cache to speed up this build: https://docs.gradle.org/9.5.0/userguide/configuration_cache_enabling.html

View file

@ -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()