Why is there no kotlin-stdlib-jdk11? - kotlin

I'm using Kotlin for backend development...
Is it because Kotlin 1.4 already supports it? Or kotlin-stdlib-jdk8 would suffice? Or Kotlin does not have plans to support JDK 11?
Please enlighten me.
Thanks!

TL;DR kotlin-stdlib-jdk8 can be successfully used with JDK 11.
The motivation of splitting binaries by JDK 1.7 and JDK 1.8 is the dependency of the jdk8 artifact on some APIs not available (e.g., ThreadLocalRandom) in older Java versions.
Currently, there is no need for a special standard library artifact for JDK 11 because Kotlin doesn't provide any APIs depending on it.
Update: just in case, if you use Kotlin Gradle Plugin, you don't need to specify Kotlin's standard library dependency manually since the plugin adds it to all the Kotlin source sets automatically.

Related

How to use javaparser plugin of JQAssistant?

I'm trying to use javaparser plugin of JQAssistant using command line. I have done the following:
Copied "jqassistant.plugin.javaparser-1.8.0.jar" to "plugin" folder.
I also noticed plugin has runtime dependency to "com.github.javaparser:javaparser-core:3.6.25". So I copied "javaparser-core-3.6.25.jar" to plugin folder too.
But when I try to scan a Java file I get the following error:
"ANTLR Tool version 4.9.2 used for code generation does not match the current runtime version 4.7.2"
The ANTLR version bundled with JQAssistant is 4.9.2 but plugin is expecting older version 4.7.2.
Has anyone been able to use javaparser plugin?
Some plugins (not only javaparser) indeed depend on JARs bundled with jQAssistant. Sometimes there are version conflicts, that's why it can only be guaranteed that Kontext E plugins with a certain version (let's say 1.8.x) are compatible with jQAssistant with the same major and minor version (so jQA 1.8 in this case). If you use javaparser 1.8.0 with jQAssistant 1.8.0 (which comes with org.antlr-antlr4-runtime-4.7.2), it works.

Kotlin 5.21 in IntelliJ IDEA

I have imported an existing Maven project into IntelliJ IDEA 2021.2. The Maven project uses Kotlin version 1.5.21. However, I get a warning that the version in Maven is incompatible with the version of the IntelliJ plugin, which is 1.5.10 and is the latest available. Is there a way to use Kotlin 1.5.21 in the latest version of IDEA?
Try Settings > Languages & Frameworks > Kotlin > Update channel > Early Access Preview 1.5.x
I don't think the difference in version really matters, but this might be interesting for you.
You can't update to the newest version of Kotlin plugin on 2021.2 for now. See - https://youtrack.jetbrains.com/issue/KTIJ-18848

Pros and Cons with installing Kotlin standalone compiler instead of using IntelliJ Kotlin plugin?

i understand that i can use Kotlin Plugin comes with IntelliJ but i can also install Kotlin standalone compiler. Is there any pros/cons using standalone vs IntelliJ own integrated?
I'd say that:
Any real Kotlin project (including projects in IntelliJ) should use a build system such as Gradle or Maven.
Enabling Kotlin support in a Gradle/Maven project will automatically download the correct compiler (and switch it when you update the Kotlin version in the config file) and not care about whether you have a stand-alone version installed.
Any other Kotlin tool will likely be integrated with them as well.
So the standalone compiler is pretty much only useful when you want to try something quickly outside any project, but then https://play.kotlinlang.org/ or https://try.kotlinlang.org/ can work as well; and again let you switch between Kotlin versions simpler than a manually installed compiler.
Running Kotlin scripts may be the only case where I would use the stand-alone compiler.
Not much, but having own install have few advantages, but probably not needed by most people on their machines:
You don't need intellij, so you can use that compiler in other IDE or just for other applications
You can use different version of compiler than the one from plugin.
But in most cases integrated one is all you need.

What is the recommended IntelliJ setup for Kotlin Multiplatform

I've been trying to get an environment for working with Kotlin (multiplatform) for a little too long now and would like some advice. I seem to get stuck on which version of JDK do I need, should I download Android Studio for the Android SDK or is there a cleaner way than getting the full IDE, which version of IntelliJ to use and which version of the Kotlin plugin is compatible.
I would like to use Kotlin 1.3.
My aim is to develop a common library with no platform-specific code; though I would like to test it on Android, Linux, WebAssembly.
Lubuntu 18.04.1
Intel x64
I'd suggest using the Kotlin Multiplatform Plugin which just came out. Its setup is very simple:
plugins {
id 'org.jetbrains.kotlin.multiplatform' version '1.2.71'
}
repositories {
mavenCentral()
}
kotlin {
targets {
fromPreset(presets.jvm, 'jvm')
fromPreset(presets.js, 'js')
fromPreset(presets.mingwX64, 'mingw')
}
sourceSets { /* ... */ }
}
It comes with built-in presets for all supported platforms but you can also set them up individually. I've worked with the "old way" of doing multiplatform development and using this plugin will just make it infinitely easier to deal with. You can read more about setting it up here.
You should target Java 6 code if you're planning to use the library in Android and not having any headaches. Note that you need to specify that explicitly to the Kotlin compiler. Only setting the IntelliJ IDEA project to target Java 6 won't do.
The JDK version doesn't really matter since you can tell the compiler to generate code for any previous Java version.
IntelliJ IDEA is probably the best IDE for Kotlin since it's made by JetBrains, the same guys that are behind Kotlin itself. Get the latest version.
You don't need any extra plugin, Kotlin is supported out of the box by IntelliJ IDEA (i.e. Kotlin plugin is included in the standard version).

The binary version of its metadata is 1.0.1, expected version is 1.1.0

In intellij idea 16 EAP 144.3357.4 I have a pure Kotlin cmd project currently refusing to run with this error:
The binary version of its metadata is 1.0.1, expected version is 1.1.0
The project runs on the command-line - I invalidated caches and restarted Idea - nothing helped. Anyone had the same problem and found a way to get it working?
The problem seems to be mismatch between the kotlin library used in your project and the version of the plugin are not compatible.
Check the Kotlin plugin version and you'll most likely see something similar to:
Version: 1.0.0-rc-1007-IJ143-11
Then check the version of the Kotlin libraries by looking into META-INF/build.txt or META-INF/MANIFEST.MF and it'll most likely be other version like 1.0.0-beta-4589.
To resolve the problem update Kotlin libraries to version 1.0.0-rc-1007 which can be found in this maven repository: https://dl.bintray.com/kotlin/kotlin-eap.
Kotlin compiler marks each .class with #kotlin.Metadata to indicate, among others:
The version of the bytecode interface (naming conventions, signatures) of the class file annotated with this annotation.
That is how the compiler detected incompatibilities.