Skip to content

Commit 9ede285

Browse files
committed
Introduce more flexible type descriptors for JSON configuration
1 parent 4adb1ee commit 9ede285

24 files changed

+767
-68
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ The JSON file consists of entries that tell Native Image the elements to include
7272
For example, Java reflection metadata is specified in `reflect-config.json`, and a sample entry looks like:
7373
```json
7474
{
75-
"name": "Foo"
75+
"type": "Foo"
7676
}
7777
```
7878
@@ -147,15 +147,15 @@ Integer.class.getMethod("parseInt", params2);
147147
### Specifying Reflection Metadata in JSON
148148
149149
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).
150+
[reflect-config-schema-v1.1.0.json](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/reflect-config-schema-v1.1.0.json).
151151
The schema also includes further details and explanations how this configuration works. Here is the example of the reflect-config.json:
152152
```json
153153
[
154154
{
155155
"condition": {
156156
"typeReachable": "<condition-class>"
157157
},
158-
"name": "<class>",
158+
"type": "<class>",
159159
"methods": [
160160
{"name": "<methodName>", "parameterTypes": ["<param-one-type>"]}
161161
],
@@ -199,7 +199,7 @@ looks up the `java.lang.String` class, which can then be used, for example, to i
199199
The generated metadata entry for the above call would look like:
200200
```json
201201
{
202-
"name": "java.lang.String"
202+
"type": "java.lang.String"
203203
}
204204
```
205205
@@ -209,7 +209,7 @@ It is not possible to specify JNI metadata in code.
209209
### JNI Metadata in JSON
210210
211211
JNI metadata should be specified in a _jni-config.json_ file and conform to the JSON schema defined in
212-
[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).
212+
[jni-config-schema-v1.1.0.json](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/jni-config-schema-v1.1.0.json).
213213
The schema also includes further details and explanations how this configuration works. The example of jni-config.json is the same
214214
as the example of reflect-config.json described above.
215215
@@ -377,7 +377,7 @@ Proxy classes can only be registered for serialization via the JSON files.
377377
### Serialization Metadata in JSON
378378
379379
Serialization metadata should be specified in a _serialization-config.json_ file and conform to the JSON schema defined in
380-
[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).
380+
[serialization-config-schema-v1.1.0.json](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/serialization-config-schema-v1.1.0.json).
381381
The schema also includes further details and explanations how this configuration works. Here is the example of the serialization-config.json:
382382
```json
383383
{
@@ -386,7 +386,7 @@ The schema also includes further details and explanations how this configuration
386386
"condition": {
387387
"typeReachable": "<condition-class>"
388388
},
389-
"name": "<fully-qualified-class-name>",
389+
"type": "<fully-qualified-class-name>",
390390
"customTargetConstructorClass": "<custom-target-constructor-class>"
391391
}
392392
],
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2019-09/schema",
3+
"$id": "https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/config-condition-schema-v1.0.0.json",
4+
"title": "JSON schema for the conditions used in GraalVM Native Image configuration files",
5+
"properties": {
6+
"typeReachable": {
7+
"type": "string",
8+
"title": "Fully qualified name of a class that must be reachable in order to register the type <type> for reflection"
9+
}
10+
},
11+
"required": [
12+
"typeReachable"
13+
],
14+
"additionalProperties": false,
15+
"type": "object"
16+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2019-09/schema",
3+
"$id": "https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/config-type-schema-v1.0.0.json",
4+
"type": "string",
5+
"title": "JSON schema for the type descriptors GraalVM Native Image configuration files use"
6+
}
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
{
2+
"$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.1.0.json",
4+
"default": [],
5+
"items": {
6+
"properties": {
7+
"condition": {
8+
"$ref": "config-condition-schema-v1.0.0.json",
9+
"title": "Condition under which the class should be registered for access through JNI"
10+
},
11+
"type": {
12+
"$ref": "config-type-schema-v1.0.0.json",
13+
"title": "Type descriptor of the class that should be registered for access through JNI"
14+
},
15+
"name": {
16+
"deprecated": true,
17+
"type": "string",
18+
"title": "Name of the class that should be registered for access through JNI"
19+
},
20+
"methods": {
21+
"default": [],
22+
"items": {
23+
"properties": {
24+
"name": {
25+
"type": "string",
26+
"title": "Method name that should be registered for this class"
27+
},
28+
"parameterTypes": {
29+
"default": [],
30+
"items": {
31+
"type": "string",
32+
"title": "List of the method's parameter types"
33+
},
34+
"type": "array"
35+
}
36+
},
37+
"required": [
38+
"name"
39+
],
40+
"additionalProperties": false,
41+
"type": "object",
42+
"title": "List of methods from this class that are registered for access through JNI"
43+
},
44+
"type": "array",
45+
"title": "List of methods that should be registered for the class declared in <name>"
46+
},
47+
"queriedMethods": {
48+
"deprecated": true,
49+
"default": [],
50+
"items": {
51+
"properties": {
52+
"name": {
53+
"type": "string",
54+
"title": "Method name that are queried for this class"
55+
},
56+
"parameterTypes": {
57+
"default": [],
58+
"items": {
59+
"type": "string",
60+
"title": "List of types for the parameters of the this method"
61+
},
62+
"type": "array",
63+
"title": "List of methods to register for this class that are only looked up but not invoked."
64+
}
65+
},
66+
"required": [
67+
"name"
68+
],
69+
"additionalProperties": false,
70+
"type": "object"
71+
},
72+
"type": "array",
73+
"title": "List of methods that are queried for the class declared in <name>"
74+
},
75+
"fields": {
76+
"default": [],
77+
"items": {
78+
"properties": {
79+
"name": {
80+
"type": "string",
81+
"title": "Name of the field that should be registered for access through JNI"
82+
}
83+
},
84+
"required": [
85+
"name"
86+
],
87+
"additionalProperties": false,
88+
"type": "object"
89+
},
90+
"type": "array",
91+
"title": "List of fields that should be registered for the class declared in <name>"
92+
},
93+
"allDeclaredClasses": {
94+
"deprecated": true,
95+
"default": false,
96+
"type": "boolean",
97+
"title": "Register classes which would be returned by the java.lang.Class#getDeclaredClasses call"
98+
},
99+
"allDeclaredMethods": {
100+
"default": false,
101+
"type": "boolean",
102+
"title": "Register methods which would be returned by the java.lang.Class#getDeclaredMethods call"
103+
},
104+
"allDeclaredFields": {
105+
"default": false,
106+
"type": "boolean",
107+
"title": "Register fields which would be returned by the java.lang.Class#getDeclaredFields call"
108+
},
109+
"allDeclaredConstructors": {
110+
"default": false,
111+
"type": "boolean",
112+
"title": "Register constructors which would be returned by the java.lang.Class#getDeclaredConstructors call"
113+
},
114+
"allPublicClasses": {
115+
"deprecated": true,
116+
"default": false,
117+
"type": "boolean",
118+
"title": "Register all public classes which would be returned by the java.lang.Class#getClasses call"
119+
},
120+
"allPublicMethods": {
121+
"default": false,
122+
"type": "boolean",
123+
"title": "Register all public methods which would be returned by the java.lang.Class#getMethods call"
124+
},
125+
"allPublicFields": {
126+
"default": false,
127+
"type": "boolean",
128+
"title": "Register all public fields which would be returned by the java.lang.Class#getFields call"
129+
},
130+
"allPublicConstructors": {
131+
"default": false,
132+
"type": "boolean",
133+
"title": "Register all public constructors which would be returned by the java.lang.Class#getConstructors call"
134+
},
135+
"allRecordComponents": {
136+
"deprecated": true,
137+
"default": false,
138+
"type": "boolean",
139+
"title": "Register record components which would be returned by the java.lang.Class#getRecordComponents call"
140+
},
141+
"allPermittedSubclasses": {
142+
"deprecated": true,
143+
"default": false,
144+
"type": "boolean",
145+
"title": "Register permitted subclasses which would be returned by the java.lang.Class#getPermittedSubclasses call"
146+
},
147+
"allNestMembers": {
148+
"deprecated": true,
149+
"default": false,
150+
"type": "boolean",
151+
"title": "Register nest members which would be returned by the java.lang.Class#getNestMembers call"
152+
},
153+
"allSigners": {
154+
"deprecated": true,
155+
"default": false,
156+
"type": "boolean",
157+
"title": "Register signers which would be returned by the java.lang.Class#getSigners call"
158+
},
159+
"queryAllDeclaredMethods": {
160+
"deprecated": true,
161+
"default": false,
162+
"type": "boolean",
163+
"title": "Register methods which would be returned by the java.lang.Class#getDeclaredMethods call but only for lookup"
164+
},
165+
"queryAllDeclaredConstructors": {
166+
"deprecated": true,
167+
"default": false,
168+
"type": "boolean",
169+
"title": "Register constructors which would be returned by the java.lang.Class#getDeclaredConstructors call but only for lookup"
170+
},
171+
"queryAllPublicMethods": {
172+
"deprecated": true,
173+
"default": false,
174+
"type": "boolean",
175+
"title": "Register all public methods which would be returned by the java.lang.Class#getMethods call but only for lookup"
176+
},
177+
"queryAllPublicConstructors": {
178+
"deprecated": true,
179+
"default": false,
180+
"type": "boolean",
181+
"title": "Register all public constructors which would be returned by the java.lang.Class#getConstructors call but only for lookup"
182+
},
183+
"unsafeAllocated": {
184+
"default": false,
185+
"type": "boolean",
186+
"title": "Allow objects of this class to be instantiated with a call to jdk.internal.misc.Unsafe#allocateInstance"
187+
}
188+
},
189+
"additionalProperties": false,
190+
"type": "object"
191+
},
192+
"type": "array",
193+
"title": "JSON schema for the JNI configuration that GraalVM Native Image uses"
194+
}

0 commit comments

Comments
 (0)