Java Magazine, May/June 2019
ORACLE COM JAVAMAGAZINE MAY JUNE 2019 46 containers name greet parameterTypes This file specifies which classes methods and constructors will be accessed reflectively In a similar manner you would typically need to configure Java Native Interface JNI access if the application you are compiling to a native image uses JNI You might imagine that providing such a configuration could become annoying especially if the code that uses reflection is not yours but comes from a dependency In such a case you can use the configuration javaagent that GraalVM provides Run your application with the agent attached and it will record all uses of reflection JNI and anything else that you need to configure for the native image path to graalvm bin java agentlib native image agent trace output path to trace file json You can run it multiple times producing diferent trace files to ensure that all relevant code paths are executed at least once and the native image utility has the full picture of the code you want to run You can run the tracing agent when you execute tests Tests usually cover the most important code path If not perhaps you should correct that first When traces are collected you can turn them into a native image configuration file native image tool native image configure native image configure process trace output dir path to config dir path to trace file json
You must have JavaScript enabled to view digital editions.