Support main entry-point without arguments in JVM
#KT-26574 In Progress
This commit is contained in:
+1
@@ -0,0 +1 @@
|
||||
Return code: 0
|
||||
@@ -0,0 +1,9 @@
|
||||
package Hello
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
System.out.println("Hello!")
|
||||
}
|
||||
|
||||
fun main() {
|
||||
System.out.println("Fail")
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
OUT:
|
||||
Hello!
|
||||
|
||||
Return code: 0
|
||||
+1
@@ -0,0 +1 @@
|
||||
Return code: 0
|
||||
@@ -0,0 +1,5 @@
|
||||
package Hello
|
||||
|
||||
fun main() {
|
||||
System.out.println("Hello!")
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
OUT:
|
||||
Hello!
|
||||
|
||||
Return code: 0
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
Return code: 0
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package Hello
|
||||
|
||||
import kotlin.concurrent.thread
|
||||
import kotlin.coroutines.suspendCoroutine
|
||||
import kotlin.coroutines.resume
|
||||
import kotlin.reflect.jvm.javaMethod
|
||||
|
||||
@kotlin.jvm.Volatile
|
||||
private var result = ""
|
||||
@kotlin.jvm.Volatile
|
||||
private var callback: Function0<Unit>? = null
|
||||
|
||||
suspend fun appendAndSuspend(s: String) {
|
||||
result += s
|
||||
|
||||
suspendCoroutine<Unit> { continuation ->
|
||||
callback = {
|
||||
continuation.resume(Unit)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun main() {
|
||||
thread(isDaemon = true) {
|
||||
while (true) {
|
||||
val c = callback
|
||||
c?.invoke()
|
||||
Thread.sleep(500)
|
||||
}
|
||||
}
|
||||
|
||||
appendAndSuspend("O")
|
||||
appendAndSuspend("K")
|
||||
println(result)
|
||||
callback = null
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
OUT:
|
||||
OK
|
||||
|
||||
Return code: 0
|
||||
Reference in New Issue
Block a user