I read about the GraalVM and the SubstrateVM framework. I understand that the native-image
command can be used to create native applications from Java source files as follows:
$ javac Hello.java
$ native-image --no-server --no-fallback Hello
$ ./hello
Hello World!
$
This creates a native binary hello
, which is - according to this question - powered by the SubstrateVM framework, which provides...
...other things (runtime) needed to actually run ahead-of-time compiled Java bytecode without a JVM.
This is unclear to me:
hello
binary consist of pure target machine bytecode or is there still Java bytecode and a fully-fledged virtual machine embedded, namely the SubstrateVM?hello
native image to run compared to a usual Hello World!
C program?A good example to understand what's going on is the Garbage Collector.
The JVM has one, so you don't have to manually manage memory. But when you build a native image, there isn't one in your java code right? So the native image tool bundles the SubstrateVM garbage collector with your application so that the generated binary can collect it's own garbage and you don't have to.
This means that Substrate VM is needed at build time, and at run time. It also means that there isn't any bytecode in the binary and there is no "fully-fledged virtual machine embedded".