withEnvAttaching

context(autofreeScope: AutofreeScope)
inline fun <T> JavaVM.withEnvAttaching(version: JniVersion, name: String, group: JObject? = null, block: context(JniEnv) () -> T): T(source)

Alias for withEnvAttaching which accepts the thread name as a Kotlin String encoded as modified UTF-8 with String.modifiedUtf8.


context(autofreeScope: AutofreeScope)
inline fun <T> JavaVM.withEnvAttaching(version: JniVersion, name: CValuesRef<ByteVar>? = null, group: JObject? = null, block: context(JniEnv) () -> T): T(source)

Attaches the current thread to the Java VM, executes the provided block of code within the attached environment and then detaches the thread upon completion.

Parameters

version

the requested JNI version to be used for attaching the current thread.

name

the name of the thread in the null-terminated modified UTF-8. Use String.modifiedUtf8 to get it, or if you are sure that your string doesn't have illegal characters you may use optimized String.utf8.

group

a global ref of a ThreadGroup object.