mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-10 00:21:35 +00:00
Currently all tests in boxWithStdlib/ run with both runtime and reflection included; eventually they'll be merged into box/ using these directives
42 lines
634 B
Kotlin
Vendored
42 lines
634 B
Kotlin
Vendored
// WITH_RUNTIME
|
|
// FILE: 1.kt
|
|
|
|
package test
|
|
|
|
class A {}
|
|
|
|
fun getMain(className: String): java.lang.reflect.Method {
|
|
val classLoader = A().javaClass.classLoader
|
|
return classLoader.loadClass(className).getDeclaredMethod("main", Array<String>::class.java)
|
|
}
|
|
|
|
fun box(): String {
|
|
val bMain = getMain("pkg.AKt")
|
|
val cMain = getMain("pkg.BKt")
|
|
|
|
val args = Array(1, { "" })
|
|
|
|
bMain.invoke(null, args)
|
|
cMain.invoke(null, args)
|
|
|
|
return args[0]
|
|
}
|
|
|
|
|
|
|
|
// FILE: a.kt
|
|
|
|
package pkg
|
|
|
|
fun main(args: Array<String>) {
|
|
args[0] += "O"
|
|
}
|
|
|
|
// FILE: b.kt
|
|
|
|
package pkg
|
|
|
|
fun main(args: Array<String>) {
|
|
args[0] += "K"
|
|
}
|