From 24cdb165660e1b9f801536f4a5f653434ca028bb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Feb 2026 14:02:51 +0000 Subject: [PATCH 1/3] Bump org.junit:junit-bom from 5.13.4 to 6.0.3 Bumps [org.junit:junit-bom](https://github.com/junit-team/junit-framework) from 5.13.4 to 6.0.3. - [Release notes](https://github.com/junit-team/junit-framework/releases) - [Commits](https://github.com/junit-team/junit-framework/compare/r5.13.4...r6.0.3) --- updated-dependencies: - dependency-name: org.junit:junit-bom dependency-version: 6.0.3 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f3b3e9a9..9f9a4b41 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -27,7 +27,7 @@ kotlinpoet-core = { module = "com.squareup:kotlinpoet", version.ref = "kotlinpoe kotlinpoet-metadata = { module = "com.squareup:kotlinpoet-metadata", version.ref = "kotlinpoet" } kotlinpoet-ksp = { module = "com.squareup:kotlinpoet-ksp", version.ref = "kotlinpoet" } -junit-bom = "org.junit:junit-bom:5.13.4" +junit-bom = "org.junit:junit-bom:6.0.3" junit-jupiter = { module = "org.junit.jupiter:junit-jupiter" } junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher" } From 10dba31a4f1f892d815b2178633e167c4ec8a13e Mon Sep 17 00:00:00 2001 From: Nicklas Ansman Date: Sun, 26 Apr 2026 14:00:11 -0400 Subject: [PATCH 2/3] Fix Kotlin 2.3 compatibility --- api/src/main/kotlin/se/ansman/kotshi/KotshiUtils.kt | 9 ++++++--- compiler/build.gradle.kts | 13 +++++++------ .../kotshi/renderer/DataClassAdapterRenderer.kt | 10 +++++----- gradle-plugin/src/main/kotlin/library.gradle.kts | 3 ++- gradle/libs.versions.toml | 5 ++++- .../kotlin/se/ansman/kotshi/BaseGeneratorTest.kt | 8 ++++---- 6 files changed, 28 insertions(+), 20 deletions(-) diff --git a/api/src/main/kotlin/se/ansman/kotshi/KotshiUtils.kt b/api/src/main/kotlin/se/ansman/kotshi/KotshiUtils.kt index 30c9c8bd..c8820bb4 100644 --- a/api/src/main/kotlin/se/ansman/kotshi/KotshiUtils.kt +++ b/api/src/main/kotlin/se/ansman/kotshi/KotshiUtils.kt @@ -138,8 +138,11 @@ object KotshiUtils { override fun invoke(proxy: Any, method: Method, args: Array?): Any = when (method.name) { "annotationType" -> this@createJsonQualifierImplementation - "equals" -> args!![0] === proxy || isInstance(args!![0]) && annotationMethods.all { m -> - annotationValuesEquals(m.invoke(args[0]), annotationArguments[m.name] ?: m.defaultValue) + "equals" -> { + val other = args?.get(0) + other === proxy || isInstance(other) && annotationMethods.all { m -> + annotationValuesEquals(m.invoke(other), annotationArguments[m.name] ?: m.defaultValue) + } } // For the implementation see https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/annotation/Annotation.html#hashCode() "hashCode" -> annotationMethods.sumOf { m -> @@ -261,4 +264,4 @@ object KotshiUtils { throw JsonDataException("Expected $typeMessage but was $it at path $path") } } -} \ No newline at end of file +} diff --git a/compiler/build.gradle.kts b/compiler/build.gradle.kts index a6d17f38..e905d209 100644 --- a/compiler/build.gradle.kts +++ b/compiler/build.gradle.kts @@ -4,16 +4,17 @@ plugins { } dependencies { - compileOnly(libs.auto.service.api) - compileOnly(libs.ksp.api) - implementation(projects.api) + implementation(libs.auto.service.api) + kapt(libs.auto.service.compiler) + implementation(libs.incap.api) + kapt(libs.incap.compiler) + implementation(libs.auto.common) implementation(libs.kotlinpoet.core) implementation(libs.kotlinpoet.metadata) implementation(libs.kotlinpoet.ksp) implementation(libs.kotlin.metadata) implementation(libs.oldestSupportedMoshi) + implementation(libs.ksp.api) implementation(libs.asm) - - kapt(libs.auto.service.compiler) -} \ No newline at end of file +} diff --git a/compiler/src/main/kotlin/se/ansman/kotshi/renderer/DataClassAdapterRenderer.kt b/compiler/src/main/kotlin/se/ansman/kotshi/renderer/DataClassAdapterRenderer.kt index 8a9eb1d9..7cd77c98 100644 --- a/compiler/src/main/kotlin/se/ansman/kotshi/renderer/DataClassAdapterRenderer.kt +++ b/compiler/src/main/kotlin/se/ansman/kotshi/renderer/DataClassAdapterRenderer.kt @@ -348,7 +348,7 @@ class DataClassAdapterRenderer( if (hasDefaultValueConstructor) { val allMasksAreSetBlock = maskNames.withIndex() .map { (index, maskName) -> - CodeBlock.of("$maskName·== 0x${Integer.toHexString(maskAllSetValues[index])}.toInt()") + CodeBlock.of("$maskName·== %L", maskAllSetValues[index]) } .joinToCode("·&& ") beginControlFlow("if (%L)", allMasksAreSetBlock) @@ -488,7 +488,7 @@ class DataClassAdapterRenderer( } else if (hasDefaultValue) { CodeBlock.builder() .add("// \$mask = \$mask and (1 shl %L).inv()\n", maskIndex) - .addStatement("%1L = %1L and 0x%2L.toInt()", maskName, Integer.toHexString(mask.inv())) + .addStatement("%1L = %1L and %2L", maskName, mask.inv()) .build() } else { null @@ -496,14 +496,14 @@ class DataClassAdapterRenderer( isSet = if (localIsSet != null) { CodeBlock.of("%N", localIsSet) } else if (hasDefaultValue) { - CodeBlock.of("%1L and 0x%2L.toInt() != 0", maskName, Integer.toHexString(mask)) + CodeBlock.of("%1L and %2L != 0", maskName, mask) } else { CodeBlock.of("%N != null", value) }, isNotSet = if (localIsSet != null) { CodeBlock.of("!%N", localIsSet) } else if (hasDefaultValue) { - CodeBlock.of("%1L and 0x%2L.toInt() == 0", maskName, Integer.toHexString(mask)) + CodeBlock.of("%1L and %2L == 0", maskName, mask) } else { CodeBlock.of("%N == null", value) }, @@ -642,4 +642,4 @@ private fun AsmType.toReflectionString(): String = // Object type else -> className } - } \ No newline at end of file + } diff --git a/gradle-plugin/src/main/kotlin/library.gradle.kts b/gradle-plugin/src/main/kotlin/library.gradle.kts index 6a34aa76..e4f83a9c 100644 --- a/gradle-plugin/src/main/kotlin/library.gradle.kts +++ b/gradle-plugin/src/main/kotlin/library.gradle.kts @@ -1,5 +1,6 @@ import org.gradle.accessors.dm.LibrariesForLibs +import org.jetbrains.kotlin.gradle.dsl.JvmDefaultMode import org.jetbrains.kotlin.gradle.dsl.JvmTarget plugins { @@ -19,11 +20,11 @@ extensions.configure { kotlin { compilerOptions { jvmTarget.set(JvmTarget.JVM_1_8) + jvmDefault.set(JvmDefaultMode.NO_COMPATIBILITY) allWarningsAsErrors.set(true) freeCompilerArgs.addAll( "-Xsuppress-version-warnings", "-opt-in=kotlin.RequiresOptIn", - "-Xjvm-default=all", "-Xcontext-parameters", "-Xannotation-default-target=param-property", ) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9f9a4b41..f9780c3b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -40,6 +40,9 @@ moshi-latest = { module = "com.squareup.moshi:moshi", version.ref = "moshi-lates findBugs = "com.google.code.findbugs:jsr305:3.0.2" +incap-api = { module = "net.ltgt.gradle.incap:incap", version.ref = "incap" } +incap-compiler = { module = "net.ltgt.gradle.incap:incap-processor", version.ref = "incap" } + ksp = { module = "com.google.devtools.ksp:symbol-processing", version.ref = "ksp" } ksp-api = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" } ksp-commonDeps = { module = "com.google.devtools.ksp:symbol-processing-common-deps", version.ref = "ksp" } @@ -47,4 +50,4 @@ ksp-aaEmbeddable = { module = "com.google.devtools.ksp:symbol-processing-aa-embe asm = "org.ow2.asm:asm:9.9.1" -gradleMavenPublish = "com.vanniktech.maven.publish:com.vanniktech.maven.publish.gradle.plugin:0.36.0" \ No newline at end of file +gradleMavenPublish = "com.vanniktech.maven.publish:com.vanniktech.maven.publish.gradle.plugin:0.36.0" diff --git a/tests/src/test/kotlin/se/ansman/kotshi/BaseGeneratorTest.kt b/tests/src/test/kotlin/se/ansman/kotshi/BaseGeneratorTest.kt index d006d1ec..31273a15 100644 --- a/tests/src/test/kotlin/se/ansman/kotshi/BaseGeneratorTest.kt +++ b/tests/src/test/kotlin/se/ansman/kotshi/BaseGeneratorTest.kt @@ -554,14 +554,14 @@ abstract class BaseGeneratorTest { } @Test - fun `non data object does not logs warnings when using Kotlin 1_8`() { + fun `language version 1_8 is rejected`() { val source = kotlin("source.kt", """ @se.ansman.kotshi.JsonSerializable object TestObject """) val result = compile(source, languageVersion = "1.8") - assertThat(result::exitCode).isEqualTo(KotlinCompilation.ExitCode.OK) - assertThat(result::messages).doesNotContain(Errors.nonDataObject) + assertThat(result::exitCode).isEqualTo(KotlinCompilation.ExitCode.COMPILATION_ERROR) + assertThat(result::messages).contains("Language version 1.8 is no longer supported") } @Test @@ -602,4 +602,4 @@ abstract class BaseGeneratorTest { .first { it.name == name } .readText() .trim() -} \ No newline at end of file +} From 093404dfa604fa8c9993fd209de78307469bcdf9 Mon Sep 17 00:00:00 2001 From: Nicklas Ansman Date: Sun, 26 Apr 2026 14:06:17 -0400 Subject: [PATCH 3/3] Fix JUnit 6 test resolution --- gradle-plugin/src/main/kotlin/library.gradle.kts | 5 +++++ tests/src/test/kotlin/se/ansman/kotshi/BaseGeneratorTest.kt | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/gradle-plugin/src/main/kotlin/library.gradle.kts b/gradle-plugin/src/main/kotlin/library.gradle.kts index e4f83a9c..1a38fead 100644 --- a/gradle-plugin/src/main/kotlin/library.gradle.kts +++ b/gradle-plugin/src/main/kotlin/library.gradle.kts @@ -1,5 +1,6 @@ import org.gradle.accessors.dm.LibrariesForLibs +import org.gradle.api.attributes.java.TargetJvmVersion import org.jetbrains.kotlin.gradle.dsl.JvmDefaultMode import org.jetbrains.kotlin.gradle.dsl.JvmTarget @@ -74,3 +75,7 @@ configurations.configureEach { } } } + +configurations.matching { it.name == "testCompileClasspath" || it.name == "testRuntimeClasspath" }.configureEach { + attributes.attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21) +} diff --git a/tests/src/test/kotlin/se/ansman/kotshi/BaseGeneratorTest.kt b/tests/src/test/kotlin/se/ansman/kotshi/BaseGeneratorTest.kt index 31273a15..930bf930 100644 --- a/tests/src/test/kotlin/se/ansman/kotshi/BaseGeneratorTest.kt +++ b/tests/src/test/kotlin/se/ansman/kotshi/BaseGeneratorTest.kt @@ -554,14 +554,14 @@ abstract class BaseGeneratorTest { } @Test - fun `language version 1_8 is rejected`() { + fun `non data object does not logs warnings when using Kotlin 1_8`() { val source = kotlin("source.kt", """ @se.ansman.kotshi.JsonSerializable object TestObject """) val result = compile(source, languageVersion = "1.8") - assertThat(result::exitCode).isEqualTo(KotlinCompilation.ExitCode.COMPILATION_ERROR) - assertThat(result::messages).contains("Language version 1.8 is no longer supported") + assertThat(result::exitCode).isEqualTo(KotlinCompilation.ExitCode.OK) + assertThat(result::messages).doesNotContain(Errors.nonDataObject) } @Test