-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Please specify proper '-jvm-target' optionkotlin(INLINE_FROM_HIGHER_PLATFORM) #72
Comments
This might be related to #20. Java 9+ support is still experimental. |
I switch back to Java 8
and still have the same message. |
Same problem here, setting the
Any more info we can provide to help out?, |
I'm having this same issue. Could you add a VSCode setting to change the version of the Here's the relevant portion of my Gradle configuration: import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
tasks.withType<KotlinCompile> {
kotlinOptions.suppressWarnings = true
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8.toString()
} The specific error I'm getting is a little different than others, but the root cause is similar.
|
I've also bumped into this problem. Is there some kind of "brute force" approach to solve this problem? For example, force KLS to always use 1.8. This would be sufficient for my purposes for now since I am using the same Java version on all my projects. |
I have same problem too. diff --git a/server/src/main/kotlin/org/javacs/kt/Compiler.kt b/server/src/main/kotlin/org/javacs/kt/Compiler.kt
index 0f223df..e310b90 100644
--- a/server/src/main/kotlin/org/javacs/kt/Compiler.kt
+++ b/server/src/main/kotlin/org/javacs/kt/Compiler.kt
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.cli.jvm.config.addJvmClasspathRoots
import org.jetbrains.kotlin.config.CommonConfigurationKeys
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.JVMConfigurationKeys
+import org.jetbrains.kotlin.config.JvmTarget
import org.jetbrains.kotlin.container.ComponentProvider
import org.jetbrains.kotlin.container.get
import org.jetbrains.kotlin.idea.KotlinLanguage
@@ -49,6 +50,7 @@ class Compiler(classPath: Set<Path>) {
private val config = CompilerConfiguration().apply {
put(CommonConfigurationKeys.MODULE_NAME, JvmAbi.DEFAULT_MODULE_NAME)
put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, LoggingMessageCollector)
+ put(JVMConfigurationKeys.JVM_TARGET, JvmTarget.JVM_1_8)
addJvmClasspathRoots(classPath.map { it.toFile() })
}
val environment: KotlinCoreEnvironment |
Genius! thanks @kuro46, applying the patch locally as we speak :-) |
Applied, works as advertised! :-) Thanks very much! |
@kuro46 Thank you very much, I will add this as a configuration option to the language server! |
Fixed by #128. |
Wow that was fast! :-) bit of a newbie question, where do I place the new config option |
@mcraveiro LSP has a |
Aha, excellent - I'll dig through the lisp. Cheers |
To add to this, this is a sample configuration taken from my current setup: {"kotlin":{"languageServer":{"enabled":true},"compiler":{"jvm":{"target":"1.8"}},"linting":{"debounceTime":250},"completion":{"snippets":{"enabled":true}},"debounceTime":250,"snippetsEnabled":true}} This object is passed as part of the interface DidChangeConfigurationParams {
/**
* The actual changed settings
*/
settings: any;
} Edit: Not all keys have to be present, those that aren't are simply left at their current/default values, so if you just want to set the JVM version, you could do something like this: {"kotlin":{"compiler":{"jvm":{"target":"1.8"}}}} |
How can I change the target in a maven project in vscode? I'm getting the same error in a spring-boot project. |
For anyone that is struggling with this in Neovim, you can set the lsp config as follows and it should fix the problem. lua require'lspconfig'.kotlin_language_server.setup{ settings = { kotlin = { compiler = { jvm = { target = "1.8" } } } } } |
let g:lsp_settings = {
\ 'kotlin-language-server': {
\ 'workspace_config': {
\ 'kotlin': {'compiler': {'jvm': {'target': '17'}}}
\ }
\ }
\} |
I'm getting same issue. It's not clear to where should I override jvm-target setting. I guess I should need to create an additional config file... Any ideas? |
Trying to use the plugin with java 11 on OSX.
It is a simple project generate via springr.
I get the following error
You can reproduce using this repo https://github.com/laibulle/spring-kotlin-sample. The code run via
Best regards
The text was updated successfully, but these errors were encountered: