Akshat Gupta
07/02/2024, 2:47 PMAkshat Gupta
07/02/2024, 2:47 PM$ java --version
openjdk 21.0.3 2024-04-16 LTS
OpenJDK Runtime Environment Corretto-21.0.3.9.1 (build 21.0.3+9-LTS)
OpenJDK 64-Bit Server VM Corretto-21.0.3.9.1 (build 21.0.3+9-LTS, mixed mode, sharing)
$ echo $JAVA_HOME
/usr/lib/jvm/java-21-amazon-corretto
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
This ⬇️ should be unrelated, since failure is with compileJava
kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
$ ./gradlew --version
------------------------------------------------------------
Gradle 8.7
------------------------------------------------------------
Build time: 2024-03-22 15:52:46 UTC
Revision: 650af14d7653aa949fce5e886e685efc9cf97c10
Kotlin: 1.9.22
Groovy: 3.0.17
Ant: Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM: 21.0.3 (<http://Amazon.com|Amazon.com> Inc. 21.0.3+9-LTS)
OS: Linux 5.15.160-104.158.amzn2.x86_64 amd64
Error log:
> Task :proto-library:compileJava
An exception has occurred in the compiler (17.0.9). Please file a bug against the Java compiler via the Java bug reporting page (<https://bugreport.java.com>) after checking the Bug Database (<https://bugs.java.com>) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
java.lang.OutOfMemoryError: Java heap spaceAkshat Gupta
07/02/2024, 2:47 PMorg.gradle.jvmargs=-Xmx8g -XX:MaxMetaspaceSize=4096m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8Akshat Gupta
07/02/2024, 2:48 PMAkshat Gupta
07/02/2024, 2:48 PMVampire
07/02/2024, 3:05 PMThis ⬇️ should be unrelated, since failure is withI don't think it is unrelated. The Kotlin Gradle Plugin most probably is configuring thecompileJava
compileJava task to be consistent with the KGP configuration otherwise you get complaints that compileJava and compileKotlin are not configured consistently.
Also, I have monitored heap space of my machine; its not eating up complete 8 GYou are not monitoring the "heap space of your machine", you are monitoring the "RAM of your machine". But the
compileJava task by default is configured to have 256m iirc, so you need to set options.forkOptions.memoryMaximumSize on it if your compilation needs more.Akshat Gupta
07/02/2024, 3:08 PMkotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
like, I can't configure 21 for kotlin too, right ?Akshat Gupta
07/02/2024, 3:08 PMtasks.withType(JavaCompile).configureEach {
// Override the compile task behavior here
// For example, disabling warnings
options.compilerArgs << "-Xlint:none"
options.setWarnings(false)
options.fork = true
options.forkOptions.memoryMaximumSize = '3g'
}Vampire
07/02/2024, 3:14 PMVampire
07/02/2024, 3:15 PMoptions.fork = true should be the default, you should not need thatAkshat Gupta
07/02/2024, 3:16 PM1.9.0 version, let me try upgrading to 1.9.20 & move kotlin to 21Vampire
07/02/2024, 3:17 PMAkshat Gupta
07/02/2024, 5:06 PM