Java Lambdas
To support Java lambdas in the code of an Application, the SDK uses a forked version of RetroLambda.
RetroLambda is not compatible with the Java versions required by the SDK, so a Java 8 toolchain is internally used by the SDK to manage Java lambdas.
By default Gradle will use the Java toolchain available locally, but it can be configured to automatically download one by applying the Foojay Toolchains Plugin in the settings.gradle.kts
file of your project:
plugins {
id("org.gradle.toolchains.foojay-resolver-convention").version("0.9.0")
}
This settings plugin downloads the first Java toolchain matching the specified requirements that it finds among the
JVM Vendors recognized by Gradle and unzips it in the $USER_HOME/.gradle/.jdks
folder,
so you do not have to install one manually.
Note
A Java 8 toolchain is only required if the Java lambdas are enabled on your Application project. If it is not the case, you do not need to apply the Foojay Toolchains Plugin
.
Applied on a MicroEJ project, the plugin downloads the first Java 8 toolchain found, but it is possible to specify a Vendor by configuring the Java toolchain in the build.gradle.kts
file of your project if needed:
tasks.processMainLambdas.configure {
javaLauncher.set(javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(8)
vendor = JvmVendorSpec.ADOPTIUM
})
}
Note
For each source set defined in your project, a processXXXLambdas
task exists. To modify the Java toolchain,
you must configure the task corresponding to the source set containing Java lambdas. For example, if they are used in the src/main/java
source set,
the processMainLambdas
task must be configured.