I'm trying to compile a Kotlin 1.8 project in Eclipse 2023-03 using the Kotlin plugin 0.8.24, but I'm not having much success. I'm doing regular (non-Android) back-end development, targeting Java/JVM 1.8. The project is compiling fine in Maven using Kotlin 1.8.21, so I'm fairly certain that the source code is OK and the Maven side of the setup is fine. However, in Eclipse, out of the box, I ran into the Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6 error. By perusing the source code for the Kotlin Eclipse plug-in, I figured out that I could solve this issue by adding
globalsOverridden=true
jvmTarget=JVM_1_8
to the .settings/org.jetbrains.kotlin.core.prefs
file. The project's preference pages only show a very limited selection of configuration options (and the JVM target version is not one of them).
Next, I encountered a Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0 on various modules. Following the same approach (i.e., spelunking in the plugin source code), I figured out that adding
apiVersion=KOTLIN_1_8
languageVersion=KOTLIN_1_8
would solve this (again, these options are not available through the project preference pages). Unfortunately, the success was only temporary. Shortly, after applying this change, my project now fails to build in Eclipse. The error messages are, among others:
The Java indexing could not index /my.project/kotlin_bin/my/project/metadata/Cover.class. This .class file doesn't follow the class file format specification. Please report this issue against the .class file vendor
java.lang.IllegalStateException: Can't parse file L/my.project/src/main/kotlin/my/project/metadata/Cover.kt
at org.jetbrains.kotlin.core.builder.ProjectSourceFiles.getPsiFile(KotlinPsiManager.kt:112)
at org.jetbrains.kotlin.core.builder.KotlinPsiManager.getParsedFile(KotlinPsiManager.kt:272)
at org.jetbrains.kotlin.core.builder.KotlinPsiManager.getKotlinParsedFile(KotlinPsiManager.kt:385)
at org.jetbrains.kotlin.core.filesystem.KotlinLightClassManager.getSourceKtFiles(KotlinLightClassManager.kt:149)
at org.jetbrains.kotlin.core.filesystem.KotlinLightClassManager.getSourceFiles(KotlinLightClassManager.kt:141)
at org.jetbrains.kotlin.core.filesystem.KotlinFileStore.openInputStream(KotlinFileStore.kt:57)
at org.eclipse.core.internal.localstore.FileSystemResourceManager.read(FileSystemResourceManager.java:849)
at org.eclipse.core.internal.resources.File.getContents(File.java:277)
at org.eclipse.jdt.internal.core.util.Util.getResourceContentsAsByteArray(Util.java:1172)
at org.eclipse.jdt.internal.core.search.JavaSearchDocument.getByteContents(JavaSearchDocument.java:50)
at org.eclipse.jdt.internal.core.search.indexing.BinaryIndexer.indexDocument(BinaryIndexer.java:656)
at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.indexDocument(JavaSearchParticipant.java:91)
at org.eclipse.jdt.internal.core.search.indexing.IndexManager.indexDocument(IndexManager.java:676)
at org.eclipse.jdt.internal.core.search.indexing.IndexManager$2.execute(IndexManager.java:1291)
at org.eclipse.jdt.internal.core.search.processing.JobManager.indexerLoop(JobManager.java:514)
at java.base/java.lang.Thread.run(Thread.java:833)
There was also an NPE about a required service being null, but I can't reproduce that error anymore.
As far as I can tell, Eclipse no longer compiles .kt
files to .class
files, and any attempted change to existing Kotlin sources or any clean/rebuild actions result in an error pop-up. Notably, I cannot get the project back to its earlier state ("Cannot inline bytecode...", "Module was compiled with...") even after undoing the changes to the configuration file. There appears to be some cached state information that is hard to impossible to get rid of.
Is there some fundamental incompatibility that I'm not aware of? If not, what additional steps can I take to diagnose (and hopefully solve) the problem? (I'm a long time Eclipse user, but fairly new to Kotlin)