Hi, what’s difference between `settings.jvm` and t...
# amper
s
Hi, what’s difference between
settings.jvm
and the
settings.java
? I’m a little confused about their clear distinctions and which configuration should go where.
j
That is a fair question. The logic is the following: •
settings.kotlin
contains settings for the Kotlin compiler, thus only apply to Kotlin sources •
settings.java
contains settings for the Java compiler, thus only apply to Java sources •
settings.jvm
contains settings that apply to both Java and Kotlin sources (some common compiler options, settings related to the JDK in general, to the test JVM, etc.)
thank you color 1
I can understand that it can be confusing when we don't look at it in this light. Hopefully the nested completion in the IDE helps
s
Thanks for the info.. Does the IDE honer these jvm compiler args like in Gradle? The preview API are still showing red on the IDE
I have enabled the preview feature in freeCompilerArgs
Also, i seeing a strange behavior for JDK preview APIs . Preview API used in src@jvm java files throws proper error during compilation
Copy code
00:06.858 ERROR :shared:compileJvm        /Users/sgopal1/code/kmp-amper/shared/src@jvm/JVersion.java:3: error: ScopedValue is a preview API and is disabled by default.
00:06.859 ERROR :shared:compileJvm                System.out.println(ScopedValue.newInstance());
00:06.859 ERROR :shared:compileJvm                                   ^
00:06.859 ERROR :shared:compileJvm          (use --enable-preview to enable preview APIs)
00:06.859 ERROR :shared:compileJvm        1 error
But the same API used in kotlin sources, compiles without any issues. Does kotlin compiler enable jdk preview feature by default ?
j
> Does the IDE honor these jvm compiler args like in Gradle? Generally, yes. But for new APIs like
settings.java.freeCompilerArgs
, the support wasn't added yet in the Amper IDEA plugin (the plugin needs to tell the IDE how to configure compilers based on the Amper model). You really live on the edge of the edge here 😄 The release cycle of the IDE is a bit longer, so unfortunately you might have to wait for a bit before getting the latest Amper plugin updates.
> But the same API used in kotlin sources, compiles without any issues. Does kotlin compiler enable jdk preview feature by default ? To be honest, I don't actually know. It would be interesting to ask the Kotlin compiler folks about this. What I know for sure is that
settings.jvm.release
does restrict the available Java APIs even in Kotlin sources, but preview APIs, I don't know.
🆗 1
s
Thanks… whats really strange is it (kotlin code) even run without --enable-preview option
Copy code
❯ java --version
openjdk 21.0.8 2025-07-15 LTS
OpenJDK Runtime Environment Zulu21.44+17-CA (build 21.0.8+9-LTS)
OpenJDK 64-Bit Server VM Zulu21.44+17-CA (build 21.0.8+9-LTS, mixed mode, sharing)
Copy code
❯ java -jar ./build/tasks/_jvm_executableJarJvm/jvm-jvm-executable.jar

java.lang.ScopedValue@f0001e1
Hello Kotlin 2.2.0 - JVM World 21.0.8
I am pretty sure scoped value is a preview in jdk 21
Also, can we make these javac lint warning as WARN instead of ERROR ?
Copy code
00:07.523 ERROR :shared:compileJvm        /../code/kmp-amper/shared/src@jvm/JVersion.java:3: warning: [preview] ScopedValue is a preview API and may be removed in a future release.
00:07.525 ERROR :shared:compileJvm                System.out.println(ScopedValue.newInstance());
00:07.525 ERROR :shared:compileJvm                                   ^
00:07.540 ERROR :shared:compileJvm        1 warning