Tracey Yoshima
06/22/2023, 11:41 PMkotlin("compiler-embeddable")
version 1.8.2x
to access FIR
elements in a Java app and get a bad class file
error during compilation.
I can use classes like FirPrimaryConstructor
on version 1.8.0
, an error occurs starting on version 1.8.2x
.
I created a simple project that reproduces the error here.
Any helps is greatly appreciated, thanks in advance!Tracey Yoshima
06/22/2023, 11:41 PM/Users/yoshi/Desktop/kotlin-example/src/main/java/org/example/Main.java:3: error: cannot access FirPrimaryConstructor
import org.jetbrains.kotlin.fir.declarations.impl.FirPrimaryConstructor;
^
bad class file: /Users/yoshi/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-compiler-embeddable/1.8.22/e2cf111da088dc807a74157741b4cd4b664edfb7/kotlin-compiler-embeddable-1.8.22.jar(/org/jetbrains/kotlin/fir/declarations/impl/FirPrimaryConstructor.class)
undeclared type variable: T
Please remove or make sure it appears in the correct subdirectory of the classpath.
dmitriy.novozhilov
06/23/2023, 7:34 AMdmitriy.novozhilov
06/23/2023, 7:35 AMfun test(obj: Any?) {
if (obj is FirPrimaryConstructor) {
println("hello")
}
}
I checked, it works just fineTracey Yoshima
06/23/2023, 3:22 PMTracey Yoshima
06/23/2023, 5:35 PMdmitriy.novozhilov
06/26/2023, 2:43 PMudalov
udalov
@JvmInline
classes will make it difficult to use compiler internals from Java, even when bugs like KT-52706 are fixed. I believe we are OK with this, so it’s just something to remember.