Skip to content

Commit 987c983

Browse files
committed
Introduce reachability-metadata.json to replace the various existing -config.json files
1 parent 9f1232f commit 987c983

31 files changed

+1315
-376
lines changed
Lines changed: 362 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,362 @@
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/reachability-metadata-schema-v1.0.0.json",
4+
"title": "JSON schema for the reachability metadata used by GraalVM Native Image",
5+
"type": "object",
6+
"default": {},
7+
"properties": {
8+
"comment": {
9+
"title": "A comment applying to the whole file (e.g., generation date, author, etc.)",
10+
"oneOf": [
11+
{
12+
"type": "string"
13+
},
14+
{
15+
"type": "array",
16+
"items": {
17+
"type": "string"
18+
}
19+
}
20+
],
21+
"default": ""
22+
},
23+
"reflection": {
24+
"title": "Metadata to ensure elements are reachable through reflection",
25+
"$ref": "#/$defs/reflection"
26+
},
27+
"jni": {
28+
"title": "Metadata to ensure elements are reachable through JNI",
29+
"$ref": "#/$defs/reflection"
30+
},
31+
"serialization": {
32+
"title": "Metadata for types that are serialized or deserialized at run time. The types must extend 'java.io.Serializable'.",
33+
"type": "array",
34+
"default": [],
35+
"items": {
36+
"title": "Enables serializing and deserializing objects of the class specified by <type>",
37+
"type": "object",
38+
"properties": {
39+
"reason": {
40+
"title": "Reason for the type's inclusion in the serialization metadata",
41+
"$ref": "#/$defs/reason"
42+
},
43+
"condition": {
44+
"title": "Condition under which the class should be registered for serialization",
45+
"$ref": "#/$defs/condition"
46+
},
47+
"type": {
48+
"title": "Type descriptor of the class that should be registered for serialization",
49+
"$ref": "#/$defs/type"
50+
},
51+
"customTargetConstructorClass": {
52+
"title": "Fully qualified name of the class whose constructor should be used to serialize the class specified by <type>",
53+
"type": "string"
54+
}
55+
},
56+
"required": [
57+
"type"
58+
],
59+
"additionalProperties": false
60+
}
61+
},
62+
"resources": {
63+
"title": "Metadata to ensure resources are available",
64+
"type": "array",
65+
"default": [],
66+
"items": {
67+
"title": "Resource that should be available",
68+
"type": "object",
69+
"properties": {
70+
"reason": {
71+
"title": "Reason for the resource's inclusion in the metadata",
72+
"$ref": "#/$defs/reason"
73+
},
74+
"condition": {
75+
"title": "Condition under which the resource should be registered for runtime access",
76+
"$ref": "#/$defs/condition"
77+
},
78+
"module": {
79+
"title": "Module containing the resource",
80+
"type": "string",
81+
"default": ""
82+
},
83+
"glob": {
84+
"title": "Resource name or pattern matching multiple resources (accepts * and ** wildcards)",
85+
"type": "string"
86+
}
87+
},
88+
"required": [
89+
"glob"
90+
],
91+
"additionalProperties": false
92+
}
93+
},
94+
"bundles": {
95+
"title": "Metadata to ensure resource bundles are available",
96+
"type": "array",
97+
"default": [],
98+
"items": {
99+
"title": "Resource bundle that should be available",
100+
"type": "object",
101+
"properties": {
102+
"reason": {
103+
"title": "Reason for the resource bundle's inclusion in the metadata",
104+
"$ref": "#/$defs/reason"
105+
},
106+
"condition": {
107+
"title": "Condition under which the resource bundle should be registered for runtime access",
108+
"$ref": "#/$defs/condition"
109+
},
110+
"name": {
111+
"title": "Name of the resource bundle",
112+
"type": "string"
113+
},
114+
"locales": {
115+
"title": "List of locales that should be registered for this resource bundle",
116+
"type": "array",
117+
"default": [],
118+
"items": {
119+
"type": "string"
120+
}
121+
}
122+
},
123+
"required": [
124+
"name"
125+
],
126+
"additionalProperties": false
127+
}
128+
}
129+
},
130+
"required": [],
131+
"additionalProperties": false,
132+
133+
"$defs": {
134+
"reflection": {
135+
"type": "array",
136+
"default": [],
137+
"items": {
138+
"title": "Elements that should be registered for reflection for a specified type",
139+
"type": "object",
140+
"properties": {
141+
"reason": {
142+
"title": "Reason for the element's inclusion",
143+
"$ref": "#/$defs/reason"
144+
},
145+
"condition": {
146+
"title": "Condition under which the class should be registered for reflection",
147+
"$ref": "#/$defs/condition"
148+
},
149+
"type": {
150+
"title": "Type descriptor of the class that should be registered for reflection",
151+
"$ref": "#/$defs/type"
152+
},
153+
"methods": {
154+
"title": "List of methods that should be registered for the type declared in <type>",
155+
"type": "array",
156+
"default": [],
157+
"items": {
158+
"title": "Method descriptor of the method that should be registered for reflection",
159+
"$ref": "#/$defs/method"
160+
}
161+
},
162+
"fields": {
163+
"title": "List of class fields that can be read or written to for the type declared in <type>",
164+
"type": "array",
165+
"default": [],
166+
"items": {
167+
"title": "Field descriptor of the field that should be registered for reflection",
168+
"$ref": "#/$defs/field"
169+
}
170+
},
171+
"allDeclaredMethods": {
172+
"title": "Register all declared methods from the type for reflective invocation",
173+
"type": "boolean",
174+
"default": false
175+
},
176+
"allDeclaredFields": {
177+
"title": "Register all declared fields from the type for reflective access",
178+
"type": "boolean",
179+
"default": false
180+
},
181+
"allDeclaredConstructors": {
182+
"title": "Register all declared constructors from the type for reflective invocation",
183+
"type": "boolean",
184+
"default": false
185+
},
186+
"allPublicMethods": {
187+
"title": "Register all public methods from the type for reflective invocation",
188+
"type": "boolean",
189+
"default": false
190+
},
191+
"allPublicFields": {
192+
"title": "Register all public fields from the type for reflective access",
193+
"type": "boolean",
194+
"default": false
195+
},
196+
"allPublicConstructors": {
197+
"title": "Register all public constructors from the type for reflective invocation",
198+
"type": "boolean",
199+
"default": false
200+
},
201+
"unsafeAllocated": {
202+
"title": "Allow objects of this class to be instantiated with a call to jdk.internal.misc.Unsafe#allocateInstance or JNI's AllocObject",
203+
"type": "boolean",
204+
"default": false
205+
}
206+
},
207+
"additionalProperties": false
208+
}
209+
},
210+
"jni": {
211+
"type": "array",
212+
"default": [],
213+
"items": {
214+
"title": "Elements that should be registered for JNI for a specified type",
215+
"type": "object",
216+
"properties": {
217+
"reason": {
218+
"title": "Reason for the element's inclusion",
219+
"$ref": "#/$defs/reason"
220+
},
221+
"condition": {
222+
"title": "Condition under which the class should be registered for JNI",
223+
"$ref": "#/$defs/condition"
224+
},
225+
"type": {
226+
"title": "Type descriptor of the class that should be registered for JNI",
227+
"$ref": "#/$defs/type"
228+
},
229+
"methods": {
230+
"title": "List of methods that should be registered for the type declared in <type>",
231+
"type": "array",
232+
"default": [],
233+
"items": {
234+
"title": "Method descriptor of the method that should be registered for JNI",
235+
"$ref": "#/$defs/method"
236+
}
237+
},
238+
"fields": {
239+
"title": "List of class fields that can be read or written to for the type declared in <type>",
240+
"type": "array",
241+
"default": [],
242+
"items": {
243+
"title": "Field descriptor of the field that should be registered for JNI",
244+
"$ref": "#/$defs/field"
245+
}
246+
},
247+
"allDeclaredMethods": {
248+
"title": "Register all declared methods from the type for JNI access",
249+
"type": "boolean",
250+
"default": false
251+
},
252+
"allDeclaredFields": {
253+
"title": "Register all declared fields from the type for JNI access",
254+
"type": "boolean",
255+
"default": false
256+
},
257+
"allDeclaredConstructors": {
258+
"title": "Register all declared constructors from the type for JNI access",
259+
"type": "boolean",
260+
"default": false
261+
},
262+
"allPublicMethods": {
263+
"title": "Register all public methods from the type for JNI access",
264+
"type": "boolean",
265+
"default": false
266+
},
267+
"allPublicFields": {
268+
"title": "Register all public fields from the type for JNI access",
269+
"type": "boolean",
270+
"default": false
271+
},
272+
"allPublicConstructors": {
273+
"title": "Register all public constructors from the type for JNI access",
274+
"type": "boolean",
275+
"default": false
276+
}
277+
},
278+
"additionalProperties": false
279+
}
280+
},
281+
"reason": {
282+
"type": "string",
283+
"default": []
284+
},
285+
"condition": {
286+
"title": "Condition used by GraalVM Native Image metadata files",
287+
"type": "object",
288+
"properties": {
289+
"typeReached": {
290+
"title": "Type descriptor of a class that must be reached in order to enable the corresponding registration",
291+
"$ref": "#/$defs/type"
292+
}
293+
},
294+
"required": [
295+
"typeReached"
296+
],
297+
"additionalProperties": false
298+
},
299+
"type": {
300+
"title": "Type descriptors used by GraalVM Native Image metadata files",
301+
"oneOf": [
302+
{
303+
"type": "string"
304+
},
305+
{
306+
"type": "object",
307+
"properties": {
308+
"proxy": {
309+
"title": "List of interfaces defining the proxy class",
310+
"type": "array",
311+
"default": [],
312+
"items": {
313+
"title": "Fully qualified name of the interface defining the proxy class",
314+
"type": "string"
315+
}
316+
}
317+
},
318+
"required": [
319+
"proxy"
320+
],
321+
"additionalProperties": false
322+
}
323+
]
324+
},
325+
"method": {
326+
"title": "Method descriptors used by GraalVM Native Image metadata files",
327+
"type": "object",
328+
"properties": {
329+
"name": {
330+
"title": "Method name that should be registered for this class",
331+
"type": "string"
332+
},
333+
"parameterTypes": {
334+
"default": [],
335+
"items": {
336+
"title": "List of the method's parameter types",
337+
"type": "string"
338+
},
339+
"type": "array"
340+
}
341+
},
342+
"required": [
343+
"name"
344+
],
345+
"additionalProperties": false
346+
},
347+
"field": {
348+
"title": "Field descriptors used by GraalVM Native Image metadata files",
349+
"type": "object",
350+
"properties": {
351+
"name": {
352+
"title": "Name of the field that should be registered for reflection",
353+
"type": "string"
354+
}
355+
},
356+
"required": [
357+
"name"
358+
],
359+
"additionalProperties": false
360+
}
361+
}
362+
}

