Skip to content

Java 25 runtime compatibility - #1

Open
PerrierBouteille wants to merge 5 commits into
Trialsfrom
feat/java25-runtime
Open

Java 25 runtime compatibility#1
PerrierBouteille wants to merge 5 commits into
Trialsfrom
feat/java25-runtime

Conversation

@PerrierBouteille

Copy link
Copy Markdown

But

Rendre le serveur Arclight (Forge 1.20.1 / 47.4.18) compatible Java 25 au runtime. Le build reste fait avec un JDK 17 ; seul l'exécution du serveur cible Java 25.

Constat clé

La stack launcher de Forge 47.4.18 (securejarhandler 2.1.10, modlauncher 10.0.9, bootstraplauncher, mixin 0.8.5) boote déjà sur Java 25. Il ne restait que des usages d'API JDK supprimées.

Correctifs

  1. arclight-api Unsafe (jar repatché + source vendorée sous arclight-forge/patches/) : ensureClassInitialized/shouldBeInitialized routés vers jdk.internal.misc.Unsafe (supprimés de sun.misc.Unsafe en JDK 22+), caller-class via StackWalker (le constructeur SecurityManager jette en JDK 24+, JEP 486), et cast (Object) rétabli sur defineAnonymousClass.
  2. JavaPluginLoaderMixin : la génération ASM d'EventExecutor est extraite vers un helper EventExecutorGenerator. Mixin 0.8.5 ne sait pas résoudre les métadonnées org.objectweb.asm.ClassVisitor sur Java 25 quand elles sont dans des méthodes du mixin.
  3. ForgeInstaller.addToPath : fallback sur URLClassPath(URL[]) (le constructeur (URL[], AccessControlContext) a disparu en JDK 24+).

Validation (Corretto 25.0.2)

  • ✅ Démarrage complet : Done! For help, type "help", arrêt propre. Pas de régression sur JDK 17.
  • ✅ Plugin de test : enregistrement d'events (génération ASM via Unsafe) + livraison de ServerLoadEvent.
  • ✅ Plugin NMS : références directes CraftServer + NMS remappées correctement par le remapper (CraftServer.getServer()net.minecraft.server.dedicated.DedicatedServer).

🤖 Generated with Claude Code

PerrierBouteille and others added 5 commits June 18, 2026 11:53
sun.misc.Unsafe.ensureClassInitialized / shouldBeInitialized were removed in
JDK 22+, and SecurityManager's constructor throws on JDK 24+ (JEP 486), so
io.izzel.arclight.api.Unsafe crashed at class-init on Java 25.

Forked arclight-api-1.5.4: route those two methods to jdk.internal.misc.Unsafe
via the trusted IMPL_LOOKUP, force the StackWalker caller-class path, and
neutralise the now-dead defineAnonymousClass branch. The patched jar is embedded
in place of the Maven artifact. Verified: the server still boots on JDK 17 and
now gets past ForgeInstaller + Forge launcher bootstrap on JDK 25.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
On Java 25 the Mixin (0.8.5) bytecode provider cannot resolve
org.objectweb.asm.ClassVisitor metadata, so preprocessing JavaPluginLoaderMixin
(whose merged methods referenced ClassVisitor/ClassWriter) crashed with
ClassMetadataNotFoundException, aborting server start.

Extract the ASM EventExecutor generation (createExecutor/createConstructor/
createImpl + the cache/counter) into a normal helper class
EventExecutorGenerator that the mixin calls. The mixin no longer exposes any
org.objectweb.asm.* type to Mixin's preprocessor; the ASM classes still load and
run fine at runtime. With this + the Unsafe patch the server now reaches
"Done! For help, type help" on Java 25 (verified on Corretto 25), and still on 17.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ForgeInstaller.addToPath built jdk.internal.loader.URLClassPath via its
(URL[], AccessControlContext) constructor, which was removed on JDK 24+ when
JEP 486 dropped the AccessControlContext parameter. On Java 25 this threw
NoSuchMethodException on every addToPath call (spammed to stderr).

Try the legacy (URL[], AccessControlContext) constructor first (JDK 17-21) and
fall back to the new (URL[]) constructor (JDK 24+). Verified: no more spam and
the server reaches "Done! For help, type help" on Corretto 25.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…light-api

Regression from rebuilding arclight-api's decompiled Unsafe: the decompiler had
dropped the (Object) cast on the last invokeExact argument of
defineAnonymousClass, so the recompiled call passed `objects` as Object[] while
the H_DEF_CLASS handle (ClassLoader.defineClass0) expects Object, throwing
WrongMethodTypeException whenever a plugin registered event listeners
(JavaPluginLoader.createRegisteredListeners -> EventExecutorGenerator).

Restore the (Object) cast. Verified with a test plugin on Corretto 25:
listener registration generates the EventExecutor and ServerLoadEvent is
delivered to the plugin.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The Java 25 fixes for io.izzel.arclight.api.Unsafe ship as a rebuilt binary jar
(arclight-forge/libs/arclight-api-1.5.4-j25.jar) because arclight-api's source
isn't published. Keep the patched source under arclight-forge/patches/ so the
change is reviewable and the jar reproducible. No build behaviour change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant