windows - Kotlin代码的运行时编译会引发RuntimeException(警告:无法为Windows初始化 native 文件系统)

标签 windows kotlin compilation filesystems jsr223

我正在使用kotlin std-lib中的KotlinJsr223在运行时编译kotlin代码。

基本上概括问题,我有以下代码:

val engine = KotlinJsr223JvmLocalScriptEngineFactory().scriptEngine as KotlinJsr223JvmLocalScriptEngine
val kotlinScript = engine.compile("""println("Hello World")""") as KotlinJsr223JvmScriptEngineBase.CompiledKotlinScript

第二行运行(编译代码)后,将引发警告和RuntimException。

异常(exception)主线是:

WARN: Failed to initialize native filesystem for Windows
java.lang.RuntimeException: Could not find installation home path. Please make sure bin/idea.properties is present in the installation directory.

Looks like there's some problem in creating filesystem.



Full stack trace's gist is here,如果您要检查。

有办法解决问题吗?

编译不会退出应用程序,有点像警告。之后,像5秒钟一样的延迟,然后编译成功,但是5秒钟的中断和控制台警告仍然是某种威胁,需要加以解决。

我的运行时环境如下:
  • Windows 10内部版本1909
  • Java-11.0.4
  • Kotlin-1.3.72
  • JVM-目标1.8
  • 最佳答案

    该问题仅在IDE中运行时才会发生,可以使用org.jetbrains.kotlin.cli.common.environment.setIdeaIoUseFallback缓解。

    可以在示例here中看到。

    关于windows - Kotlin代码的运行时编译会引发RuntimeException(警告:无法为Windows初始化 native 文件系统),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61438356/

    相关文章:

    c - UTF-8 文本到剪贴板 C

    c++ - 已加载 Dll 的完整路径?

    android - Firebase Firestore Kotlin API 将数据导入自定义对象时出错 : None of the following functions can be called with the arguments supplied

    python - 如何使用 conda 启用 gl2ps 安装 vtk

    java - 从子文件夹导入包: Exception in thread "main" java. lang.NoClassDefFoundError

    c# - Kinect V2 红外面部点跟踪未显示正确的坐标位置

    linux - UDP 连接被拒绝

    android - Kotlin-reflect 和 android gradle 插件 3.1.0

    java - Kotlin 检查异常的替代方案

    剪辑汇编