Native Image Quick Reference

Native Image Quick Reference

Native Image Quick Reference Build a native IMAGE Build an optimized Native Image Configure a Native Image Build a native image from a JAR file with all dependencies: Build an image with profile-guided optimizations: Static analysis requires configuration for some language native-image [options] -jar myApp.jar native-image --pgo-instrument MyApp [imagename] features: accessing resources, serialization, reflection, JNI, Run the image to record the profile:./myapp etc. specify classes search path for directories, JARs, ZIPs: native-image --pgo default.iprof MyApp -cp jar:com/package/**/myApp.jar select GraalVM’s garbage collector implementation: Run a Java process with tracing agent to generate the configuration: specify the custom main class: --gc=G1 java -agentlib:native-image-agent= -H:Class=MyApp config-output-dir=/path/to/config-dir/ Control classes initialization at build or run time: Build a shared library -jar MyApp.jar --initialize-at-build/run-time= specify the configuration to use for building a native image: native-image -jar jarfile [libraryname] com.example.MyClass,org.package -H:ConfigurationFileDirectories=/path/to/ --shared Include resources matching Java RegEx: config-dir/ -H:IncludeResource=/com/package/**/file.xml Enable HTTPs support: annotate the entry point method(s) with the Configuration files in METa-INF/native-image on the classpath are included automatically. --enable-https @CEntryPoInt annotation. Entry point methods must be static, have non-object parameters and return types. Install exit handlers: Configure memory at run time: --install-exit-handlers ./imagename -Xmx<m> -Xmn<m> Include all security service classes: @CEntryPoint Configure default heap settings at build time: --enable-all-security-services static int add(IsolateThread thread,int a, int b) { -R:MaxHeapSize=<m> -R:MaxNewSize=<m> return a + b; Add all charsets support: } Debug a Native Image -H:+AddAllCharsets Build a native image with debug information: Include all timezones pre-initialized: -g -H:+IncludeAllTimezones Java Native image Print garbage collection logs: Build a statically linked image with libc implementation: Binary code bytecode build ./imagename -XX:+PrintGC -XX:+VerboseGC --static --libc=glibc|musl Your app Trace the initialization path for a certain class: Build a statically linked image with libc dynamically linked (distroless): Static analysis Compile code -H:+TraceClassInitialization= -H:+StaticExecutableWithDynamicLibC Code package.class.Name Dependencies Initialization Enable polyglot support: Image heap Print classes intialized detected by the static analysis: --language:java|js|python|ruby|llvm|wasm store -H:+PrintClassInitialization JDK classes Snapshot image heap Attach a debugger to the build process: Gather the diagnostic data for GraalVM Dashboard: --debug-attach=[port] -H:+DashboardAll -H:DashboardDump=<path> More info at www.graalvm.org ver: 2.000.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    1 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us