Skip to content

Conversation

@Johni0702
Copy link
Contributor

With kotlinx-metadata-jvm being promoted to stable in Kotlin 2.0, the kotlin-reflect library now relies on a new service (1), the services file for which wasn't yet present in older KFF versions. And with the Java module system, which ModLauncher uses, merely merging the service file from the newer Kotlin isn't enough, we also need to merge them into KFF's module descriptor.

With kotlinx-metadata-jvm being promoted to stable in Kotlin 2.0, the
kotlin-reflect library now relies on a new service ([1]), the services
file for which wasn't yet present in older KFF versions.
And with the Java module system, which ModLauncher uses, merely merging
the service file from the newer Kotlin isn't enough, we also need to
merge them into KFF's module descriptor.

[1]:
https://github.com/JetBrains/kotlin/blob/4c61b7118f23a090a764a3aa07e4291e50210771/libraries/kotlinx-metadata/jvm/resources/META-INF/services/kotlin.metadata.internal.extensions.MetadataExtensions
@github-actions
Copy link

Test Results

17 files  ±0  17 suites  ±0   11m 19s ⏱️ +13s
90 tests ±0  90 ✅ ±0  0 💤 ±0  0 ❌ ±0 
94 runs  ±0  94 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 8183cc4. ± Comparison against base commit e173100.

Map<String, List<String>> newProvides = newPkgsMeta.descriptor().provides()
.stream().collect(Collectors.toMap(ModuleDescriptor.Provides::service, ModuleDescriptor.Provides::providers));
Map<String, List<String>> mergedProvides = new HashMap<>(orgProvides);
mergedProvides.putAll(newProvides);

Choose a reason for hiding this comment

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

Question: I assume we merge to clear duplicate keys, is there any scenario in which we would want to keep the entries in the "value" (List) of the replaced entry?
i.e. would putAll ever need to merge the preexisting list with the new putted list, for duplicate keys

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, the opposite is true actually, it shouldn't do that because if e.g. the Kotlin which shipped with KFF had a service A with provider A1, which in a later Kotlin version was replaced with provider A2, then it'd be wrong for our list to contain A1 and A2 since A1 won't work any more.

(One might think that there might be a case where KFF itself provides an impl for a Kotlin service, then if Kotlin itself also provides an impl, we'd be hiding KFF's impl. But that's not the case, and except for really old KFF versions, which don't seem to receive any updates any more, KFF's own code is jar-in-jar'd, so would be in a separate module anyway).

@Johni0702 Johni0702 merged commit 3080fb9 into master Jan 31, 2026
37 checks passed
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.

3 participants