What are the limitation in using Kotlin Script? e....
# scripting
r
What are the limitation in using Kotlin Script? e.g. if I call a regular kts(not a main.kts), from a Kotlin application does it have access to everything from the app that invoked the script (classes/methods)?
n
it can.. or you can define the scopes or packages it can access i never quite figured it out but the functionality is there
r
Do you see any documentation for that? Does the script run in the same memory space as the main process?
i
It depends very much on how you run your script. If you're using the
BasicJvmScriptingHost
host (which is used in most examples) without additional configuration , then the script is executed in the same process on a classloader that has your application classloader in the parents. To make classes from your app available for script directly, you need to provide dependencies via script configuration. If you, on the other hand, aiming at isolation, you can start by isolating the classloaders - this is a simple configuration option. Or you can compile script to a classes or jar and execute it as you like. Or you can write your own evaluator with the level of isolation you like.