diff --git a/integration-testing/build.gradle.kts b/integration-testing/build.gradle.kts index dc68f14d36..78a3e32b65 100644 --- a/integration-testing/build.gradle.kts +++ b/integration-testing/build.gradle.kts @@ -134,6 +134,15 @@ sourceSets { implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion") } } + + create("javaConsumersTest") { + compileClasspath += sourceSets.test.get().runtimeClasspath + runtimeClasspath += sourceSets.test.get().runtimeClasspath + + dependencies { + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion") + } + } } kotlin { @@ -199,6 +208,12 @@ tasks { classpath = sourceSet.runtimeClasspath } + create("javaConsumersTest") { + val sourceSet = sourceSets[name] + testClassesDirs = sourceSet.output.classesDirs + classpath = sourceSet.runtimeClasspath + } + check { dependsOn( "jvmCoreTest", @@ -206,9 +221,10 @@ tasks { "mavenTest", "debugAgentTest", "coreAgentTest", + "javaConsumersTest", ":jpmsTest:check", "smokeTest:build", - "java8Test:check" + "java8Test:check", ) } diff --git a/integration-testing/src/javaConsumersTest/java/RunBlockingJavaTest.java b/integration-testing/src/javaConsumersTest/java/RunBlockingJavaTest.java new file mode 100644 index 0000000000..d657d361cc --- /dev/null +++ b/integration-testing/src/javaConsumersTest/java/RunBlockingJavaTest.java @@ -0,0 +1,20 @@ +import kotlinx.coroutines.BuildersKt; +import kotlinx.coroutines.Dispatchers; +import org.junit.Test; + +public class RunBlockingJavaTest { + Boolean entered = false; + + /** This code will not compile if `runBlocking` doesn't declare `@Throws(InterruptedException::class)` */ + @Test + public void testRunBlocking() { + try { + BuildersKt.runBlocking(Dispatchers.getIO(), (scope, continuation) -> { + entered = true; + return null; + }); + } catch (InterruptedException e) { + } + assert entered; + } +}