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

[GR-50434] Introduce more flexible type descriptors for JSON configuration #8369

Merged
merged 1 commit into from
Mar 6, 2024
Merged
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
14 changes: 7 additions & 7 deletions docs/reference-manual/native-image/ReachabilityMetadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 72,7 @@ The JSON file consists of entries that tell Native Image the elements to include
For example, Java reflection metadata is specified in `reflect-config.json`, and a sample entry looks like:
```json
{
"name": "Foo"
"type": "Foo"
}
```

Expand Down Expand Up @@ -147,15 147,15 @@ 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.0.0.json](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/reflect-config-schema-v1.0.0.json).
[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).
The schema also includes further details and explanations how this configuration works. Here is the example of the reflect-config.json:
```json
[
{
"condition": {
"typeReachable": "<condition-class>"
},
"name": "<class>",
"type": "<class>",
"methods": [
{"name": "<methodName>", "parameterTypes": ["<param-one-type>"]}
],
Expand Down Expand Up @@ -199,7 199,7 @@ looks up the `java.lang.String` class, which can then be used, for example, to i
The generated metadata entry for the above call would look like:
```json
{
"name": "java.lang.String"
"type": "java.lang.String"
}
```

Expand All @@ -209,7 209,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.0.0.json](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/jni-config-schema-v1.0.0.json).
[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).
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 @@ -377,7 377,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.0.0.json](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/serialization-config-schema-v1.0.0.json).
[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).
The schema also includes further details and explanations how this configuration works. Here is the example of the serialization-config.json:
```json
{
Expand All @@ -386,7 386,7 @@ The schema also includes further details and explanations how this configuration
"condition": {
"typeReachable": "<condition-class>"
},
"name": "<fully-qualified-class-name>",
"type": "<fully-qualified-class-name>",
"customTargetConstructorClass": "<custom-target-constructor-class>"
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 1,16 @@
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/config-condition-schema-v1.0.0.json",
"title": "JSON schema for the conditions used in GraalVM Native Image configuration files",
"properties": {
"typeReachable": {
"type": "string",
"title": "Fully qualified name of a class that must be reachable in order to register the type <type> for reflection"
}
},
"required": [
"typeReachable"
],
"additionalProperties": false,
"type": "object"
}
Original file line number Diff line number Diff line change
@@ -0,0 1,6 @@
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/config-type-schema-v1.0.0.json",
"type": "string",
"title": "JSON schema for the type descriptors GraalVM Native Image configuration files use"
}
Original file line number Diff line number Diff line change
@@ -0,0 1,194 @@
{
"$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.1.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"
}
},
"additionalProperties": false,
"type": "object"
},
"type": "array",
"title": "JSON schema for the JNI configuration that GraalVM Native Image uses"
}
Loading