substratevm/src/com.oracle.svm.configure.test/src/com/oracle/svm/configure/test/config/OmitPreviousConfigTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ class TypeMethodsWithFlagsTest {
233233
final Map<ConfigurationMethod, ConfigurationMemberDeclaration> methodsThatMustExist = new HashMap<>();
234234
final Map<ConfigurationMethod, ConfigurationMemberDeclaration> methodsThatMustNotExist = new HashMap<>();
235235

236-
final TypeConfiguration previousConfig = new TypeConfiguration();
237-
final TypeConfiguration currentConfig = new TypeConfiguration();
236+
final TypeConfiguration previousConfig = new TypeConfiguration("");
237+
final TypeConfiguration currentConfig = new TypeConfiguration("");
238238

239239
TypeMethodsWithFlagsTest(ConfigurationMemberDeclaration methodKind) {
240240
this.methodKind = methodKind;

substratevm/src/com.oracle.svm.configure.test/src/com/oracle/svm/configure/test/config/ResourceConfigurationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public void printJson() {
8080

8181
Thread writerThread = new Thread(() -> {
8282
try (JsonWriter w = jw) {
83-
rc.printJson(w);
83+
rc.printLegacyJson(w);
8484
} catch (IOException e) {
8585
Assert.fail(e.getMessage());
8686
}
@@ -130,7 +130,7 @@ public void addClassBasedResourceBundle(UnresolvedConfigurationCondition conditi
130130
}
131131
};
132132

133-
ResourceConfigurationParser<UnresolvedConfigurationCondition> rcp = new ResourceConfigurationParser<>(ConfigurationConditionResolver.identityResolver(), registry, true);
133+
ResourceConfigurationParser<UnresolvedConfigurationCondition> rcp = ResourceConfigurationParser.create(false, ConfigurationConditionResolver.identityResolver(), registry, true);
134134
writerThread.start();
135135
rcp.parseAndRegister(pr);
136136

0 commit comments

Comments
 (0)