Skip to content

Commit

Permalink
Update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
modmuss50 committed Feb 24, 2024
1 parent cfba0b1 commit 9ba5d23
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 43 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/test-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ jobs:
TEST_WARNING_MODE: fail
id: test

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: ${{ steps.test.outputs.test }} Results
path: build/reports/
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: ${{ steps.test.outputs.test }} Heap Dump
Expand Down Expand Up @@ -107,12 +107,12 @@ jobs:
TEST_WARNING_MODE: fail
id: test

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: ${{ steps.test.outputs.test }} (${{ matrix.java }}) Results (Windows)
path: build/reports/
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: ${{ steps.test.outputs.test }} Heap Dump (Windows)
Expand All @@ -125,8 +125,8 @@ jobs:
strategy:
fail-fast: false
matrix:
java: [ 17, 20 ]
os: [ windows-2022, ubuntu-22.04, macos-12 ]
java: [ 17, 21 ]
os: [ windows-2022, ubuntu-22.04, macos-14 ]

runs-on: ${{ matrix.os }}
steps:
Expand All @@ -138,7 +138,7 @@ jobs:

- run: ./gradlew test --tests *ReproducibleBuildTest --stacktrace --warning-mode fail

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: Reproducible Build ${{ matrix.os }} (${{ matrix.java }}) Results
Expand Down
7 changes: 7 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,13 @@ checkstyle {
toolVersion = libs.versions.checkstyle.get()
}

// Workaround https://github.com/gradle/gradle/issues/27035
configurations.checkstyle {
resolutionStrategy.capabilitiesResolution.withCapability("com.google.collections:google-collections") {
select("com.google.guava:guava:0")
}
}

