graalvm 2022-05-22

Is there a way to check at build time if you are building a GraalVM native image?

You can use the static methods on the ImageInfo class, https://www.graalvm.org/sdk/javadoc/org/graalvm/nativeimage/ImageInfo.html

Although you may also want to have different code paths at compile time (eg. building an uber jar). For that, it's common to use System properties. See https://github.com/cnuernber/dtype-next/blob/master/src/tech/v3/datatype/graal_native.cljhttps://github.com/cnuernber/dtype-next/blob/master/src/tech/v3/datatype/graal_native.cljfor an example

Oh yea the different code paths when building Jar makes sense

@grounded_sage You can check system properties for this.

So:

(System/getProperty "com.oracle.graalvm.isaot") 
should do the trick and will not couple your program to any of the graalvm specific classes

I'll play with these responses when I am back at computer.

Actually just realised I build the jar and then the native image. So of course it's not there at macro expansion.

👍 1