diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 1a6692f3b..30416679b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,15 +4,15 @@ asm = "9.6" commons-io = "2.15.0" gson = "2.10.1" jackson = "2.16.0" -guava = "32.1.3-jre" +guava = "33.0.0-jre" stitch = "0.6.2" -tiny-remapper = "0.8.11" +tiny-remapper = "0.9.0" access-widener = "2.1.0" -mapping-io = "0.5.0" +mapping-io = "0.5.1" lorenz-tiny = "4.0.2" mercury = "0.4.1" -kotlinx-metadata = "0.7.0" +kotlinx-metadata = "0.8.0" # Plugins spotless = "6.20.0" diff --git a/gradle/test.libs.versions.toml b/gradle/test.libs.versions.toml index 3bca2dd8b..f01ff02cc 100644 --- a/gradle/test.libs.versions.toml +++ b/gradle/test.libs.versions.toml @@ -6,7 +6,7 @@ mockito = "5.7.0" java-debug = "0.49.0" mixin = "0.11.4+mixin.0.8.5" -gradle-nightly = "8.6-20231118001259+0000" +gradle-nightly = "8.6-20231219002119+0000" fabric-loader = "0.14.24" fabric-installer = "0.11.1" diff --git a/src/main/java/net/fabricmc/loom/kotlin/remapping/KotlinClassMetadataWrapper.java b/src/main/java/net/fabricmc/loom/kotlin/remapping/KotlinClassMetadataWrapper.java deleted file mode 100644 index 2a6238a97..000000000 --- a/src/main/java/net/fabricmc/loom/kotlin/remapping/KotlinClassMetadataWrapper.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This file is part of fabric-loom, licensed under the MIT License (MIT). - * - * Copyright (c) 2023 FabricMC - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package net.fabricmc.loom.kotlin.remapping; - -import kotlin.Metadata; -import kotlinx.metadata.jvm.KotlinClassMetadata; - -/** - * Similar story to JvmExtensionWrapper, lets abuse the fact that Java can call "internal" Kotlin APIs without reflection :). - */ -public record KotlinClassMetadataWrapper(KotlinClassMetadata metadata) { - public Metadata getAnnotationData() { - return metadata.getAnnotationData$kotlinx_metadata_jvm(); - } -} diff --git a/src/main/kotlin/net/fabricmc/loom/kotlin/remapping/KotlinClassMetadataRemappingAnnotationVisitor.kt b/src/main/kotlin/net/fabricmc/loom/kotlin/remapping/KotlinClassMetadataRemappingAnnotationVisitor.kt index 56ce489e6..8b5296048 100644 --- a/src/main/kotlin/net/fabricmc/loom/kotlin/remapping/KotlinClassMetadataRemappingAnnotationVisitor.kt +++ b/src/main/kotlin/net/fabricmc/loom/kotlin/remapping/KotlinClassMetadataRemappingAnnotationVisitor.kt @@ -56,11 +56,11 @@ class KotlinClassMetadataRemappingAnnotationVisitor(private val remapper: Remapp logger.info("Kotlin metadata for class ($className) as it was built using a different major Kotlin version (${header.metadataVersion[0]}.${header.metadataVersion[1]}.x) while the remapper is using (${KotlinVersion.CURRENT}).") } - when (val metadata = KotlinClassMetadata.read(header)) { + when (val metadata = KotlinClassMetadata.readLenient(header)) { is KotlinClassMetadata.Class -> { var klass = metadata.kmClass klass = KotlinClassRemapper(remapper).remap(klass) - val remapped = KotlinClassMetadata.writeClass(klass, header.metadataVersion, header.extraInt) + val remapped = KotlinClassMetadata.Class(klass, metadata.version, metadata.flags).write() writeClassHeader(remapped) validateKotlinClassHeader(remapped, header) } @@ -69,7 +69,7 @@ class KotlinClassMetadataRemappingAnnotationVisitor(private val remapper: Remapp if (klambda != null) { klambda = KotlinClassRemapper(remapper).remap(klambda) - val remapped = KotlinClassMetadata.writeLambda(klambda, header.metadataVersion, header.extraInt) + val remapped = KotlinClassMetadata.SyntheticClass(klambda, metadata.version, metadata.flags).write() writeClassHeader(remapped) validateKotlinClassHeader(remapped, header) } else { @@ -79,15 +79,14 @@ class KotlinClassMetadataRemappingAnnotationVisitor(private val remapper: Remapp is KotlinClassMetadata.FileFacade -> { var kpackage = metadata.kmPackage kpackage = KotlinClassRemapper(remapper).remap(kpackage) - val remapped = KotlinClassMetadata.writeFileFacade(kpackage, header.metadataVersion, header.extraInt) + val remapped = KotlinClassMetadata.FileFacade(kpackage, metadata.version, metadata.flags).write() writeClassHeader(remapped) validateKotlinClassHeader(remapped, header) } is KotlinClassMetadata.MultiFileClassPart -> { var kpackage = metadata.kmPackage kpackage = KotlinClassRemapper(remapper).remap(kpackage) - val wrapper = KotlinClassMetadataWrapper(metadata) - val remapped = KotlinClassMetadata.writeMultiFileClassPart(kpackage, metadata.facadeClassName, wrapper.annotationData.metadataVersion, wrapper.annotationData.extraInt) + val remapped = KotlinClassMetadata.MultiFileClassPart(kpackage, metadata.facadeClassName, metadata.version, metadata.flags).write() writeClassHeader(remapped) validateKotlinClassHeader(remapped, header) } diff --git a/src/test/groovy/net/fabricmc/loom/test/unit/kotlin/KotlinRemapperClassloaderTest.groovy b/src/test/groovy/net/fabricmc/loom/test/unit/kotlin/KotlinRemapperClassloaderTest.groovy index f832df5ed..98b4042a7 100644 --- a/src/test/groovy/net/fabricmc/loom/test/unit/kotlin/KotlinRemapperClassloaderTest.groovy +++ b/src/test/groovy/net/fabricmc/loom/test/unit/kotlin/KotlinRemapperClassloaderTest.groovy @@ -24,6 +24,7 @@ package net.fabricmc.loom.test.unit.kotlin +import kotlin.KotlinVersion import org.objectweb.asm.ClassReader import org.objectweb.asm.tree.ClassNode import spock.lang.Specification @@ -36,7 +37,7 @@ import net.fabricmc.tinyremapper.api.TrEnvironment import net.fabricmc.tinyremapper.api.TrRemapper class KotlinRemapperClassloaderTest extends Specification { - private static String KOTLIN_VERSION = "1.6.10" + private static String KOTLIN_VERSION = KotlinVersion.CURRENT.toString() private static String KOTLIN_METADATA_VERSION = KotlinPluginUtils.kotlinMetadataVersion private static String KOTLIN_URL = "https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/${KOTLIN_VERSION}/kotlin-stdlib-${KOTLIN_VERSION}.jar" private static String KOTLIN_METADATA_URL = "https://repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-metadata-jvm/${KOTLIN_METADATA_VERSION}/kotlinx-metadata-jvm-${KOTLIN_METADATA_VERSION}.jar"