fix(whitelist): drop kotlin-reflect via Moshi codegen#5
Merged
Conversation
…f the JAR
Plugin onEnable crashed with:
IllegalStateException: Resource not found in classpath:
gg/grounds/platform/shaded/kotlin/gg.grounds.platform.shaded.kotlin.gg.grounds.platform.shaded.kotlin_builtins
ShadowJar's `relocate("kotlin", "gg.grounds.platform.shaded.kotlin")`
rewrites the path *and content* of every .kotlin_builtins resource,
producing the triple-prefixed garbage path above. Moshi's
KotlinJsonAdapterFactory (via moshi-kotlin) needs kotlin-reflect to
read those resources at runtime, so adapter() throws
ExceptionInInitializerError as soon as the WhitelistApiClient
constructor runs. Whitelist sync never starts; the entire plugin
gets disabled by Paper.
Drop the reflection path entirely:
- swap moshi-kotlin runtime dep for moshi-kotlin-codegen via KSP
- annotate ListResponse + RawEntry with @JsonClass(generateAdapter = true)
- remove KotlinJsonAdapterFactory from the Moshi.Builder
KSP generates ListResponseJsonAdapter at compile time. No
kotlin-reflect on the runtime classpath, so no relocation
landmine. Same external behaviour, just deserialised by generated
code instead of reflective class scanning.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Plugin `onEnable` crashed with:
```
IllegalStateException: Resource not found in classpath:
gg/grounds/platform/shaded/kotlin/gg.grounds.platform.shaded.kotlin.gg.grounds.platform.shaded.kotlin_builtins
```
ShadowJar's `relocate("kotlin", "gg.grounds.platform.shaded.kotlin")` rewrites the path and the content of every `.kotlin_builtins` resource, producing the triple-prefixed garbage path above. Moshi's `KotlinJsonAdapterFactory` (via `moshi-kotlin`) loads those resources via `kotlin-reflect` on first `adapter()` call, throws `ExceptionInInitializerError`, and Paper disables the plugin — whitelist sync never starts.
Fix: drop reflection from the runtime path entirely.
KSP generates `ListResponseJsonAdapter` at compile time → no kotlin-reflect on the runtime classpath → no relocation landmine.
Test plan