Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce reasons attribute in json configuration schemas #8962

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 36 additions & 11 deletions docs/reference-manual/native-image/ReachabilityMetadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ Integer.class.getMethod("parseInt", params2);
### Specifying Reflection Metadata in JSON

Reflection metadata should be specified in a _reflect-config.json_ file and conform to the JSON schema defined in
[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).
[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).
The schema also includes further details and explanations how this configuration works. Here is the example of the reflect-config.json:
```json
[
Expand Down Expand Up @@ -181,7 +181,10 @@ The schema also includes further details and explanations how this configuration
"queryAllDeclaredConstructors": true,
"queryAllPublicMethods": true,
"queryAllPublicConstructors": true,
"unsafeAllocated": true
"unsafeAllocated": true,
"reasons": [
"Created for Demo purposes"
]
}
]
```
Expand Down Expand Up @@ -209,7 +212,7 @@ It is not possible to specify JNI metadata in code.
### JNI Metadata in JSON

JNI metadata should be specified in a _jni-config.json_ file and conform to the JSON schema defined in
[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).
[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).
The schema also includes further details and explanations how this configuration works. The example of jni-config.json is the same
as the example of reflect-config.json described above.

Expand Down Expand Up @@ -240,7 +243,7 @@ class Example {
### Resource Metadata in JSON

Resource metadata should be specified in a _resource-config.json_ file and conform to the JSON schema defined in
[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).
[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).
The schema also includes further details and explanations how this configuration works. Here is the example of the resource-config.json:
```json
{
Expand All @@ -250,15 +253,21 @@ The schema also includes further details and explanations how this configuration
"condition": {
"typeReachable": "<condition-class>"
},
"pattern": ".*\\.txt"
"pattern": ".*\\.txt",
"reasons": [
"We want all txt files"
]
}
],
"excludes": [
{
"condition": {
"typeReachable": "<condition-class>"
},
"pattern": ".*\\.txt"
"pattern": ".*\\.txt",
"reasons": [
"We want no txt files"
]
}
]
},
Expand All @@ -268,7 +277,11 @@ The schema also includes further details and explanations how this configuration
"typeReachable": "<condition-class>"
},
"name": "fully.qualified.bundle.name",
"locales": ["en", "de", "sk"]
"locales": ["en", "de", "sk"],
"reasons": [
"That's a useful bundle",
"We support English, German, and Slovak"
]
},
{
"condition": {
Expand All @@ -278,6 +291,9 @@ The schema also includes further details and explanations how this configuration
"classNames": [
"fully.qualified.bundle.name_en",
"fully.qualified.bundle.name_de"
],
"reasons": [
"English and German have their one additional bundles"
]
}
]
Expand Down Expand Up @@ -337,7 +353,10 @@ Here is an example of dynamic proxy metadata in reflect-config.json:
"type": { "proxy": [
"IA",
"IB"
]}
]},
"reasons": [
"We generate dynamic proxies for IA and IB"
]
}
]
```
Expand Down Expand Up @@ -381,7 +400,7 @@ Proxy classes can only be registered for serialization via the JSON files.
### Serialization Metadata in JSON

Serialization metadata should be specified in a _serialization-config.json_ file and conform to the JSON schema defined in
[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).
[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).
The schema also includes further details and explanations how this configuration works. Here is the example of the serialization-config.json:
```json
{
Expand All @@ -399,15 +418,21 @@ The schema also includes further details and explanations how this configuration
},
"type": {
"proxy": ["<fully-qualified-interface-name-1>", "<fully-qualified-interface-name-n>"]
}
},
"reasons": [
"Generated dynamic proxies for interfaces 1 and 2"
]
}
],
"lambdaCapturingTypes": [
{
"condition": {
"typeReachable": "<condition-class>"
},
"name": "<fully-qualified-class-name>"
"name": "<fully-qualified-class-name>",
"reasons": [
"Serialized by MyClass"
]
}
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/config-reasons-schema-v1.0.0.json",
"type": "array",
"default": [],
"items": {
"type": "string"
},
"title": "JSON schema for the reasons justifying a configuration"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/jni-config-schema-v1.2.0.json",
"default": [],
"items": {
"properties": {
"condition": {
"$ref": "config-condition-schema-v1.0.0.json",
"title": "Condition under which the class should be registered for access through JNI"
},
"type": {
"$ref": "config-type-schema-v1.0.0.json",
"title": "Type descriptor of the class that should be registered for access through JNI"
},
"name": {
"deprecated": true,
"type": "string",
"title": "Name of the class that should be registered for access through JNI"
},
"methods": {
"default": [],
"items": {
"properties": {
"name": {
"type": "string",
"title": "Method name that should be registered for this class"
},
"parameterTypes": {
"default": [],
"items": {
"type": "string",
"title": "List of the method's parameter types"
},
"type": "array"
}
},
"required": [
"name"
],
"additionalProperties": false,
"type": "object",
"title": "List of methods from this class that are registered for access through JNI"
},
"type": "array",
"title": "List of methods that should be registered for the class declared in <name>"
},
"queriedMethods": {
"deprecated": true,
"default": [],
"items": {
"properties": {
"name": {
"type": "string",
"title": "Method name that are queried for this class"
},
"parameterTypes": {
"default": [],
"items": {
"type": "string",
"title": "List of types for the parameters of the this method"
},
"type": "array",
"title": "List of methods to register for this class that are only looked up but not invoked."
}
},
"required": [
"name"
],
"additionalProperties": false,
"type": "object"
},
"type": "array",
"title": "List of methods that are queried for the class declared in <name>"
},
"fields": {
"default": [],
"items": {
"properties": {
"name": {
"type": "string",
"title": "Name of the field that should be registered for access through JNI"
}
},
"required": [
"name"
],
"additionalProperties": false,
"type": "object"
},
"type": "array",
"title": "List of fields that should be registered for the class declared in <name>"
},
"allDeclaredClasses": {
"deprecated": true,
"default": false,
"type": "boolean",
"title": "Register classes which would be returned by the java.lang.Class#getDeclaredClasses call"
},
"allDeclaredMethods": {
"default": false,
"type": "boolean",
"title": "Register methods which would be returned by the java.lang.Class#getDeclaredMethods call"
},
"allDeclaredFields": {
"default": false,
"type": "boolean",
"title": "Register fields which would be returned by the java.lang.Class#getDeclaredFields call"
},
"allDeclaredConstructors": {
"default": false,
"type": "boolean",
"title": "Register constructors which would be returned by the java.lang.Class#getDeclaredConstructors call"
},
"allPublicClasses": {
"deprecated": true,
"default": false,
"type": "boolean",
"title": "Register all public classes which would be returned by the java.lang.Class#getClasses call"
},
"allPublicMethods": {
"default": false,
"type": "boolean",
"title": "Register all public methods which would be returned by the java.lang.Class#getMethods call"
},
"allPublicFields": {
"default": false,
"type": "boolean",
"title": "Register all public fields which would be returned by the java.lang.Class#getFields call"
},
"allPublicConstructors": {
"default": false,
"type": "boolean",
"title": "Register all public constructors which would be returned by the java.lang.Class#getConstructors call"
},
"allRecordComponents": {
"deprecated": true,
"default": false,
"type": "boolean",
"title": "Register record components which would be returned by the java.lang.Class#getRecordComponents call"
},
"allPermittedSubclasses": {
"deprecated": true,
"default": false,
"type": "boolean",
"title": "Register permitted subclasses which would be returned by the java.lang.Class#getPermittedSubclasses call"
},
"allNestMembers": {
"deprecated": true,
"default": false,
"type": "boolean",
"title": "Register nest members which would be returned by the java.lang.Class#getNestMembers call"
},
"allSigners": {
"deprecated": true,
"default": false,
"type": "boolean",
"title": "Register signers which would be returned by the java.lang.Class#getSigners call"
},
"queryAllDeclaredMethods": {
"deprecated": true,
"default": false,
"type": "boolean",
"title": "Register methods which would be returned by the java.lang.Class#getDeclaredMethods call but only for lookup"
},
"queryAllDeclaredConstructors": {
"deprecated": true,
"default": false,
"type": "boolean",
"title": "Register constructors which would be returned by the java.lang.Class#getDeclaredConstructors call but only for lookup"
},
"queryAllPublicMethods": {
"deprecated": true,
"default": false,
"type": "boolean",
"title": "Register all public methods which would be returned by the java.lang.Class#getMethods call but only for lookup"
},
"queryAllPublicConstructors": {
"deprecated": true,
"default": false,
"type": "boolean",
"title": "Register all public constructors which would be returned by the java.lang.Class#getConstructors call but only for lookup"
},
"unsafeAllocated": {
"default": false,
"type": "boolean",
"title": "Allow objects of this class to be instantiated with a call to jdk.internal.misc.Unsafe#allocateInstance"
},
"reasons": {
"$ref": "config-reasons-schema-v1.0.0.json",
"title": "List of reasons justifying the configuration"
}
},
"additionalProperties": false,
"type": "object"
},
"type": "array",
"title": "JSON schema for the JNI configuration that GraalVM Native Image uses"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/proxy-config-schema-v1.1.0.json",
"default": [],
"items": {
"properties": {
"condition": {
"properties": {
"typeReachable": {
"type": "string",
"title": "Fully qualified class name of the class that must be reachable in order to register the dynamic proxy"
}
},
"required": [
"typeReachable"
],
"additionalProperties": false,
"type": "object"
},
"interfaces": {
"default": [],
"items": {
"type": "string",
"title": "Interface that will be implemented by the dynamic proxy"
},
"type": "array",
"title": "List of interfaces that dynamic proxy implements"
},
"reasons": {
"$ref": "config-reasons-schema-v1.0.0.json",
"title": "List of reasons justifying the configuration"
}
},
"required": [
"interfaces"
],
"additionalProperties": false,
"type": "object"
},
"type": "array",
"title": "JSON schema for the proxy-config that GraalVM Native Image uses"
}
Loading