Commit 8ab1a8a
authored
Fix GraalVM native build error caused by stale substitution target in v8.x (#601)
Fix GraalVM native build error caused by stale substitution target in v8.x
Context
In kotlin-logging v8.x, io.github.oshai.kotlinlogging.internal.KLoggerFactory was moved to io.github.oshai.kotlinlogging.KotlinLoggingConfiguration, but the GraalVM @TargetClass substitution still referenced the old internal class.
When Logback is absent from the native image classpath, the LogbackNotOnClasspath condition activates the substitution — which then fails because the target class no longer exists at that location.
This PR updates the GraalVM substitution to align with the 8.x architecture while preserving core configuration overrides.
Changes
Renamed Target_io_github_oshai_kotlinlogging_internal_KLoggerFactory.kt → Target_io_github_oshai_kotlinlogging_KotlinLoggingConfiguration.kt (following standard naming conventions).
Updated @TargetClass to target the new io.github.oshai.kotlinlogging.KotlinLoggingConfiguration class.
Substituted detectLogger() (instead of the old logger method) to bypass LogbackLoggerFactory initialization when Logback is missing. This prevents GraalVM static analysis from failing on missing Logback imports (like LoggerContext).
Preserved JVM System Property Overrides: The substituted detectLogger() method correctly retains support for both the kotlin-logging-to-jul and kotlin-logging-to-direct system property overrides, as both JulLoggerFactory and DirectLoggerFactory (residing in commonMain) are completely safe for GraalVM to resolve even when Logback is absent.
Verification
Ran ./gradlew jvmTest to verify SLF4J/JUL fallback paths pass successfully.
Ran ./gradlew logbackTest to verify standard paths when Logback is present pass successfully.1 parent b1eb9fc commit 8ab1a8a
1 file changed
Lines changed: 10 additions & 7 deletions
File tree
- src/jvmMain/kotlin/io/github/oshai/kotlinlogging/internal
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | | - | |
| 20 | + | |
20 | 21 | | |
21 | | - | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | | - | |
27 | | - | |
| 27 | + | |
| 28 | + | |
28 | 29 | | |
29 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
33 | | - | |
| 36 | + | |
34 | 37 | | |
35 | 38 | | |
36 | 39 | | |
| |||
0 commit comments