graal icon indicating copy to clipboard operation
graal copied to clipboard

Resource not found: /org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreEnvironment$Companion.class

Open cyw3 opened this issue 2 years ago • 4 comments

Describe the issue

I create a binary file from a kotlin project with graal native image successfully.

However, when i run the binary file, it crash with:

java.lang.IllegalStateException: Resource not found: /org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreEnvironment$Companion.class
        at org.jetbrains.kotlin.utils.PathUtil.getResourcePathForClass(PathUtil.kt:173)

Steps to reproduce the issue here is the same error: https://github.com/facebookincubator/ktfmt/issues/44

Describe GraalVM and your environment:

  • GraalVM CE 22.1.0 (build 17.0.3+7-jvmci-22.1-b06)
  • JDK major version: openjdk 11.0.13-ga
  • OS: Centos7
  • Architecture: x86

cyw3 avatar Jul 01 '22 03:07 cyw3

Is the /org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreEnvironment$Companion.class file in your resources-config.json?

fniephaus avatar Jul 01 '22 15:07 fniephaus

Yes. And I use the native-image-agent to generate the native-image config files automatically.

{
  "resources":{
  "includes":[
    {
      "pattern":"\\QMETA-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat\\E"
    }, 
    {
      "pattern":"\\QMETA-INF/services/java.nio.file.spi.FileSystemProvider\\E"
    }, 
    {
      "pattern":"\\QMETA-INF/services/org.apache.logging.log4j.core.util.ContextDataProvider\\E"
    }, 
    {
      "pattern":"\\QMETA-INF/services/org.apache.logging.log4j.spi.Provider\\E"
    }, 
    {
      "pattern":"\\QMETA-INF/services/org.apache.logging.log4j.util.PropertySource\\E"
    }, 
    {
      "pattern":"\\QMETA-INF/services/org.jetbrains.kotlin.builtins.BuiltInsLoader\\E"
    }, 
    {
      "pattern":"\\QMETA-INF/services/org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages$Extension\\E"
    }, 
    {
      "pattern":"\\QMETA-INF/services/org.jetbrains.kotlin.resolve.ExternalOverridabilityCondition\\E"
    }, 
    {
      "pattern":"\\QMETA-INF/services/org.jetbrains.kotlin.util.ModuleVisibilityHelper\\E"
    }, 
    {
      "pattern":"\\Qcom/sun/jna/linux-x86-64/libjnidispatch.so\\E"
    }, 
    {
      "pattern":"\\Qjars/kotlin-stdlib-1.6.0.jar\\E"
    }, 
    {
      "pattern":"\\Qjars/kotlin-stdlib-common-1.6.0.jar\\E"
    }, 
    {
      "pattern":"\\Qjars/kotlin-stdlib-jdk8-1.6.0.jar\\E"
    }, 
    {
      "pattern":"\\Qkotlin/annotation/annotation.kotlin_builtins\\E"
    }, 
    {
      "pattern":"\\Qkotlin/collections/collections.kotlin_builtins\\E"
    }, 
    {
      "pattern":"\\Qkotlin/coroutines/coroutines.kotlin_builtins\\E"
    }, 
    {
      "pattern":"\\Qkotlin/internal/internal.kotlin_builtins\\E"
    }, 
    {
      "pattern":"\\Qkotlin/kotlin.kotlin_builtins\\E"
    }, 
    {
      "pattern":"\\Qkotlin/ranges/ranges.kotlin_builtins\\E"
    }, 
    {
      "pattern":"\\Qkotlin/reflect/reflect.kotlin_builtins\\E"
    }, 
    {
      "pattern":"\\Qlibrary.properties\\E"
    }, 
    {
      "pattern":"\\Qlog4j2.xml\\E"
    }, 
    {
      "pattern":"\\Qorg/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreEnvironment$Companion.class\\E"
    }, 
    {
      "pattern":"\\Qorg/slf4j/impl/StaticLoggerBinder.class\\E"
    }
  ]},
  "bundles":[]
}

cyw3 avatar Jul 04 '22 01:07 cyw3

Ok, thanks. Just because it's generated with the agent doesn't mean it's correct or complete as you can see in this example. I have no idea how KotlinCoreEnvironment works and why it's loading a resource. If it can be initialized at build-time, maybe the problem goes away because the resource no longer needs to be loaded. But again, I don't know what the resource is for and if it's safe to build-time initialize KotlinCoreEnvironment.

fniephaus avatar Jul 04 '22 07:07 fniephaus

Hi, Thank you for reporting this, we will take a look into it and get back to you

oubidar-Abderrahim avatar Jul 19 '22 15:07 oubidar-Abderrahim

Did you have time to test initializing KotlinCoreEnvironment at build-time? I tried reproducing on my side but I got different errors, could you clarify first where you add the substitution you add? is this still reproduced with the latest ktfmt jar?

oubidar-Abderrahim avatar Aug 11 '22 09:08 oubidar-Abderrahim

Closing this issue for inactivity, if you still face the issue using the latest GraalVM version, please reopen or create a new issue. Thank you

oubidar-Abderrahim avatar Nov 21 '23 11:11 oubidar-Abderrahim