Denis Voloshin
Denis Voloshin

Reputation: 788

Kotlin JavaScript Engine implementation

Does anyone know which JavaScript engine Kotlin is using to evaluate Javascript? I found the following class

KotlinJsr223ScriptEngineFactoryExamples.kt

looking at the class source KotlinJsr223ScriptEngineFactoryExamples.kt could see the following dependency

import javax.script.Bindings
import javax.script.ScriptContext
import javax.script.ScriptEngine

I'm wondering whether Kotlin is based on already existing Javascript Engines like Nashorn or Rhino or it's running its own implementation. I'm considering to port my lib to Korlin, the performance is extremely important for me, base on my tests Hashorn is losing to Rhino. So I want to find out, what engine Kotlin is executing behind the senses.

Thanks in advance

Upvotes: 1

Views: 1876

Answers (1)

kzm
kzm

Reputation: 395

JavaScript engine is provided by JDK. It can be:

You can find out script engine for your JDK using:

val engine = javax.script.ScriptEngineManager().getEngineByName("JavaScript")

println(engine::class) // class jdk.nashorn.api.scripting.NashornScriptEngine

Upvotes: 1

Related Questions