Create temporary library directories for J2V8.
Workaround for https://github.com/eclipsesource/J2V8/issues/39
This commit is contained in:
committed by
max-kammerer
parent
21d81f353c
commit
9cd005fbae
@@ -9,9 +9,20 @@ import com.eclipsesource.v8.V8
|
||||
import com.eclipsesource.v8.V8Array
|
||||
import com.eclipsesource.v8.V8Object
|
||||
import com.eclipsesource.v8.utils.V8ObjectUtils
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import java.io.File
|
||||
|
||||
class ScriptEngineV8 : ScriptEngine {
|
||||
companion object {
|
||||
// It's important that this is not created per test, but rather per process.
|
||||
val LIBRARY_PATH_BASE = FileUtil.createTempDirectory(
|
||||
File(System.getProperty("java.io.tmpdir")),
|
||||
"j2v8_library_path",
|
||||
"",
|
||||
true
|
||||
).path
|
||||
}
|
||||
|
||||
override fun <T> releaseObject(t: T) {
|
||||
(t as? V8Object)?.release()
|
||||
}
|
||||
@@ -22,7 +33,7 @@ class ScriptEngineV8 : ScriptEngine {
|
||||
return context.also { v8result.release() }
|
||||
}
|
||||
|
||||
private val myRuntime: V8 = V8.createV8Runtime("global")
|
||||
private val myRuntime: V8 = V8.createV8Runtime("global", LIBRARY_PATH_BASE)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun <T> eval(script: String): T {
|
||||
|
||||
Reference in New Issue
Block a user