Skip to content

Commit

Permalink
KAPT: Run tests on JDK 21
Browse files Browse the repository at this point in the history
Previously, some tests have also been disabled on JDK 11+, since
we did not filter out empty filesets, which led to failed assertion
inside JDK.
 #KT-57389
  • Loading branch information
ilmirus committed Nov 22, 2023
1 parent 120c99d commit 705c804
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ fun main(args: Array<String>) {
model("kotlinRunner")
}

testClass<AbstractIrKotlinKaptContextTest>(annotations = annotations) {
testClass<AbstractIrKotlinKaptContextTest> {
model("kotlinRunner")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ fun KaptContext.parseJavaFiles(javaSourceFiles: List<File>): JavacList<JCTree.JC
}

private fun KaptContext.initModulesIfNeeded(files: JavacList<JCTree.JCCompilationUnit>): JavacList<JCTree.JCCompilationUnit> {
if (isJava9OrLater()) {
if (files.isNotEmpty() && isJava9OrLater()) {
val initModulesMethod = compiler.javaClass.getMethod("initModules", JavacList::class.java)

@Suppress("UNCHECKED_CAST")
Expand Down
1 change: 1 addition & 0 deletions plugins/kapt3/kapt3-compiler/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ testsJar {}
kaptTestTask("test", JavaLanguageVersion.of(8))
kaptTestTask("testJdk11", JavaLanguageVersion.of(11))
kaptTestTask("testJdk17", JavaLanguageVersion.of(17))
kaptTestTask("testJdk21", JavaLanguageVersion.of(21))

fun Project.kaptTestTask(name: String, javaLanguageVersion: JavaLanguageVersion) {
val service = extensions.getByType<JavaToolchainService>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.jetbrains.kotlin.kapt3.test.KaptRegularExtensionForTestConfigurator
import org.jetbrains.kotlin.kapt3.test.KaptTestDirectives.MAP_DIAGNOSTIC_LOCATIONS
import org.jetbrains.kotlin.kapt3.test.KaptTestDirectives.USE_JVM_IR
import org.jetbrains.kotlin.kapt3.test.handlers.ClassFileToSourceKaptStubHandler
import org.jetbrains.kotlin.kapt3.util.doOpenInternalPackagesIfRequired
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
import org.jetbrains.kotlin.test.TargetBackend
import org.jetbrains.kotlin.test.backend.BlackBoxCodegenSuppressor
Expand All @@ -26,6 +27,10 @@ import org.jetbrains.kotlin.test.services.configuration.JvmEnvironmentConfigurat
abstract class AbstractClassFileToSourceStubConverterTestBase(
targetBackend: TargetBackend
) : AbstractKotlinCompilerWithTargetBackendTest(targetBackend) {
init {
doOpenInternalPackagesIfRequired()
}

override fun TestConfigurationBuilder.configuration() {
globalDefaults {
frontend = FrontendKinds.ClassicFrontend
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package org.jetbrains.kotlin.kapt3.test.runners

import org.jetbrains.kotlin.kapt3.util.doOpenInternalPackagesIfRequired
import org.jetbrains.kotlin.kapt3.test.*
import org.jetbrains.kotlin.kapt3.test.KaptTestDirectives.MAP_DIAGNOSTIC_LOCATIONS
import org.jetbrains.kotlin.kapt3.test.handlers.KaptContextHandler
Expand All @@ -20,6 +21,10 @@ import org.jetbrains.kotlin.test.services.configuration.JvmEnvironmentConfigurat
abstract class AbstractKotlinKaptContextTestBase(
targetBackend: TargetBackend
) : AbstractKotlinCompilerWithTargetBackendTest(targetBackend) {
init {
doOpenInternalPackagesIfRequired()
}

override fun TestConfigurationBuilder.configuration() {
globalDefaults {
frontend = FrontendKinds.ClassicFrontend
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions plugins/kapt4/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ testsJar {}
kaptTestTask("test", JavaLanguageVersion.of(8))
kaptTestTask("testJdk11", JavaLanguageVersion.of(11))
kaptTestTask("testJdk17", JavaLanguageVersion.of(17))
kaptTestTask("testJdk21", JavaLanguageVersion.of(21))

fun Project.kaptTestTask(name: String, javaLanguageVersion: JavaLanguageVersion) {
val service = extensions.getByType<JavaToolchainService>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package org.jetbrains.kotlin.kapt4

import org.jetbrains.kotlin.kapt3.util.doOpenInternalPackagesIfRequired
import org.jetbrains.kotlin.kapt3.test.*
import org.jetbrains.kotlin.kapt3.test.KaptTestDirectives.MAP_DIAGNOSTIC_LOCATIONS
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
Expand All @@ -22,6 +23,10 @@ open class AbstractKotlinKapt4ContextTest : AbstractKotlinKapt4ContextTestBase(T
abstract class AbstractKotlinKapt4ContextTestBase(
targetBackend: TargetBackend
) : AbstractKotlinCompilerWithTargetBackendTest(targetBackend) {
init {
doOpenInternalPackagesIfRequired()
}

override fun TestConfigurationBuilder.configuration() {
globalDefaults {
frontend = FrontendKinds.FIR
Expand Down

0 comments on commit 705c804

Please sign in to comment.