Hey, I've been having some issues getting IntelliJ...
# scripting
l
Hey, I've been having some issues getting IntelliJ to recognize my script definitions. The IDE log suggests that the issue is caused by some access problems:
java.lang.IllegalAccessException: class kotlin.reflect.jvm.internal.KClassImpl$Data$objectInstance$2 cannot access a member of class com.github.themrmilchmann.kwiki.dsl.SiteScriptCompilationConfiguration with modifiers "public static final"
(I will include the full stacktrace as a thread comment.) However, my compilation configuration is a public object as shown in examples in this channel before. (
object SiteScriptCompilationConfiguration : ScriptCompilationConfiguration({ ... })
) Now my actual question is what I can do to debug this further? (Could this be an issue caused by using Java 11 as IDE runtime?)
Untitled
i
Sorry for the long delay. We have only one hypothesis so far, is your configuration object defined in the modular jar? If so, you need to make sure that the package with the configuration is explicitly exported from the module. Is it the case?
l
Hi, I'm not using Java modules in this project. In fact, the project SDK and Gradle SDK are both set to JDK 8. The only component that is using Java >= 9 is the IDE itself (i.e. the Jetbrains Runtime). IDE version is latest 2020.1 EAP and Kotlin 1.3.70.
i
Is the
SiteScriptCompilationConfiguration
really public?
We have this issue - https://youtrack.jetbrains.com/issue/KT-22792 - with the similar effect.
And does it fail only in IntelliJ, and works fine when you run the script from a host?
l
That's the full thing.
i
/cc: @udalov
l
Okay, so I spent some time experimenting and now this seems to be fixed but I don't understand how or why: My script base class accepts a parameter (as can be seen in the attached image). I do not know why this is relevant for IntelliJ but after I removed the parameter (and the interface), IntelliJ started picking up the script definition. Now the weird part: When adding both back (even after invalidating IDE caches and restarting) IntelliJ picks up everything just fine.
Sorry for wasting your time. I'll just assume that this was a configuration error and report back should I ever be able to reproduce it. While I've got your attention, could you point me to the API for compiling a script to file?
i
Yes, please report if you'll see it again, so far it looks quite strange.
API for compiling a script to file?
There are no proper docs and examples, but this test - https://github.com/JetBrains/kotlin/blob/1.3.70/libraries/scripting/jvm-host-test/test/kotlin/script/experimental/jvmhost/test/ScriptingHostTest.kt#L124 shows how to do it.
l
Thanks!
i
And please, do not hesitate to ask questions here, I'm sorry that I'm failing to answer it soon enough sometimes, but I'm trying to answer questions sooner or later anyway.
👍 1