I'm using kotlin 2.2.0, with `BasicJvmScriptingHos...
# scripting
t
I'm using kotlin 2.2.0, with
BasicJvmScriptingHost
embedded in an application that's dynamically loading JPMS modules using
ModuleLayer
. I simply want the classloader from this
ModuleLayer
to be visible to the compiler. I"m setting
baseClassLoader
in the host configuration thus:
Copy code
val hostconf = ScriptingHostConfiguration {
        jvm {
            baseClassLoader(appClassloader)
        }
    }
I've also tried a variety of ways to set the classloader in the
ScriptCompilationConfiguration
but to no avail. I don't want to add explicit jars (e.g.
dependenciesFromClassloader()
). I just want it to use a provided classloader, but it always just uses the main/boot classloader. This is something I've had working at some stage in the pass, but now doesn't seem to. I feel like I'm missing something obvious - it seems to want external files? Please, any pointers?
m
I don't think that's ever worked. The compiler needs the raw bytecode of the classes, which the JVM doesn't expose. That's why it needs files.
t
Thanks for your response. But how does it use the boot class loader in that case? Compiler can access any classes that were on the module path during boot?