@@ -61,7 +61,7 @@ Computing metadata in code can be achieved in two ways:
6161 return aClass;
6262 }
6363 }
64- ```
64+ ```
6565
6666 When metadata is computed in code, the dynamically accessed elements will be included into the native executable' s heap only if that part of the heap is reachable through an enclosing method (for example, `ReflectiveAccess#fetchFoo`) or a static field (for example, `InitializedAtBuildTime.aClass`).
6767
@@ -89,6 +89,8 @@ A condition is specified in the following way:
8989An entry with a `typeReachable` condition is considered only when the fully-qualified class is reachable.
9090Currently, we support only `typeReachable` as a condition.
9191
92+ Find more examples of the configuration files in the [GraalVM Reachability Metadata repository](https://github.com/oracle/graalvm-reachability-metadata).
93+
9294## Metadata Types
9395
9496Native Image accepts the following types of reachability metadata:
@@ -144,53 +146,9 @@ Integer.class.getMethod("parseInt", params2);
144146
145147### Specifying Reflection Metadata in JSON
146148
147- Reflection metadata can be specified in the ` reflect-config.json ` file.
148- The JSON file is an array of reflection entries:
149- ``` json
150- [
151- {
152- "condition" : {
153- "typeReachable" : " <condition-class>"
154- },
155- "name" : " <class>" ,
156- "methods" : [
157- {"name" : " <methodName>" , "parameterTypes" : [" <param-one-type>" ]}
158- ],
159- "queriedMethods" : [
160- {"name" : " <methodName>" , "parameterTypes" : [" <param-one-type>" ]}
161- ],
162- "fields" : [
163- {"name" : " <fieldName>" }
164- ],
165- "allDeclaredMethods" : true ,
166- "allDeclaredFields" : true ,
167- "allDeclaredConstructors" : true ,
168- "allPublicMethods" : true ,
169- "allPublicFields" : true ,
170- "allPublicConstructors" : true ,
171- "queryAllDeclaredMethods" : true ,
172- "queryAllDeclaredConstructors" : true ,
173- "queryAllPublicMethods" : true ,
174- "queryAllPublicConstructors" : true ,
175- "unsafeAllocated" : true
176- }
177- ]
178- ```
179-
180- The fields in a reflection entry have the following meaning:
181- - ` condition ` : See [ Conditional Metadata Entries] ( #specifying-metadata-with-json )
182- - ` name ` : Name of the class that will be reflectively looked up. This property is mandatory.
183- - ` methods ` : List class methods that can be looked up and executed reflectively.
184- Each method is described by its name and a list of parameter types.
185- The parameter types are fully qualified Java class names.
186- - ` queriedMethods ` : List of class methods that can only be looked up.
187- The description of each method is identical to the ` methods ` list.
188- - ` fields ` : List of class fields that can be looked up, read, or modified.
189- - ` all<access>(Methods/Fields/Constructors) ` : Registers all methods/fields/constructors for lookup. Methods and constructors can also be invoked.
190- ` <access> ` refers to different ways of querying these members in Java and can be either ` Declared ` or ` Public ` .
191- For more information, see ` java.lang.Class.getDeclaredMethods() ` and ` java.lang.Class.getPublicMethods() ` .
192- - ` queryAll<access>(Methods/Constructors) ` : Registers all methods/constructors for lookup only.
193- - ` unsafeAllocated ` : Allows objects of this class to be allocated using ` Unsafe.allocateInstance ` .
149+ Reflection metadata should be specified in a _reflect-config.json_ file and conform to the JSON schema defined in
150+ [reflect-config-schema-v1.0.0.json](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/reflect-config-schema-v1.0.0.json).
151+ The schema also includes further details and explanations how this configuration works.
194152
195153## Java Native Interface
196154
@@ -213,8 +171,10 @@ The generated metadata entry for the above call would look like:
213171It is not possible to specify JNI metadata in code.
214172
215173### JNI Metadata in JSON
216- Metadata for JNI is provided in ` jni-config.json ` files.
217- The JSON schema of JNI metadata is identical to the [ Reflection metadata schema] ( #specifying-reflection-metadata-in-json ) .
174+
175+ JNI metadata should be specified in a _jni-config.json_ file and conform to the JSON schema defined in
176+ [jni-config-schema-v1.0.0.json](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/jni-config-schema-v1.0.0.json).
177+ The schema also includes further details and explanations how this configuration works.
218178
219179## Resources and Resource Bundles
220180Java is capable of accessing any resource on the application class path, or the module path for which the requesting code has permission to access.
@@ -241,42 +201,10 @@ class Example {
241201```
242202
243203### Resource Metadata in JSON
244- Metadata for resources is provided in ` resource-config.json ` files.
245- ``` json
246- {
247- "resources" : {
248- "includes" : [
249- {
250- "condition" : {
251- "typeReachable" : " <condition-class>"
252- },
253- "pattern" : " .*\\ .txt"
254- }
255- ],
256- "excludes" : [
257- {
258- "condition" : {
259- "typeReachable" : " <condition-class>"
260- },
261- "pattern" : " .*\\ .txt"
262- }
263- ]
264- },
265- "bundles" : [
266- {
267- "condition" : {
268- "typeReachable" : " <condition-class>"
269- },
270- "name" : " fully.qualified.bundle.name" ,
271- "locales" : [" en" , " de" , " sk" ]
272- }
273- ]
274- }
275- ```
276204
277- Native Image will iterate over all resources and match their relative paths against the Java regex specified in ` includes ` .
278- If the path matches the regex, the resource is included .
279- The ` excludes ` statement instructs ` native-image ` to omit certain included resources that match the given ` pattern ` .
205+ Resource metadata should be specified in a _resource-config.json_ file and conform to the JSON schema defined in
206+ [ resource-config-schema-v1.0.0.json](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/resource-config-schema-v1.0.0.json) .
207+ The schema also includes further details and explanations how this configuration works .
280208
281209## Dynamic Proxy
282210
@@ -316,20 +244,10 @@ The following methods are evaluated at build time when called with constant argu
316244 - `java.lang.reflect.Proxy.newProxyInstance`
317245
318246### Dynamic Proxy Metadata in JSON
319- Metadata for dynamic proxies is provided in ` proxy-config.json ` files.
320- ``` json
321- [
322- {
323- "condition" : {
324- "typeReachable" : " <condition-class>"
325- },
326- "interfaces" : [
327- " IA" ,
328- " IB"
329- ]
330- }
331- ]
332- ```
247+
248+ Dynamic proxy metadata should be specified in a _proxy-config.json_ file and conform to the JSON schema defined in
249+ [proxy-config-schema-v1.0.0.json](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/proxy-config-schema-v1.0.0.json).
250+ The schema also includes further details and explanations how this configuration works.
333251
334252## Serialization
335253Java can serialize any class that implements the `Serializable` interface.
@@ -366,42 +284,10 @@ To create a custom constructor for serialization use:
366284Proxy classes can only be registered for serialization via the JSON files.
367285
368286### Serialization Metadata in JSON
369- Metadata for serialization is provided in ` serialization-config.json ` files.
370- ``` json
371- {
372- "types" : [
373- {
374- "condition" : {
375- "typeReachable" : " <condition-class>"
376- },
377- "name" : " <fully-qualified-class-name>" ,
378- "customTargetConstructorClass" : " <custom-target-constructor-class>"
379- }
380- ],
381- "lambdaCapturingTypes" : [
382- {
383- "condition" : {
384- "typeReachable" : " <condition-class>"
385- },
386- "name" : " <fully-qualified-class-name>"
387- }
388- ],
389- "proxies" : [
390- {
391- "condition" : {
392- "typeReachable" : " <condition-class>"
393- },
394- "interfaces" : [" <fully-qualified-interface-name-1>" , " <fully-qualified-interface-name-n>" ]
395- }
396- ]
397- }
398- ```
399-
400- Each entry in ` types ` enables serializing and deserializing objects of the class given by ` name ` .
401287
402- Each entry in ` lambdaCapturingTypes ` enables lambda serialization: all lambdas declared in the methods of the class given by ` name ` can be serialized and deserialized.
403-
404- Each entry in ` proxies ` enables the [ Proxy ] ( https://docs.oracle.com/javase/8/docs/technotes/guides/reflection/proxy.html ) serialization by providing an interface list that a proxy implements .
288+ Serialization metadata should be specified in a _serialization-config.json_ file and conform to the JSON schema defined in
289+ [serialization-config-schema-v1.0.0.json](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/serialization-config-schema-v1.0.0.json).
290+ The schema also includes further details and explanations how this configuration works .
405291
406292## Predefined Classes
407293
@@ -418,22 +304,10 @@ At runtime, if there is an attempt to load a class with the same name and byteco
418304It is not possible to specify predefined classes in code.
419305
420306### Predefined Classes Metadata in JSON
421- Metadata for predefined classes is provided in ` predefined-classes-config.json ` files.
422- ``` json
423- [
424- {
425- "type" : " agent-extracted" ,
426- "classes" : [
427- {
428- "hash" : " <class-bytecodes-hash>" ,
429- "nameInfo" : " <class-name"
430- }
431- ]
432- }
433- ]
434- ```
435307
436- The JSON schema is accompanied by the ` agent-extracted-predefined-classes ` directory that contains the bytecode of the listed classes.
308+ Predefined classes metadata should be specified in a _predefined-classes-config.json_ file and conform to the JSON schema defined in
309+ [predefined-classes-config-schema-v1.0.0.json](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/predefined-classes-config-schema-v1.0.0.json).
310+ The schema also includes further details and explanations how this configuration works.
437311
438312### Further Reading
439313
0 commit comments