简体   繁体   中英

When and why is the SubstrateVM Framwork Required for a Native Image?

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:

  • When and why is the SubstrateVM framework required? Is it required at native-build time only or also during runtime? Does the hello binary consist of pure target machine bytecode or is there still Java bytecode and a fully-fledged virtual machine embedded, namely the SubstrateVM?
  • Which overhead requires the 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".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM