Skip to content

Run MCPC+ / Cauldron 1.6.4 servers on Java 17 - #1

Closed
MisterSandFR wants to merge 5 commits into
mainfrom
claude/fervent-gates-tkterz
Closed

MisterSandFR wants to merge 5 commits into
mainfrom
claude/fervent-gates-tkterz

Conversation

@MisterSandFR

Copy link
Copy Markdown
Contributor

L'agent démarre désormais les serveurs MCPC+ / Cauldron 1.6.4 sous Java 17 au lieu de Java 8. Il est renommé mcpc-java17-agent (package gg.nationsglory.mcpcj17, logs [mcpc-j17]).

Ce que l'agent corrige sous Java 17

  • Check de version : java.version est présentée comme 1.7.0_80 sur toute JVM autre que Java 7.

  • launchwrapper : Launch castait le class loader de l'application en URLClassLoader, ce qui échoue depuis Java 9. Il est remplacé seulement s'il fait encore ce cast. LaunchClassLoader délègue au JDK les packages du platform loader (javax.sql, javax.script…).

  • Modules : tous les packages du JDK sont ouverts au serveur, et les filtres de réflexion de Java 12+ (Field.modifiers) sont retirés.

  • sun.reflect.ReflectionFactory supprimé : les références (EnumHelper de Forge, NGEnumFactory…) sont redirigées vers des remplaçants fournis par l'agent.

  • ASM : l'agent embarque ASM 9.7 et le substitue à l'ASM 4.1 de MCPC+, ce qui permet de charger des mods Java 8+ et des coremods utilisant une API ASM récente. Cet ASM est adapté au build pour rester compatible avec Forge 1.6.4 :

    • Remapping*Adapter repris d'ASM 7.0 ;
    • Type.getType accepte un nom interne, comme ASM 4 ;
    • les visiteurs déclarés en API ASM4 ne lèvent plus requires ASMx, et le flag « interface » des appels est conservé.

    Un serveur qui a déjà un ASM ≥ 5 garde le sien.

  • CI : GitHub Actions construit le jar à chaque push ; un tag v* publie une release avec le jar.

Tests (OpenJDK 17.0.20)

Avec un mod de test compilé en Java 8 (lambdas, streams, méthodes static/default d'interface) qui contient aussi un coremod en Opcodes.ASM9 :

  • MCPC+ 1.6.4 d'origine (Forge 9.11.1.965, ASM 4.1) : Done, mod actif, 0 erreur FML. Sans agent : ClassCastException dans Launch.
  • Build NGServer (ASM 9 ou ASM 4.1 dans libraries/) : Done, mod actif, 0 erreur. Sans agent : plantage au chargement du monde.

Les deux serveurs ont été testés sans joueurs connectés et sans les mods de production.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DszbR9jSTnJF2dtbGNiQRv


Generated by Claude Code

- Spoof java.version on any non-Java 7 runtime to pass the MCPC+ check.
- Patch launchwrapper's Launch constructor: the app class loader is no
  longer a URLClassLoader, so build LaunchClassLoader from java.class.path
  and delegate platform-loader packages (javax.sql, javax.script...).
- Open every JDK package to unnamed modules and remove the Java 12+
  reflection filters (Field.modifiers), as on Java 8.
- Redirect sun.reflect.ReflectionFactory / ConstructorAccessor /
  FieldAccessor to shims so Forge's EnumHelper can still add enum values.
- Rename the agent to mcpc-java17-agent and require Java 17 to build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DszbR9jSTnJF2dtbGNiQRv
The NGServer build of MCPC+ 1.6.4 ships a Launch that no longer casts the
app class loader, and is compiled against ASM 9: replacing those classes
with the stock launchwrapper 1.8 / ASM 4 ones broke it.

- Replace Launch only if it still references URLClassLoader.
- Replace the ASM classes only if the loader's ClassReader predates ASM 5.
- Configure LaunchClassLoader (platform packages, agent shims) from the
  transformer when it defines its first class, so it no longer depends on
  the patched Launch.

Tested: NGServer MCPC+ 1.6.4 boots to Done and stops cleanly on JDK 17.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DszbR9jSTnJF2dtbGNiQRv
ASM 4.1 cannot read Java 8+ bytecode nor run coremods written against a
recent ASM API, so mods built for Java 8 could not load. The agent now
ships ASM 9.7 and serves its classes in place of ASM 4 ones when the
server uses ASM 4 (servers already on ASM 5+ keep theirs). The ASM 4
class patches are superseded and removed.

The bundled ASM is adapted at build time so Forge 1.6.4 and ASM 4 era
code keep working:
- Remapping*Adapter classes, removed after ASM 7.0, come from ASM 7.0.
- Type.getType(String) accepts internal names, as ASM 4 did
  (Forge's EventTransformer).
- Visitors declared with the ASM 4 API no longer throw 'requires ASMx'
  on newer bytecode (FML's mod parser), and the interface flag of method
  calls survives them (LegacyAsmApi).

LaunchClassLoader delegates org.objectweb.asm to the application class
loader so a single ASM is used.

Tested on JDK 17 with a Java 8 mod + ASM9 coremod: stock MCPC+ 1.6.4 and
the NGServer build (with ASM 4 or ASM 9 in libraries) boot to Done with
the mod active and no FML errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DszbR9jSTnJF2dtbGNiQRv
Builds the jar on every push and pull request (downloadable as a workflow
artifact), and attaches it to a GitHub release when a v* tag is pushed.
Make gradlew executable so the wrapper runs in CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DszbR9jSTnJF2dtbGNiQRv
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DszbR9jSTnJF2dtbGNiQRv
@augmentcode

augmentcode Bot commented Sep 24, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: Migrates the MCPC+/Cauldron startup agent from Java 8 support to Java 17 support.

Changes:

  • Renames the artifact, packages, manifest entry point, logs, and documentation to mcpc-java17-agent.
  • Spoofs the legacy Java 7 version expected by the MCPC+ launch check.
  • Replaces the legacy launchwrapper entry point when needed and derives URLs from java.class.path.
  • Configures the launch class loader to delegate platform-module packages and the bundled ASM implementation.
  • Opens JDK modules and removes reflection filters needed by Forge enum mutation code.
  • Redirects removed sun.reflect APIs to agent-provided constructor and field accessor shims.
  • Bundles ASM 9.7, patches legacy ASM API behavior, and retains Forge-required remapping adapters.
  • Adds a Gradle task that rewrites selected ASM classes before packaging the executable agent JAR.
  • Adds GitHub Actions build, artifact upload, and tag-triggered release publishing.
Technical notes: The agent preserves a server-provided modern ASM or launchwrapper where its compatibility checks allow it; it requires JDK 17+.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

private boolean needsPatch(ClassLoader loader, String className, byte[] original) {
if (className.equals(LAUNCH)) {
// The stock constructor casts the application class loader to URLClassLoader.
return indexOf(original, "java/net/URLClassLoader".getBytes(StandardCharsets.US_ASCII)) >= 0;

@augmentcode augmentcode Bot Sep 24, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not identify the cast described in the comment; it matches any URLClassLoader constant. A Java-9-ready Launch that still uses URLClassLoader elsewhere will be replaced wholesale by the bundled 1.8 class, discarding its server-specific behavior instead of being kept.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

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.

2 participants