Take java 9 modules into account in coroutines debug metadata

reading
 #KT-28237
This commit is contained in:
Ilmir Usmanov
2018-11-20 23:05:50 +03:00
parent bdd1eef39a
commit 1336e8f3e3
6 changed files with 91 additions and 14 deletions
@@ -0,0 +1 @@
usage/some.module.withsome.packages.Test
@@ -0,0 +1 @@
OK
@@ -0,0 +1,3 @@
module usage {
requires kotlin.stdlib;
}
@@ -0,0 +1,21 @@
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "CANNOT_OVERRIDE_INVISIBLE_MEMBER")
package some.module.withsome.packages
import java.lang.RuntimeException
import kotlin.coroutines.intrinsics.suspendCoroutineUninterceptedOrReturn
import kotlin.coroutines.jvm.internal.BaseContinuationImpl
suspend fun dummy() {}
class Test {
suspend fun getStackTraceElement(): StackTraceElement {
dummy() // to force state-machine generation
return suspendCoroutineUninterceptedOrReturn<StackTraceElement> {
(it as BaseContinuationImpl).getStackTraceElement()
}
}
}
suspend fun main() {
println(Test().getStackTraceElement().className)
}
@@ -1,26 +1,17 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.jvm.compiler
import com.intellij.openapi.util.io.FileUtil
import junit.framework.TestCase
import org.jetbrains.kotlin.cli.AbstractCliTest
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
import org.jetbrains.kotlin.test.KotlinTestUtils
import java.io.File
import java.util.concurrent.TimeUnit
import java.util.jar.Manifest
class Java9ModulesIntegrationTest : AbstractKotlinCompilerIntegrationTest() {
@@ -251,4 +242,21 @@ class Java9ModulesIntegrationTest : AbstractKotlinCompilerIntegrationTest() {
)
module("usage", additionalKotlinArguments = listOf("-no-stdlib", buildFile))
}
fun testCoroutinesDebugMetadata() {
val jar = module("usage", listOf(ForTestCompileRuntime.runtimeJarForTests()))
val command = listOf<String>(
File(KotlinTestUtils.getJdk9Home(), "bin/java").path,
"-p",
"${ForTestCompileRuntime.runtimeJarForTests().path}:${jar.path}",
"-m",
"usage/some.module.withsome.packages.UsageKt"
)
val process = ProcessBuilder().command(command).start()
process.waitFor(1, TimeUnit.MINUTES)
val got = process.inputStream.reader().readText()
KotlinTestUtils.assertEqualsToFile(File("$testDataDirectory/stdout.txt"), got)
}
}