Skip to content

Commit ca74ebd

Browse files
committed
Introduce reasons attribute in json configuration schemas
Closes #8543
1 parent d1196be commit ca74ebd

File tree

7 files changed

+737
-12
lines changed

7 files changed

+737
-12
lines changed

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

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ 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.1.0.json](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/reflect-config-schema-v1.1.0.json).
150+
[reflect-config-schema-v1.2.0.json](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/reflect-config-schema-v1.2.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
[
@@ -181,7 +181,10 @@ The schema also includes further details and explanations how this configuration
181181
"queryAllDeclaredConstructors": true,
182182
"queryAllPublicMethods": true,
183183
"queryAllPublicConstructors": true,
184-
"unsafeAllocated": true
184+
"unsafeAllocated": true,
185+
"reasons": [
186+
"Created for Demo purposes"
187+
]
185188
}
186189
]
187190
```
@@ -209,7 +212,7 @@ It is not possible to specify JNI metadata in code.
209212
### JNI Metadata in JSON
210213
211214
JNI metadata should be specified in a _jni-config.json_ file and conform to the JSON schema defined in
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).
215+
[jni-config-schema-v1.2.0.json](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/jni-config-schema-v1.2.0.json).
213216
The schema also includes further details and explanations how this configuration works. The example of jni-config.json is the same
214217
as the example of reflect-config.json described above.
215218
@@ -240,7 +243,7 @@ class Example {
240243
### Resource Metadata in JSON
241244
242245
Resource metadata should be specified in a _resource-config.json_ file and conform to the JSON schema defined in
243-
[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).
246+
[resource-config-schema-v1.1.0.json](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/resource-config-schema-v1.1.0.json).
244247
The schema also includes further details and explanations how this configuration works. Here is the example of the resource-config.json:
245248
```json
246249
{
@@ -250,15 +253,21 @@ The schema also includes further details and explanations how this configuration
250253
"condition": {
251254
"typeReachable": "<condition-class>"
252255
},
253-
"pattern": ".*\\.txt"
256+
"pattern": ".*\\.txt",
257+
"reasons": [
258+
"We want all txt files"
259+
]
254260
}
255261
],
256262
"excludes": [
257263
{
258264
"condition": {
259265
"typeReachable": "<condition-class>"
260266
},
261-
"pattern": ".*\\.txt"
267+
"pattern": ".*\\.txt",
268+
"reasons": [
269+
"We want no txt files"
270+
]
262271
}
263272
]
264273
},
@@ -268,7 +277,11 @@ The schema also includes further details and explanations how this configuration
268277
"typeReachable": "<condition-class>"
269278
},
270279
"name": "fully.qualified.bundle.name",
271-
"locales": ["en", "de", "sk"]
280+
"locales": ["en", "de", "sk"],
281+
"reasons": [
282+
"That's a useful bundle",
283+
"We support English, German, and Slovak"
284+
]
272285
},
273286
{
274287
"condition": {
@@ -278,6 +291,9 @@ The schema also includes further details and explanations how this configuration
278291
"classNames": [
279292
"fully.qualified.bundle.name_en",
280293
"fully.qualified.bundle.name_de"
294+
],
295+
"reasons": [
296+
"English and German have their one additional bundles"
281297
]
282298
}
283299
]
@@ -324,7 +340,7 @@ The following methods are evaluated at build time when called with constant argu
324340
### Dynamic Proxy Metadata in JSON
325341
326342
Dynamic proxy metadata should be specified in a _proxy-config.json_ file and conform to the JSON schema defined in
327-
[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).
343+
[proxy-config-schema-v1.1.0.json](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/proxy-config-schema-v1.1.0.json).
328344
The schema also includes further details and explanations how this configuration works. Here is the example of the proxy-config.json:
329345
```json
330346
[
@@ -335,6 +351,9 @@ The schema also includes further details and explanations how this configuration
335351
"interfaces": [
336352
"IA",
337353
"IB"
354+
],
355+
"reasons": [
356+
"We generate dynamic proxies for IA and IB"
338357
]
339358
}
340359
]
@@ -377,7 +396,7 @@ Proxy classes can only be registered for serialization via the JSON files.
377396
### Serialization Metadata in JSON
378397
379398
Serialization metadata should be specified in a _serialization-config.json_ file and conform to the JSON schema defined in
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).
399+
[serialization-config-schema-v1.2.0.json](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/serialization-config-schema-v1.2.0.json).
381400
The schema also includes further details and explanations how this configuration works. Here is the example of the serialization-config.json:
382401
```json
383402
{
@@ -387,23 +406,32 @@ The schema also includes further details and explanations how this configuration
387406
"typeReachable": "<condition-class>"
388407
},
389408
"type": "<fully-qualified-class-name>",
390-
"customTargetConstructorClass": "<custom-target-constructor-class>"
409+
"customTargetConstructorClass": "<custom-target-constructor-class>",
410+
"reasons": [
411+
"Serialized by MyClass"
412+
]
391413
}
392414
],
393415
"lambdaCapturingTypes": [
394416
{
395417
"condition": {
396418
"typeReachable": "<condition-class>"
397419
},
398-
"name": "<fully-qualified-class-name>"
420+
"name": "<fully-qualified-class-name>",
421+
"reasons": [
422+
"Serialized by MyClass"
423+
]
399424
}
400425
],
401426
"proxies": [
402427
{
403428
"condition": {
404429
"typeReachable": "<condition-class>"
405430
},
406-
"interfaces": ["<fully-qualified-interface-name-1>", "<fully-qualified-interface-name-n>"]
431+
"interfaces": ["<fully-qualified-interface-name-1>", "<fully-qualified-interface-name-n>"],
432+
"reasons": [
433+
"Generated dynamic proxies for interfaces 1 and 2"
434+
]
407435
}
408436
]
409437
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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-reasons-schema-v1.0.0.json",
4+
"type": "array",
5+
"default": [],
6+
"items": {
7+
"type": "string"
8+
},
9+
"title": "JSON schema for the reasons justifying a configuration"
10+
}
Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
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.2.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+
"reasons": {
189+
"$ref": "config-reasons-schema-v1.0.0.json",
190+
"title": "List of reasons justifying the configuration"
191+
}
192+
},
193+
"additionalProperties": false,
194+
"type": "object"
195+
},
196+
"type": "array",
197+
"title": "JSON schema for the JNI configuration that GraalVM Native Image uses"
198+
}

0 commit comments

Comments
 (0)