File tree Expand file tree Collapse file tree
core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -77,7 +77,14 @@ internal val formatter = DataFrameFormatter(
7777internal fun getResources (vararg resource : String ) = resource.joinToString(separator = " \n " ) { getResourceText(it) }
7878
7979internal fun getResourceText (resource : String , vararg replacement : Pair <String , Any >): String {
80- val res = DataFrame ::class .java.getResourceAsStream(resource) ? : error(" Resource '$resource ' not found" )
80+ /* *
81+ * The choice of loader is crucial here: it should always be a class loaded by the same class loader as the resource we load.
82+ * I.e. [DataFrame] isn't a good fit because it might be loaded by Kotlin IDEA plugin (because Kotlin plugin
83+ * loads DataFrame compiler plugin), and plugin's classloader knows nothing about the resources.
84+ */
85+ val loader = HtmlContent ::class .java
86+ val res = loader.getResourceAsStream(resource)
87+ ? : error(" Resource '$resource ' not found. Load was attempted by $loader , loaded by ${loader.classLoader} " )
8188 var template = InputStreamReader (res).readText()
8289 replacement.forEach {
8390 template = template.replace(it.first, it.second.toString())
You can’t perform that action at this time.
0 commit comments