I'm learning Kotlin how to eval scripts, and I saw the code in BasicJvmScriptEvaluator like the following:
val ctor = java.constructors.single()
val saveClassLoader = Thread.currentThread().contextClassLoader
Thread.currentThread().contextClassLoader = this.java.classLoader
return try {
ctor.newInstance(*args.toArray())
} finally {
Thread.currentThread().contextClassLoader = saveClassLoader
}
I don't understand the code java.constructors.single()
, there is no package named java.constructors. How should I understand this code?