Skip to content

Commit 9b71b4d

Browse files
committed
Hacky fix to class downgrader failing when downgrading too new classes
1 parent d61ef9b commit 9b71b4d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

recaf-core/src/main/java/software/coley/recaf/util/JavaDowngraderUtil.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ public static void downgrade(int targetJavaVersion,
9191
for (String undesirableStub : undesirableStubs)
9292
flags.debugSkipStub.add(FullyQualifiedMemberNameAndDesc.of(undesirableStub));
9393

94+
// Any stub that is beyond our runtime version is not supported...
95+
//
96+
// This is due to the downgrader loading stubs at runtime when inserting missing API's, but those stubs
97+
// are compiled against the stubbed version minus one.
98+
//
99+
// If there is a stubbed API for Java 25, and we are running on Java 22 then stubs for 24 and 25 stubs will fail.
100+
for (int i = JavaVersion.get() + JavaVersion.VERSION_OFFSET + 1; i < 100; i++)
101+
flags.debugSkipStubs.add(i);
102+
94103
try (ClassDowngrader downgrader = new RecafClassDowngrader(flags, inheritanceGraph)) {
95104
int maxClassFileVersion = downgrader.maxVersion();
96105
classes.forEach((className, classBytes) -> {

0 commit comments

Comments
 (0)