Skip to content

Bundle kotlin-reflect so dependents get working Kotlin reflection#16

Open
Chaosgh wants to merge 2 commits into
notKolja:masterfrom
Chaosgh:add-kotlin-reflect
Open

Bundle kotlin-reflect so dependents get working Kotlin reflection#16
Chaosgh wants to merge 2 commits into
notKolja:masterfrom
Chaosgh:add-kotlin-reflect

Conversation

@Chaosgh

@Chaosgh Chaosgh commented Jul 2, 2026

Copy link
Copy Markdown

Problem

InjectLib is loaded first and provides the shared kotlin-stdlib for dependent plugins. When its kotlin.jvm.internal.Reflection class initializes (at InjectLib load time), it fixes the reflection factory based on whether kotlin-reflect is on its classloader. InjectLib ships stdlib but not kotlin-reflect, so the factory is permanently set to "no reflection".

As a result, dependents hit KotlinReflectionNotSupportedError at runtime — even when they shade their own kotlin-reflect, because their copy lives on a child classloader that InjectLib's already-initialized Reflection can't see. On Minecraft 26.1.2 this broke e.g. TransientCore's item serialization (jackson-module-kotlin), cascading to several plugins failing to enable.

Fix

Ship kotlin-reflect alongside kotlin-stdlib-jdk8 (same ${kotlin.version}) so it's shaded into the InjectLib jar. Then InjectLib's Reflection initializes with the reflection factory available, and every dependent gets working Kotlin reflection.

Verified: the built jar now contains kotlin/reflect/jvm/internal/ReflectionFactoryImpl alongside the stdlib.

claude added 2 commits July 3, 2026 00:31
InjectLib provides the shared kotlin-stdlib + inits kotlin.jvm.internal.Reflection
before dependents load. Without reflect here, Reflection's factory is fixed to
'no reflection', so plugins (e.g. TransientCore item serialization via
jackson-module-kotlin) hit KotlinReflectionNotSupportedError even when they shade
their own reflect. Ship reflect alongside stdlib.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Dependents compile against Kotlin 2.3.x; the shared stdlib must be >= theirs.
kotlin.jvm.internal.KotlinGenericDeclaration is a 2.3.20 stdlib class that
kotlin-reflect 2.3.20 references, so stdlib+reflect must both be 2.3.20.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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