codenarc {
toolVersion = libs.versions.codenarc.get()
configFile = file("codenarc.groovy")
Expand Down
8 changes: 4 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ gson = "2.10.1"
guava = "33.0.0-jre"

stitch = "0.6.2"
tiny-remapper = "0.10.0"
tiny-remapper = "0.10.1"
access-widener = "2.1.0"
mapping-io = "0.5.1"
lorenz-tiny = "4.0.2"
mercury = "0.4.1"
kotlinx-metadata = "0.9.0"

# Plugins
spotless = "6.20.0"
spotless = "6.25.0"
test-retry = "1.5.6"
checkstyle = "10.12.5"
codenarc = "3.3.0"
checkstyle = "10.13.0"
codenarc = "3.4.0"
jacoco = "0.8.11"

[libraries]
Expand Down
2 changes: 1 addition & 1 deletion gradle/runtime.libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
# Decompilers
fernflower = "2.0.0"
cfr = "0.2.1"
cfr = "0.2.2"
vineflower = "1.9.3"

# Runtime depedencies
Expand Down
14 changes: 7 additions & 7 deletions gradle/test.libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[versions]
spock = "2.3-groovy-3.0"
junit = "5.10.1"
javalin = "5.6.3"
mockito = "5.8.0"
java-debug = "0.50.0"
mixin = "0.11.4+mixin.0.8.5"
junit = "5.10.2"
javalin = "6.1.0"
mockito = "5.10.0"
java-debug = "0.51.0"
mixin = "0.12.5+mixin.0.8.5"

gradle-nightly = "8.7-20240202001338+0000"
fabric-loader = "0.15.3"
gradle-nightly = "8.8-20240224001421+0000"
fabric-loader = "0.15.6"
fabric-installer = "1.0.0"

[libraries]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,19 @@ import org.objectweb.asm.commons.Remapper
import org.objectweb.asm.tree.AnnotationNode
import org.slf4j.LoggerFactory

class KotlinClassMetadataRemappingAnnotationVisitor(private val remapper: Remapper, val next: AnnotationVisitor, val className: String?) :
class KotlinClassMetadataRemappingAnnotationVisitor(
private val remapper: Remapper,
val next: AnnotationVisitor,
val className: String?,
) :
AnnotationNode(Opcodes.ASM9, KotlinMetadataRemappingClassVisitor.ANNOTATION_DESCRIPTOR) {

private val logger = LoggerFactory.getLogger(javaClass)

private var _name: String? = null

override fun visit(name: String?, value: Any?) {
override fun visit(
name: String?,
value: Any?,
) {
super.visit(name, value)
this._name = name
}

override fun visitEnd() {
Expand All @@ -53,7 +56,11 @@ class KotlinClassMetadataRemappingAnnotationVisitor(private val remapper: Remapp
val currentMinorVersion = KotlinVersion(KotlinVersion.CURRENT.major, KotlinVersion.CURRENT.minor, 0)

if (headerVersion != currentMinorVersion) {
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}).")
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.readLenient(header)) {
Expand Down Expand Up @@ -86,7 +93,13 @@ class KotlinClassMetadataRemappingAnnotationVisitor(private val remapper: Remapp
is KotlinClassMetadata.MultiFileClassPart -> {
var kpackage = metadata.kmPackage
kpackage = KotlinClassRemapper(remapper).remap(kpackage)
val remapped = KotlinClassMetadata.MultiFileClassPart(kpackage, metadata.facadeClassName, metadata.version, metadata.flags).write()
val remapped =
KotlinClassMetadata.MultiFileClassPart(
kpackage,
metadata.facadeClassName,
metadata.version,
metadata.flags,
).write()
writeClassHeader(remapped)
validateKotlinClassHeader(remapped, header)
}
Expand Down Expand Up @@ -147,10 +160,17 @@ class KotlinClassMetadataRemappingAnnotationVisitor(private val remapper: Remapp
newNode.accept(next)
}

private fun validateKotlinClassHeader(remapped: Metadata, original: Metadata) {
// This can happen when the remapper is ran on a kotlin version that does not match the version the class was compiled with.
private fun validateKotlinClassHeader(
remapped: Metadata,
original: Metadata,
) {
// This can happen when the remapper is ran on a kotlin version
// that does not match the version the class was compiled with.
if (remapped.data2.size != original.data2.size) {
logger.info("Kotlin class metadata size mismatch: data2 size does not match original in class $className. New: ${remapped.data2.size} Old: ${original.data2.size}")
logger.info(
"Kotlin class metadata size mismatch: data2 size does not match original in class $className. " +
"New: ${remapped.data2.size} Old: ${original.data2.size}",
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,12 @@ class KotlinClassRemapper(private val remapper: Remapper) {
}

private fun remap(type: KmType): KmType {
type.classifier = when (val classifier = type.classifier) {
is KmClassifier.Class -> KmClassifier.Class(remap(classifier.name))
is KmClassifier.TypeParameter -> KmClassifier.TypeParameter(classifier.id)
is KmClassifier.TypeAlias -> KmClassifier.TypeAlias(remap(classifier.name))
}
type.classifier =
when (val classifier = type.classifier) {
is KmClassifier.Class -> KmClassifier.Class(remap(classifier.name))
is KmClassifier.TypeParameter -> KmClassifier.TypeParameter(classifier.id)
is KmClassifier.TypeAlias -> KmClassifier.TypeAlias(remap(classifier.name))
}
type.arguments.replaceAll(this::remap)
type.abbreviatedType = type.abbreviatedType?.let { remap(it) }
type.outerType = type.outerType?.let { remap(it) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ class KotlinMetadataRemappingClassVisitor(private val remapper: Remapper, next:
super.visit(version, access, name, signature, superName, interfaces)
}

override fun visitAnnotation(descriptor: String, visible: Boolean): AnnotationVisitor? {
override fun visitAnnotation(
descriptor: String,
visible: Boolean,
): AnnotationVisitor? {
var result: AnnotationVisitor? = super.visitAnnotation(descriptor, visible)

if (descriptor == ANNOTATION_DESCRIPTOR && result != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ import net.fabricmc.tinyremapper.api.TrClass
import org.objectweb.asm.ClassVisitor

object KotlinMetadataTinyRemapperExtensionImpl : KotlinMetadataTinyRemapperExtension {
override fun insertApplyVisitor(cls: TrClass, next: ClassVisitor?): ClassVisitor {
override fun insertApplyVisitor(
cls: TrClass,
next: ClassVisitor?,
): ClassVisitor {
return KotlinMetadataRemappingClassVisitor(cls.environment.remapper, next)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ class KotlinClassMetadataRemappingAnnotationVisitorTest {

val classReader = ClassReader(inputPosInChunk)

val tinyRemapper = TinyRemapper.newRemapper()
.withMappings(readMappings("PosInChunk"))
.build()
val tinyRemapper =
TinyRemapper.newRemapper()
.withMappings(readMappings("PosInChunk"))
.build()

val inputWriter = StringWriter()
classReader.accept(stringWriterVisitor(inputWriter), 0)
Expand All @@ -77,9 +78,10 @@ class KotlinClassMetadataRemappingAnnotationVisitorTest {
val input = getClassBytes("TestExtensionKt")
val classReader = ClassReader(input)

val tinyRemapper = TinyRemapper.newRemapper()
.withMappings(readMappings("TestExtensionKt"))
.build()
val tinyRemapper =
TinyRemapper.newRemapper()
.withMappings(readMappings("TestExtensionKt"))
.build()

val inputWriter = StringWriter()
classReader.accept(stringWriterVisitor(inputWriter), 0)
Expand Down

0 comments on commit 9ba5d23

Please sign in to comment.