Skip to content

Commit cd25252

Browse files
committed
Add links to schema files in ReachabilityMetadata.md
1 parent e827e7f commit cd25252

7 files changed

+23
-153
lines changed

docs/reference-manual/native-image/ReachabilityMetadata.md

Lines changed: 11 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -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:
8989
An entry with a `typeReachable` condition is considered only when the fully-qualified class is reachable.
9090
Currently, we support only `typeReachable` as a condition.
9191
92+
**Examples of the config files can be found in [GraalVM Reachability Metadata repository](https://github.com/oracle/graalvm-reachability-metadata)**
93+
9294
## Metadata Types
9395
9496
Native Image accepts the following types of reachability metadata:
@@ -144,53 +146,8 @@ 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 can be specified in the `reflect-config.json` file.
150+
Detailed explanation of the config file can be found in the corresponding [json schema](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/reflect-config-schema-v1.0.0.json).
194151
195152
## Java Native Interface
196153
@@ -214,7 +171,7 @@ It is not possible to specify JNI metadata in code.
214171
215172
### JNI Metadata in JSON
216173
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+
Detailed explanation of the config file can be found in the corresponding [json schema](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/jni-config-schema-v1.0.0.json).
218175
219176
## Resources and Resource Bundles
220177
Java is capable of accessing any resource on the application class path, or the module path for which the requesting code has permission to access.
@@ -242,41 +199,7 @@ class Example {
242199
243200
### Resource Metadata in JSON
244201
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-
```
276-
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`.
202+
Detailed explanation of the config file can be found in the corresponding [json schema](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/resource-config-schema-v1.0.0.json).
280203
281204
## Dynamic Proxy
282205
@@ -316,20 +239,8 @@ The following methods are evaluated at build time when called with constant argu
316239
- `java.lang.reflect.Proxy.newProxyInstance`
317240
318241
### 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-
```
242+
Metadata for resources is provided in `proxy-config.json` files.
243+
Detailed explanation of the config file can be found in the corresponding [json schema](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/proxy-config-schema-v1.0.0.json).
333244
334245
## Serialization
335246
Java can serialize any class that implements the `Serializable` interface.
@@ -367,41 +278,7 @@ Proxy classes can only be registered for serialization via the JSON files.
367278
368279
### Serialization Metadata in JSON
369280
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`.
401-
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.
281+
Detailed explanation of the config file can be found in the corresponding [json schema](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/serialization-config-schema-v1.0.0.json).
405282
406283
## Predefined Classes
407284
@@ -419,21 +296,7 @@ It is not possible to specify predefined classes in code.
419296
420297
### Predefined Classes Metadata in JSON
421298
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-
```
435-
436-
The JSON schema is accompanied by the `agent-extracted-predefined-classes` directory that contains the bytecode of the listed classes.
299+
Detailed explanation of the config file can be found in the corresponding [json schema](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/predefined-classes-config-schema-v1.0.0.json).
437300
438301
### Further Reading
439302

docs/reference-manual/native-image/assets/jni-config-schema-v1.0.0.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"$schema": "https://json-schema.org/draft/2019-09/schema",
3+
"$id": "https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/jni-config-schema-v1.0.0.json",
34
"default": [],
45
"items": {
56
"properties": {

docs/reference-manual/native-image/assets/predefined-classes-config-schema-v1.0.0.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"$schema": "https://json-schema.org/draft/2019-09/schema",
3+
"$id": "https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/predefined-classes-config-schema-v1.0.0.json",
34
"default": [
45
{
56
"type": "agent-extracted",

docs/reference-manual/native-image/assets/proxy-config-schema-v1.0.0.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"$schema": "https://json-schema.org/draft/2019-09/schema",
3+
"$id": "https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/proxy-config-schema-v1.0.0.json",
34
"default": [],
45
"items": {
56
"properties": {

docs/reference-manual/native-image/assets/reflect-config-schema-v1.0.0.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"$schema": "https://json-schema.org/draft/2019-09/schema",
3+
"$id": "https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/reflect-config-schema-v1.0.0.json",
34
"default": [],
45
"items": {
56
"properties": {
@@ -86,7 +87,7 @@
8687
"type": "object"
8788
},
8889
"type": "array",
89-
"title": "List of fields that should be registered for the class declared in <name>"
90+
"title": "List of class fields that can be looked up, read, or modified for the class declared in <name>"
9091
},
9192
"allDeclaredMethods": {
9293
"default": false,

docs/reference-manual/native-image/assets/resource-config-schema-v1.0.0.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"$schema": "https://json-schema.org/draft/2019-09/schema",
3+
"$id": "https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/resource-config-schema-v1.0.0.json",
34
"default": {
45
"resources": {},
56
"bundles": []
@@ -103,5 +104,6 @@
103104
"resources"
104105
],
105106
"type": "object",
106-
"title": "JSON schema for the resource-config that GraalVM Native Image uses"
107+
"title": "JSON schema for the resource-config that GraalVM Native Image uses",
108+
"description": "Native Image will iterate over all resources and match their relative paths against the Java regex specified in <includes>.If the path matches the regex, the resource is included. The <excludes> statement instructs <native-image> to omit certain included resources that match the given <pattern>"
107109
}

docs/reference-manual/native-image/assets/serialization-config-schema-v1.0.0.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"$schema": "https://json-schema.org/draft/2019-09/schema",
3+
"$id": "https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/serialization-config-schema-v1.0.0.json",
34
"default": {
45
"types": [],
56
"lambdaCapturingTypes": [],
@@ -33,7 +34,7 @@
3334
},
3435
"type": "object"
3536
},
36-
"title": "List of classes that should be serialized",
37+
"title": "Each entry in <types> enables serializing and deserializing objects of the class given by <name>",
3738
"type": "array"
3839
},
3940
"lambdaCapturingTypes": {
@@ -59,7 +60,7 @@
5960
},
6061
"type": "object"
6162
},
62-
"title": "List of classes that capture lambdas that should be serialized",
63+
"title": "Each entry in <lambdaCapturingTypes> enables lambda serialization. All lambdas declared in the methods of the class given by <name> can be serialized and deserialized.",
6364
"type": "array"
6465
},
6566
"proxies": {
@@ -93,7 +94,7 @@
9394
"type": "object",
9495
"title": "Proxy that should be registered for serialization"
9596
},
96-
"title": "List of proxies that should be serialized",
97+
"title": "Each entry in <proxies> enables the proxy serialization by providing an interface list that a proxy implements.",
9798
"type": "array"
9899
}
99100
},

0 commit comments

Comments
 (0)