Im trying out the "Foreign Function & Memory API (Preview)" in Java 19. Ive used jextract to create netcdf_h.java. This is working from a main() program in src, but when I try to run it from a test program in test, it fails with the message:
Preview features are not enabled for sunya/cdm/netcdf/ffm/netcdf_h (class file version 63.65535). Try running with '--enable-preview' java.lang.UnsupportedClassVersionError: Preview features are not enabled for sunya/cdm/netcdf/ffm/netcdf_h (class file version 63.65535). Try running with '--enable-preview'
Im using gradle to build:
...
tasks {
val ENABLE_PREVIEW = "--enable-preview"
withType<JavaCompile>() {
options.compilerArgs.add(ENABLE_PREVIEW)
// Optionally we can show which preview feature we use.
options.compilerArgs.add("-Xlint:preview")
// Explicitly setting compiler option --release
// is needed when we wouldn't set the
// sourceCompatiblity and targetCompatibility
// properties of the Java plugin extension.
options.release.set(19)
}
withType<Test>() {
useJUnitPlatform()
jvmArgs!!.add(ENABLE_PREVIEW)
}
withType<JavaExec>() {
jvmArgs!!.add(ENABLE_PREVIEW)
}
withType<KotlinCompile> {
kotlinOptions.jvmTarget = "19"
}
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(19))
}
}
And IntelliJ to run.
Seems like maybe theres somewhere else I need to add "--enable-preview" in gradle for tests ??