From 35fd46ed7ee8b0a66db86d48fbc178e5b5355811 Mon Sep 17 00:00:00 2001 From: David Nestorovic Date: Wed, 26 Apr 2023 17:04:11 +0200 Subject: [PATCH 1/7] Add JSON schema for predefined-classes-config --- .../predefined-classes-config-schema.json | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 docs/reference-manual/native-image/assets/predefined-classes-config-schema.json diff --git a/docs/reference-manual/native-image/assets/predefined-classes-config-schema.json b/docs/reference-manual/native-image/assets/predefined-classes-config-schema.json new file mode 100644 index 000000000000..2eed1350470a --- /dev/null +++ b/docs/reference-manual/native-image/assets/predefined-classes-config-schema.json @@ -0,0 +1,58 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "default": [ + { + "type": "agent-extracted", + "classes": [] + } + ], + "examples": [ + { + "type": "agent-extracted", + "classes":[ + { + "nameInfo":"com/example/Class", + "hash":"hash987654321hash987654321hash987654321hash987654321" + } + ] + } + ], + "items": { + "properties": { + "type": { + "default": "agent-extracted", + "title": "Origin of the classes listed in ", + "type": "string", + "enum": [ + "agent-extracted" + ] + }, + "classes": { + "default": [], + "items": { + "properties": { + "nameInfo": { + "type": "string", + "title": "Fully qualified name of the predefined class" + }, + "hash": { + "type": "string", + "title": "Hash value of the predefined class" + } + }, + "type": "object", + "required": [ + "nameInfo", + "hash" + ] + }, + "type": "array", + "title": "List of classes that are predefined" + } + }, + "type": "object", + "title": "List of classes with their origin that are predefined" + }, + "type": "array", + "title": "JSON schema for the predefined-classes-config that GraalVM Native Image uses" +} \ No newline at end of file From 8bfa37d94353395c1ec6f4ed5d448b462d32b848 Mon Sep 17 00:00:00 2001 From: David Nestorovic Date: Wed, 26 Apr 2023 17:04:43 +0200 Subject: [PATCH 2/7] Add JSON schema for proxy-config --- .../assets/proxy-config-schema.json | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 docs/reference-manual/native-image/assets/proxy-config-schema.json diff --git a/docs/reference-manual/native-image/assets/proxy-config-schema.json b/docs/reference-manual/native-image/assets/proxy-config-schema.json new file mode 100644 index 000000000000..d59a8a1ee624 --- /dev/null +++ b/docs/reference-manual/native-image/assets/proxy-config-schema.json @@ -0,0 +1,32 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "default": [], + "items": { + "properties": { + "condition": { + "properties": { + "typeReachable": { + "type": "string", + "title": "Fully qualified class name of the class that must be reachable in order to register dynamic proxy" + } + }, + "required": [ + "typeReachable" + ], + "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" + } + }, + "type": "object" + }, + "type": "array", + "title": "JSON schema for the proxy-config that GraalVM Native Image uses" +} \ No newline at end of file From 67cfa04acefc8ba7dbda84712a88b5bd7dbb734b Mon Sep 17 00:00:00 2001 From: David Nestorovic Date: Wed, 26 Apr 2023 17:05:09 +0200 Subject: [PATCH 3/7] Add JSON schema for serialization-config --- .../assets/serialization-config-schema.json | 136 ++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 docs/reference-manual/native-image/assets/serialization-config-schema.json diff --git a/docs/reference-manual/native-image/assets/serialization-config-schema.json b/docs/reference-manual/native-image/assets/serialization-config-schema.json new file mode 100644 index 000000000000..92f303870ee9 --- /dev/null +++ b/docs/reference-manual/native-image/assets/serialization-config-schema.json @@ -0,0 +1,136 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "default": { + "types": [], + "lambdaCapturingTypes": [], + "proxies": [] + }, + "examples": [ + { + "types": [ + { + "condition": { + "typeReachable": "com.example.myPackage.ConditionClass" + }, + "name": "java.lang.Class", + "customTargetConstructorClass": "com.example.myPackage.CustomTargetConstructorClass" + } + ], + "lambdaCapturingTypes": [ + { + "condition": { + "typeReachable": "com.example.myPackage.ConditionLambdaCapturingClass" + }, + "name": "com.example.Class" + } + ], + "proxies": [ + { + "condition": { + "typeReachable": "com.example.myPackage.ConditionProxyClass" + }, + "interfaces": [ + "com.example.interface.name1", + "com.example.interface.name2", + "com.example.interface.name3" + ] + } + ] + } + ], + "properties": { + "types": { + "default": [], + "items": { + "properties": { + "condition": { + "properties": { + "typeReachable": { + "type": "string", + "title": "Fully qualified class name of the class that must be reachable in order to serialize class from " + } + }, + "required": [ + "typeReachable" + ], + "type": "object" + }, + "name": { + "type": "string", + "title": "Fully qualified class name of the class that should be serialized" + }, + "customTargetConstructorClass": { + "type": "string", + "title": "Fully qualified class name of the class which constructor should be used instead of serializing class constructor" + } + }, + "type": "object" + }, + "title": "List of classes that should be serialized", + "type": "array" + }, + "lambdaCapturingTypes": { + "default": [], + "items": { + "properties": { + "condition": { + "properties": { + "typeReachable": { + "type": "string", + "title": "Fully qualified class name of the class that must be reachable in order to serialize lambda classes that are captured by the class referred in " + } + }, + "required": [ + "typeReachable" + ], + "type": "object" + }, + "name": { + "type": "string", + "title": "Fully qualified class name of the class that captures lambda classes that should be either serialized or deserialized" + } + }, + "type": "object" + }, + "title": "List of classes that capture lambdas that should be serialized", + "type": "array" + }, + "proxies": { + "default": [], + "items": { + "properties": { + "condition": { + "properties": { + "typeReachable": { + "type": "string", + "title": "Fully qualified class name of the class that must be reachable in order to serialize proxy classes that implements interfaces from " + } + }, + "required": [ + "typeReachable" + ], + "type": "object" + }, + "interfaces": { + "items": { + "type": "string", + "title": "Fully qualified name of an interface that is implemented by the proxy that should be serialized" + }, + "type": "array", + "title": "List of interfaces that are implemented by the proxy class that should be serialized" + } + }, + "type": "object" + }, + "title": "List of proxies that should be serialized", + "type": "array" + } + }, + "required": [ + "types", + "lambdaCapturingTypes", + "proxies" + ], + "title": "JSON schema for the serialization-config that GraalVM Native Image uses", + "type": "object" +} \ No newline at end of file From eb0803c845f4381967c7c3f5609b459d106c01a4 Mon Sep 17 00:00:00 2001 From: David Nestorovic Date: Thu, 27 Apr 2023 12:15:02 +0200 Subject: [PATCH 4/7] Add JSON schema for reflect-config --- .../assets/proxy-config-schema.json | 21 +++ .../assets/reflect-config-schema.json | 159 ++++++++++++++++++ 2 files changed, 180 insertions(+) create mode 100644 docs/reference-manual/native-image/assets/reflect-config-schema.json diff --git a/docs/reference-manual/native-image/assets/proxy-config-schema.json b/docs/reference-manual/native-image/assets/proxy-config-schema.json index d59a8a1ee624..0f5aea7ef060 100644 --- a/docs/reference-manual/native-image/assets/proxy-config-schema.json +++ b/docs/reference-manual/native-image/assets/proxy-config-schema.json @@ -1,6 +1,27 @@ { "$schema": "https://json-schema.org/draft/2019-09/schema", "default": [], + "examples": [ + [ + { + "condition": { + "typeReachable": "org.condition.Class" + }, + "interfaces": [ + "com.interface.Interface1" + ] + }, + { + "condition": { + "typeReachable": "org.condition.package.Class" + }, + "interfaces": [ + "com.interface.Interface2", + "com.interface.Interface3" + ] + } + ] + ], "items": { "properties": { "condition": { diff --git a/docs/reference-manual/native-image/assets/reflect-config-schema.json b/docs/reference-manual/native-image/assets/reflect-config-schema.json new file mode 100644 index 000000000000..c5ac916eaa2a --- /dev/null +++ b/docs/reference-manual/native-image/assets/reflect-config-schema.json @@ -0,0 +1,159 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "default": [], + "examples": [ + [ + { + "name": "[Ljava.lang.Boolean;", + "condition": { + "typeReachable": "org.condition.Class" + } + }, + { + "name": "[Lpackage.ClassName", + "condition": { + "typeReachable": "org.condition.Class" + }, + "allDeclaredFields": true, + "allDeclaredConstructors": true + } + ] + ], + "items": { + "properties": { + "condition": { + "properties": { + "typeReachable": { + "type": "string", + "title": "Fully qualified class name of the class that must be reachable in order to register reflection declared in " + } + }, + "required": [ + "typeReachable" + ], + "type": "object" + }, + "name": { + "type": "string", + "title": "Name of the class that should be registered for reflection" + }, + "methods": { + "default": [], + "items": { + "properties": { + "name": { + "type": "string", + "title": "List of method names that should be registered for the class declared in " + }, + "parameterTypes": { + "default": [], + "items": { + "type": "string", + "title": "List of types for the parameters of the method declared in " + }, + "type": "array" + } + }, + "required": [ + "name", + "parameterTypes" + ], + "type": "object" + }, + "type": "array", + "title": "List of methods that should be registered for the class declared in " + }, + "queriedMethods": { + "default": [], + "items": { + "properties": { + "name": { + "type": "string", + "title": "List of method names that are queried for the class declared in " + }, + "parameterTypes": { + "default": [], + "items": { + "type": "string", + "title": "List of types for the parameters of the method declared in " + }, + "type": "array" + } + }, + "required": [ + "name", + "parameterTypes" + ], + "type": "object" + }, + "type": "array", + "title": "List of methods that are queried for the class declared in " + }, + "fields": { + "default": [], + "items": { + "properties": { + "name": { + "type": "string", + "title": "Name of the field that should be registered for reflection" + } + }, + "type": "object" + }, + "type": "array", + "title": "List of fields that should be registered for the class declared in " + }, + "allDeclaredMethods": { + "default": true, + "type": "boolean" + }, + "allDeclaredFields": { + "default": true, + "type": "boolean" + }, + "allDeclaredConstructors": { + "default": true, + "type": "boolean" + }, + "allPublicMethods": { + "default": true, + "type": "boolean" + }, + "allPublicFields": { + "default": true, + "type": "boolean" + }, + "allPublicConstructors": { + "default": true, + "type": "boolean" + }, + "queryAllDeclaredMethods": { + "default": true, + "type": "boolean" + }, + "queryAllDeclaredConstructors": { + "default": true, + "type": "boolean" + }, + "queryAllPublicMethods": { + "default": true, + "type": "boolean" + }, + "queryAllPublicConstructors": { + "default": true, + "type": "boolean" + }, + "unsafeAllocated": { + "default": true, + "type": "boolean" + } + }, + "required": [ + "condition", + "name" + ], + "type": "object" + }, + "type": "array", + "title": "JSON schema for the reflect-config that GraalVM Native Image uses" +} \ No newline at end of file From 2d6ae3748e76f6f8a657a63c51f2dac371b63fce Mon Sep 17 00:00:00 2001 From: David Nestorovic Date: Thu, 27 Apr 2023 12:16:08 +0200 Subject: [PATCH 5/7] Add JSON schema for resource-config --- .../assets/proxy-config-schema.json | 21 --- .../assets/resource-config-schema.json | 142 ++++++++++++++++++ 2 files changed, 142 insertions(+), 21 deletions(-) create mode 100644 docs/reference-manual/native-image/assets/resource-config-schema.json diff --git a/docs/reference-manual/native-image/assets/proxy-config-schema.json b/docs/reference-manual/native-image/assets/proxy-config-schema.json index 0f5aea7ef060..d59a8a1ee624 100644 --- a/docs/reference-manual/native-image/assets/proxy-config-schema.json +++ b/docs/reference-manual/native-image/assets/proxy-config-schema.json @@ -1,27 +1,6 @@ { "$schema": "https://json-schema.org/draft/2019-09/schema", "default": [], - "examples": [ - [ - { - "condition": { - "typeReachable": "org.condition.Class" - }, - "interfaces": [ - "com.interface.Interface1" - ] - }, - { - "condition": { - "typeReachable": "org.condition.package.Class" - }, - "interfaces": [ - "com.interface.Interface2", - "com.interface.Interface3" - ] - } - ] - ], "items": { "properties": { "condition": { diff --git a/docs/reference-manual/native-image/assets/resource-config-schema.json b/docs/reference-manual/native-image/assets/resource-config-schema.json new file mode 100644 index 000000000000..b7874cc3280a --- /dev/null +++ b/docs/reference-manual/native-image/assets/resource-config-schema.json @@ -0,0 +1,142 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "default": { + "resources": {}, + "bundles": [] + }, + "examples": [ + { + "resources": { + "includes": [ + { + "condition": { + "typeReachable": "com.condition.resource.Class" + }, + "pattern": "\\Qcom/pattern/to/be/included\\E" + } + ], + "excludes": [ + { + "condition": { + "typeReachable": "com.condition.resource.Class" + }, + "pattern": "\\Qcom/pattern/to/be/excluded\\E" + } + ] + }, + "bundles": [ + { + "condition": { + "typeReachable": "com.condition.Class" + }, + "name": "com.bundle.name" + } + ] + } + ], + "properties": { + "resources": { + "properties": { + "includes": { + "default": [], + "items": { + "properties": { + "condition": { + "properties": { + "typeReachable": { + "type": "string", + "title": "Fully qualified class name of the class that must be reachable in order to register resource pattern" + } + }, + "required": [ + "typeReachable" + ], + "type": "object" + }, + "pattern": { + "type": "string", + "title": "Resource matching pattern" + } + }, + "required": [ + "condition" + ], + "type": "object" + }, + "type": "array", + "title": "List of included resource patterns" + }, + "excludes": { + "default": [], + "items": { + "properties": { + "condition": { + "properties": { + "typeReachable": { + "type": "string", + "title": "Fully qualified class name of the class that must be reachable in order to exclude resource pattern" + } + }, + "required": [ + "typeReachable" + ], + "type": "object" + }, + "pattern": { + "type": "string", + "title": "Resource matching pattern" + } + }, + "required": [ + "condition" + ], + "type": "object" + }, + "type": "array", + "title": "List of excluded resource patterns" + } + }, + "type": "object", + "title": "Set of included and excluded lists of patterns" + }, + "bundles": { + "default": [], + "items": { + "properties": { + "condition": { + "properties": { + "typeReachable": { + "type": "string", + "title": "Fully qualified class name of the class that must be reachable in order to register resource bundle" + } + }, + "required": [ + "typeReachable" + ], + "type": "object" + }, + "name": { + "type": "string", + "title": "Fully qualified name of the resource bundle" + }, + "locales": { + "default": [], + "items": { + "type": "string" + }, + "type": "array", + "title": "List of locales that should be registered for the resource bundle declared in " + } + }, + "required": [ + "condition" + ], + "type": "object" + }, + "type": "array", + "title": "List of resource bundles that should be registered" + } + }, + "type": "object", + "title": "JSON schema for the resource-config that GraalVM Native Image uses" +} \ No newline at end of file From db8ba8e423e4a6483f11458e63c6c52427e17e18 Mon Sep 17 00:00:00 2001 From: David Nestorovic Date: Thu, 27 Apr 2023 12:22:59 +0200 Subject: [PATCH 6/7] Add JSON schema for jni-config --- .../assets/jni-config-schema.json | 159 ++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 docs/reference-manual/native-image/assets/jni-config-schema.json diff --git a/docs/reference-manual/native-image/assets/jni-config-schema.json b/docs/reference-manual/native-image/assets/jni-config-schema.json new file mode 100644 index 000000000000..688f6beb6c98 --- /dev/null +++ b/docs/reference-manual/native-image/assets/jni-config-schema.json @@ -0,0 +1,159 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "default": [], + "examples": [ + [ + { + "name": "[Ljava.lang.Boolean;", + "condition": { + "typeReachable": "org.condition.Class" + } + }, + { + "name": "[Lpackage.ClassName", + "condition": { + "typeReachable": "org.condition.Class" + }, + "allDeclaredFields": true, + "allDeclaredConstructors": true + } + ] + ], + "items": { + "properties": { + "condition": { + "properties": { + "typeReachable": { + "type": "string", + "title": "Fully qualified class name of the class that must be reachable in order to register JNI declared in " + } + }, + "required": [ + "typeReachable" + ], + "type": "object" + }, + "name": { + "type": "string", + "title": "Name of the class that should be registered for JNI" + }, + "methods": { + "default": [], + "items": { + "properties": { + "name": { + "type": "string", + "title": "List of method names that should be registered for the class declared in " + }, + "parameterTypes": { + "default": [], + "items": { + "type": "string", + "title": "List of types for the parameters of the method declared in " + }, + "type": "array" + } + }, + "required": [ + "name", + "parameterTypes" + ], + "type": "object" + }, + "type": "array", + "title": "List of methods that should be registered for the class declared in " + }, + "queriedMethods": { + "default": [], + "items": { + "properties": { + "name": { + "type": "string", + "title": "List of method names that are queried for the class declared in " + }, + "parameterTypes": { + "default": [], + "items": { + "type": "string", + "title": "List of types for the parameters of the method declared in " + }, + "type": "array" + } + }, + "required": [ + "name", + "parameterTypes" + ], + "type": "object" + }, + "type": "array", + "title": "List of methods that are queried for the class declared in " + }, + "fields": { + "default": [], + "items": { + "properties": { + "name": { + "type": "string", + "title": "Name of the field that should be registered for JNI" + } + }, + "type": "object" + }, + "type": "array", + "title": "List of fields that should be registered for the class declared in " + }, + "allDeclaredMethods": { + "default": true, + "type": "boolean" + }, + "allDeclaredFields": { + "default": true, + "type": "boolean" + }, + "allDeclaredConstructors": { + "default": true, + "type": "boolean" + }, + "allPublicMethods": { + "default": true, + "type": "boolean" + }, + "allPublicFields": { + "default": true, + "type": "boolean" + }, + "allPublicConstructors": { + "default": true, + "type": "boolean" + }, + "queryAllDeclaredMethods": { + "default": true, + "type": "boolean" + }, + "queryAllDeclaredConstructors": { + "default": true, + "type": "boolean" + }, + "queryAllPublicMethods": { + "default": true, + "type": "boolean" + }, + "queryAllPublicConstructors": { + "default": true, + "type": "boolean" + }, + "unsafeAllocated": { + "default": true, + "type": "boolean" + } + }, + "required": [ + "condition", + "name" + ], + "type": "object" + }, + "type": "array", + "title": "JSON schema for the jni-config that GraalVM Native Image uses" +} From 75aa2c0892700b6beb539420acfcfbc79c874df7 Mon Sep 17 00:00:00 2001 From: David Nestorovic Date: Thu, 27 Apr 2023 12:24:18 +0200 Subject: [PATCH 7/7] Update ReachabilityMetadata.md and improve examples --- .../native-image/ReachabilityMetadata.md | 83 ++++---- .../assets/jni-config-schema-v1.0.0.json | 190 ++++++++++++++++++ .../assets/jni-config-schema.json | 159 --------------- ...defined-classes-config-schema-v1.0.0.json} | 15 +- ...a.json => proxy-config-schema-v1.0.0.json} | 8 +- .../assets/reflect-config-schema-v1.0.0.json | 190 ++++++++++++++++++ .../assets/reflect-config-schema.json | 159 --------------- ...son => resource-config-schema-v1.0.0.json} | 67 +++--- ...> serialization-config-schema-v1.0.0.json} | 59 ++---- 9 files changed, 479 insertions(+), 451 deletions(-) create mode 100644 docs/reference-manual/native-image/assets/jni-config-schema-v1.0.0.json delete mode 100644 docs/reference-manual/native-image/assets/jni-config-schema.json rename docs/reference-manual/native-image/assets/{predefined-classes-config-schema.json => predefined-classes-config-schema-v1.0.0.json} (82%) rename docs/reference-manual/native-image/assets/{proxy-config-schema.json => proxy-config-schema-v1.0.0.json} (72%) create mode 100644 docs/reference-manual/native-image/assets/reflect-config-schema-v1.0.0.json delete mode 100644 docs/reference-manual/native-image/assets/reflect-config-schema.json rename docs/reference-manual/native-image/assets/{resource-config-schema.json => resource-config-schema-v1.0.0.json} (72%) rename docs/reference-manual/native-image/assets/{serialization-config-schema.json => serialization-config-schema-v1.0.0.json} (70%) diff --git a/docs/reference-manual/native-image/ReachabilityMetadata.md b/docs/reference-manual/native-image/ReachabilityMetadata.md index e298778e0302..c3f5db4d0744 100644 --- a/docs/reference-manual/native-image/ReachabilityMetadata.md +++ b/docs/reference-manual/native-image/ReachabilityMetadata.md @@ -61,7 +61,7 @@ Computing metadata in code can be achieved in two ways: return aClass; } } - ``` + ``` When metadata is computed in code, the dynamically accessed elements will be included into the native executable's heap only if that part of the heap is reachable through an enclosing method (for example, `ReflectiveAccess#fetchFoo`) or a static field (for example, `InitializedAtBuildTime.aClass`). @@ -89,6 +89,8 @@ A condition is specified in the following way: An entry with a `typeReachable` condition is considered only when the fully-qualified class is reachable. Currently, we support only `typeReachable` as a condition. +Find more examples of the configuration files in the [GraalVM Reachability Metadata repository](https://github.com/oracle/graalvm-reachability-metadata). + ## Metadata Types Native Image accepts the following types of reachability metadata: @@ -144,8 +146,9 @@ Integer.class.getMethod("parseInt", params2); ### Specifying Reflection Metadata in JSON -Reflection metadata can be specified in the `reflect-config.json` file. -The JSON file is an array of reflection entries: +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). +The schema also includes further details and explanations how this configuration works. Here is the example of the reflect-config.json: ```json [ { @@ -162,12 +165,18 @@ The JSON file is an array of reflection entries: "fields": [ {"name": ""} ], + "allDeclaredClasses": true, "allDeclaredMethods": true, - "allDeclaredFields": true, + "allDeclaredFields": true, "allDeclaredConstructors": true, + "allPublicClasses": true, "allPublicMethods": true, "allPublicFields": true, "allPublicConstructors": true, + "allRecordComponents": true, + "allNestMembers": true, + "allSigners": true, + "allPermittedSubclasses": true, "queryAllDeclaredMethods": true, "queryAllDeclaredConstructors": true, "queryAllPublicMethods": true, @@ -177,21 +186,6 @@ The JSON file is an array of reflection entries: ] ``` -The fields in a reflection entry have the following meaning: - - `condition`: See [Conditional Metadata Entries](#specifying-metadata-with-json) - - `name`: Name of the class that will be reflectively looked up. This property is mandatory. - - `methods`: List class methods that can be looked up and executed reflectively. - Each method is described by its name and a list of parameter types. - The parameter types are fully qualified Java class names. - - `queriedMethods`: List of class methods that can only be looked up. - The description of each method is identical to the `methods` list. - - `fields`: List of class fields that can be looked up, read, or modified. - - `all(Methods/Fields/Constructors)`: Registers all methods/fields/constructors for lookup. Methods and constructors can also be invoked. - `` refers to different ways of querying these members in Java and can be either `Declared` or `Public`. - For more information, see `java.lang.Class.getDeclaredMethods()` and `java.lang.Class.getPublicMethods()`. - - `queryAll(Methods/Constructors)`: Registers all methods/constructors for lookup only. - - `unsafeAllocated`: Allows objects of this class to be allocated using `Unsafe.allocateInstance`. - ## Java Native Interface Java Native Interface (JNI) allows native code to access arbitrary Java types and type members. @@ -213,8 +207,11 @@ The generated metadata entry for the above call would look like: It is not possible to specify JNI metadata in code. ### JNI Metadata in JSON -Metadata for JNI is provided in `jni-config.json` files. -The JSON schema of JNI metadata is identical to the [Reflection metadata schema](#specifying-reflection-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). +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. ## Resources and Resource Bundles Java is capable of accessing any resource on the application class path, or the module path for which the requesting code has permission to access. @@ -241,14 +238,17 @@ class Example { ``` ### Resource Metadata in JSON -Metadata for resources is provided in `resource-config.json` files. + +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). +The schema also includes further details and explanations how this configuration works. Here is the example of the resource-config.json: ```json { "resources": { "includes": [ { "condition": { - "typeReachable": "" + "typeReachable": "" }, "pattern": ".*\\.txt" } @@ -269,15 +269,21 @@ Metadata for resources is provided in `resource-config.json` files. }, "name": "fully.qualified.bundle.name", "locales": ["en", "de", "sk"] + }, + { + "condition": { + "typeReachable": "" + }, + "name": "fully.qualified.bundle.name", + "classNames": [ + "fully.qualified.bundle.name_en", + "fully.qualified.bundle.name_de" + ] } ] } ``` -Native Image will iterate over all resources and match their relative paths against the Java regex specified in `includes`. -If the path matches the regex, the resource is included. -The `excludes` statement instructs `native-image` to omit certain included resources that match the given `pattern`. - ## Dynamic Proxy The JDK supports generating proxy classes for a given interface list. @@ -316,7 +322,10 @@ The following methods are evaluated at build time when called with constant argu - `java.lang.reflect.Proxy.newProxyInstance` ### Dynamic Proxy Metadata in JSON -Metadata for dynamic proxies is provided in `proxy-config.json` files. + +Dynamic proxy metadata should be specified in a _proxy-config.json_ file and conform to the JSON schema defined in +[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). +The schema also includes further details and explanations how this configuration works. Here is the example of the proxy-config.json: ```json [ { @@ -366,7 +375,10 @@ To create a custom constructor for serialization use: Proxy classes can only be registered for serialization via the JSON files. ### Serialization Metadata in JSON -Metadata for serialization is provided in `serialization-config.json` files. + +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). +The schema also includes further details and explanations how this configuration works. Here is the example of the serialization-config.json: ```json { "types": [ @@ -397,12 +409,6 @@ Metadata for serialization is provided in `serialization-config.json` files. } ``` -Each entry in `types` enables serializing and deserializing objects of the class given by `name`. - -Each entry in `lambdaCapturingTypes` enables lambda serialization: all lambdas declared in the methods of the class given by `name` can be serialized and deserialized. - -Each entry in `proxies` enables the [Proxy](https://docs.oracle.com/javase/8/docs/technotes/guides/reflection/proxy.html) serialization by providing an interface list that a proxy implements. - ## Predefined Classes Native Image requires all classes to be known at build time (a "closed-world assumption"). @@ -418,7 +424,10 @@ At runtime, if there is an attempt to load a class with the same name and byteco It is not possible to specify predefined classes in code. ### Predefined Classes Metadata in JSON -Metadata for predefined classes is provided in `predefined-classes-config.json` files. + +Predefined classes metadata should be specified in a _predefined-classes-config.json_ file and conform to the JSON schema defined in +[predefined-classes-config-schema-v1.0.0.json](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/predefined-classes-config-schema-v1.0.0.json). +The schema also includes further details and explanations how this configuration works. Here is the example of the predefined-classes-config.json: ```json [ { @@ -433,8 +442,6 @@ Metadata for predefined classes is provided in `predefined-classes-config.json` ] ``` -The JSON schema is accompanied by the `agent-extracted-predefined-classes` directory that contains the bytecode of the listed classes. - ### Further Reading * [Metadata Collection with the Tracing Agent](AutomaticMetadataCollection.md) diff --git a/docs/reference-manual/native-image/assets/jni-config-schema-v1.0.0.json b/docs/reference-manual/native-image/assets/jni-config-schema-v1.0.0.json new file mode 100644 index 000000000000..308782b947b8 --- /dev/null +++ b/docs/reference-manual/native-image/assets/jni-config-schema-v1.0.0.json @@ -0,0 +1,190 @@ +{ + "$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.0.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 class for access through JNI" + } + }, + "required": [ + "typeReachable" + ], + "additionalProperties": false, + "type": "object" + }, + "name": { + "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 types for the parameters of the this method" + }, + "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 " + }, + "queriedMethods": { + "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 " + }, + "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 " + }, + "allDeclaredClasses": { + "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": { + "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": { + "default": false, + "type": "boolean", + "title": "Register record components which would be returned by the java.lang.Class#getRecordComponents call" + }, + "allPermittedSubclasses": { + "default": false, + "type": "boolean", + "title": "Register permitted subclasses which would be returned by the java.lang.Class#getPermittedSubclasses call" + }, + "allNestMembers": { + "default": false, + "type": "boolean", + "title": "Register nest members which would be returned by the java.lang.Class#getNestMembers call" + }, + "allSigners": { + "default": false, + "type": "boolean", + "title": "Register signers which would be returned by the java.lang.Class#getSigners call" + }, + "queryAllDeclaredMethods": { + "default": false, + "type": "boolean", + "title": "Register methods which would be returned by the java.lang.Class#getDeclaredMethods call but only for lookup" + }, + "queryAllDeclaredConstructors": { + "default": false, + "type": "boolean", + "title": "Register constructors which would be returned by the java.lang.Class#getDeclaredConstructors call but only for lookup" + }, + "queryAllPublicMethods": { + "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": { + "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" + } + }, + "required": [ + "name" + ], + "additionalProperties": false, + "type": "object" + }, + "type": "array", + "title": "JSON schema for the jni-config that GraalVM Native Image uses" +} \ No newline at end of file diff --git a/docs/reference-manual/native-image/assets/jni-config-schema.json b/docs/reference-manual/native-image/assets/jni-config-schema.json deleted file mode 100644 index 688f6beb6c98..000000000000 --- a/docs/reference-manual/native-image/assets/jni-config-schema.json +++ /dev/null @@ -1,159 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2019-09/schema", - "default": [], - "examples": [ - [ - { - "name": "[Ljava.lang.Boolean;", - "condition": { - "typeReachable": "org.condition.Class" - } - }, - { - "name": "[Lpackage.ClassName", - "condition": { - "typeReachable": "org.condition.Class" - }, - "allDeclaredFields": true, - "allDeclaredConstructors": true - } - ] - ], - "items": { - "properties": { - "condition": { - "properties": { - "typeReachable": { - "type": "string", - "title": "Fully qualified class name of the class that must be reachable in order to register JNI declared in " - } - }, - "required": [ - "typeReachable" - ], - "type": "object" - }, - "name": { - "type": "string", - "title": "Name of the class that should be registered for JNI" - }, - "methods": { - "default": [], - "items": { - "properties": { - "name": { - "type": "string", - "title": "List of method names that should be registered for the class declared in " - }, - "parameterTypes": { - "default": [], - "items": { - "type": "string", - "title": "List of types for the parameters of the method declared in " - }, - "type": "array" - } - }, - "required": [ - "name", - "parameterTypes" - ], - "type": "object" - }, - "type": "array", - "title": "List of methods that should be registered for the class declared in " - }, - "queriedMethods": { - "default": [], - "items": { - "properties": { - "name": { - "type": "string", - "title": "List of method names that are queried for the class declared in " - }, - "parameterTypes": { - "default": [], - "items": { - "type": "string", - "title": "List of types for the parameters of the method declared in " - }, - "type": "array" - } - }, - "required": [ - "name", - "parameterTypes" - ], - "type": "object" - }, - "type": "array", - "title": "List of methods that are queried for the class declared in " - }, - "fields": { - "default": [], - "items": { - "properties": { - "name": { - "type": "string", - "title": "Name of the field that should be registered for JNI" - } - }, - "type": "object" - }, - "type": "array", - "title": "List of fields that should be registered for the class declared in " - }, - "allDeclaredMethods": { - "default": true, - "type": "boolean" - }, - "allDeclaredFields": { - "default": true, - "type": "boolean" - }, - "allDeclaredConstructors": { - "default": true, - "type": "boolean" - }, - "allPublicMethods": { - "default": true, - "type": "boolean" - }, - "allPublicFields": { - "default": true, - "type": "boolean" - }, - "allPublicConstructors": { - "default": true, - "type": "boolean" - }, - "queryAllDeclaredMethods": { - "default": true, - "type": "boolean" - }, - "queryAllDeclaredConstructors": { - "default": true, - "type": "boolean" - }, - "queryAllPublicMethods": { - "default": true, - "type": "boolean" - }, - "queryAllPublicConstructors": { - "default": true, - "type": "boolean" - }, - "unsafeAllocated": { - "default": true, - "type": "boolean" - } - }, - "required": [ - "condition", - "name" - ], - "type": "object" - }, - "type": "array", - "title": "JSON schema for the jni-config that GraalVM Native Image uses" -} diff --git a/docs/reference-manual/native-image/assets/predefined-classes-config-schema.json b/docs/reference-manual/native-image/assets/predefined-classes-config-schema-v1.0.0.json similarity index 82% rename from docs/reference-manual/native-image/assets/predefined-classes-config-schema.json rename to docs/reference-manual/native-image/assets/predefined-classes-config-schema-v1.0.0.json index 2eed1350470a..61683f48652a 100644 --- a/docs/reference-manual/native-image/assets/predefined-classes-config-schema.json +++ b/docs/reference-manual/native-image/assets/predefined-classes-config-schema-v1.0.0.json @@ -1,22 +1,12 @@ { "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/predefined-classes-config-schema-v1.0.0.json", "default": [ { "type": "agent-extracted", "classes": [] } ], - "examples": [ - { - "type": "agent-extracted", - "classes":[ - { - "nameInfo":"com/example/Class", - "hash":"hash987654321hash987654321hash987654321hash987654321" - } - ] - } - ], "items": { "properties": { "type": { @@ -40,9 +30,9 @@ "title": "Hash value of the predefined class" } }, + "additionalProperties": false, "type": "object", "required": [ - "nameInfo", "hash" ] }, @@ -50,6 +40,7 @@ "title": "List of classes that are predefined" } }, + "additionalProperties": false, "type": "object", "title": "List of classes with their origin that are predefined" }, diff --git a/docs/reference-manual/native-image/assets/proxy-config-schema.json b/docs/reference-manual/native-image/assets/proxy-config-schema-v1.0.0.json similarity index 72% rename from docs/reference-manual/native-image/assets/proxy-config-schema.json rename to docs/reference-manual/native-image/assets/proxy-config-schema-v1.0.0.json index d59a8a1ee624..d93ca5722fd8 100644 --- a/docs/reference-manual/native-image/assets/proxy-config-schema.json +++ b/docs/reference-manual/native-image/assets/proxy-config-schema-v1.0.0.json @@ -1,5 +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/proxy-config-schema-v1.0.0.json", "default": [], "items": { "properties": { @@ -7,12 +8,13 @@ "properties": { "typeReachable": { "type": "string", - "title": "Fully qualified class name of the class that must be reachable in order to register dynamic proxy" + "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": { @@ -25,6 +27,10 @@ "title": "List of interfaces that dynamic proxy implements" } }, + "required": [ + "interfaces" + ], + "additionalProperties": false, "type": "object" }, "type": "array", diff --git a/docs/reference-manual/native-image/assets/reflect-config-schema-v1.0.0.json b/docs/reference-manual/native-image/assets/reflect-config-schema-v1.0.0.json new file mode 100644 index 000000000000..cb3c3cd7a9fb --- /dev/null +++ b/docs/reference-manual/native-image/assets/reflect-config-schema-v1.0.0.json @@ -0,0 +1,190 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/reflect-config-schema-v1.0.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 class for reflection" + } + }, + "required": [ + "typeReachable" + ], + "additionalProperties": false, + "type": "object" + }, + "name": { + "type": "string", + "title": "Name of the class that should be registered for reflection" + }, + "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 types for the parameters of the this method" + }, + "type": "array" + } + }, + "required": [ + "name" + ], + "additionalProperties": false, + "type": "object", + "title": "List of methods from this class that are registered for reflection" + }, + "type": "array", + "title": "List of methods that should be registered for the class declared in " + }, + "queriedMethods": { + "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 " + }, + "fields": { + "default": [], + "items": { + "properties": { + "name": { + "type": "string", + "title": "Name of the field that should be registered for reflection" + } + }, + "required": [ + "name" + ], + "additionalProperties": false, + "type": "object" + }, + "type": "array", + "title": "List of class fields that can be looked up, read, or modified for the class declared in " + }, + "allDeclaredClasses": { + "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": { + "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": { + "default": false, + "type": "boolean", + "title": "Register record components which would be returned by the java.lang.Class#getRecordComponents call" + }, + "allPermittedSubclasses": { + "default": false, + "type": "boolean", + "title": "Register permitted subclasses which would be returned by the java.lang.Class#getPermittedSubclasses call" + }, + "allNestMembers": { + "default": false, + "type": "boolean", + "title": "Register nest members which would be returned by the java.lang.Class#getNestMembers call" + }, + "allSigners": { + "default": false, + "type": "boolean", + "title": "Register signers which would be returned by the java.lang.Class#getSigners call" + }, + "queryAllDeclaredMethods": { + "default": false, + "type": "boolean", + "title": "Register methods which would be returned by the java.lang.Class#getDeclaredMethods call but only for lookup" + }, + "queryAllDeclaredConstructors": { + "default": false, + "type": "boolean", + "title": "Register constructors which would be returned by the java.lang.Class#getDeclaredConstructors call but only for lookup" + }, + "queryAllPublicMethods": { + "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": { + "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" + } + }, + "required": [ + "name" + ], + "additionalProperties": false, + "type": "object" + }, + "type": "array", + "title": "JSON schema for the reflect-config that GraalVM Native Image uses" +} \ No newline at end of file diff --git a/docs/reference-manual/native-image/assets/reflect-config-schema.json b/docs/reference-manual/native-image/assets/reflect-config-schema.json deleted file mode 100644 index c5ac916eaa2a..000000000000 --- a/docs/reference-manual/native-image/assets/reflect-config-schema.json +++ /dev/null @@ -1,159 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2019-09/schema", - "default": [], - "examples": [ - [ - { - "name": "[Ljava.lang.Boolean;", - "condition": { - "typeReachable": "org.condition.Class" - } - }, - { - "name": "[Lpackage.ClassName", - "condition": { - "typeReachable": "org.condition.Class" - }, - "allDeclaredFields": true, - "allDeclaredConstructors": true - } - ] - ], - "items": { - "properties": { - "condition": { - "properties": { - "typeReachable": { - "type": "string", - "title": "Fully qualified class name of the class that must be reachable in order to register reflection declared in " - } - }, - "required": [ - "typeReachable" - ], - "type": "object" - }, - "name": { - "type": "string", - "title": "Name of the class that should be registered for reflection" - }, - "methods": { - "default": [], - "items": { - "properties": { - "name": { - "type": "string", - "title": "List of method names that should be registered for the class declared in " - }, - "parameterTypes": { - "default": [], - "items": { - "type": "string", - "title": "List of types for the parameters of the method declared in " - }, - "type": "array" - } - }, - "required": [ - "name", - "parameterTypes" - ], - "type": "object" - }, - "type": "array", - "title": "List of methods that should be registered for the class declared in " - }, - "queriedMethods": { - "default": [], - "items": { - "properties": { - "name": { - "type": "string", - "title": "List of method names that are queried for the class declared in " - }, - "parameterTypes": { - "default": [], - "items": { - "type": "string", - "title": "List of types for the parameters of the method declared in " - }, - "type": "array" - } - }, - "required": [ - "name", - "parameterTypes" - ], - "type": "object" - }, - "type": "array", - "title": "List of methods that are queried for the class declared in " - }, - "fields": { - "default": [], - "items": { - "properties": { - "name": { - "type": "string", - "title": "Name of the field that should be registered for reflection" - } - }, - "type": "object" - }, - "type": "array", - "title": "List of fields that should be registered for the class declared in " - }, - "allDeclaredMethods": { - "default": true, - "type": "boolean" - }, - "allDeclaredFields": { - "default": true, - "type": "boolean" - }, - "allDeclaredConstructors": { - "default": true, - "type": "boolean" - }, - "allPublicMethods": { - "default": true, - "type": "boolean" - }, - "allPublicFields": { - "default": true, - "type": "boolean" - }, - "allPublicConstructors": { - "default": true, - "type": "boolean" - }, - "queryAllDeclaredMethods": { - "default": true, - "type": "boolean" - }, - "queryAllDeclaredConstructors": { - "default": true, - "type": "boolean" - }, - "queryAllPublicMethods": { - "default": true, - "type": "boolean" - }, - "queryAllPublicConstructors": { - "default": true, - "type": "boolean" - }, - "unsafeAllocated": { - "default": true, - "type": "boolean" - } - }, - "required": [ - "condition", - "name" - ], - "type": "object" - }, - "type": "array", - "title": "JSON schema for the reflect-config that GraalVM Native Image uses" -} \ No newline at end of file diff --git a/docs/reference-manual/native-image/assets/resource-config-schema.json b/docs/reference-manual/native-image/assets/resource-config-schema-v1.0.0.json similarity index 72% rename from docs/reference-manual/native-image/assets/resource-config-schema.json rename to docs/reference-manual/native-image/assets/resource-config-schema-v1.0.0.json index b7874cc3280a..d315e0ff052f 100644 --- a/docs/reference-manual/native-image/assets/resource-config-schema.json +++ b/docs/reference-manual/native-image/assets/resource-config-schema-v1.0.0.json @@ -1,39 +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/resource-config-schema-v1.0.0.json", "default": { "resources": {}, "bundles": [] }, - "examples": [ - { - "resources": { - "includes": [ - { - "condition": { - "typeReachable": "com.condition.resource.Class" - }, - "pattern": "\\Qcom/pattern/to/be/included\\E" - } - ], - "excludes": [ - { - "condition": { - "typeReachable": "com.condition.resource.Class" - }, - "pattern": "\\Qcom/pattern/to/be/excluded\\E" - } - ] - }, - "bundles": [ - { - "condition": { - "typeReachable": "com.condition.Class" - }, - "name": "com.bundle.name" - } - ] - } - ], "properties": { "resources": { "properties": { @@ -51,6 +22,7 @@ "required": [ "typeReachable" ], + "additionalProperties": false, "type": "object" }, "pattern": { @@ -58,9 +30,7 @@ "title": "Resource matching pattern" } }, - "required": [ - "condition" - ], + "additionalProperties": false, "type": "object" }, "type": "array", @@ -80,6 +50,7 @@ "required": [ "typeReachable" ], + "additionalProperties": false, "type": "object" }, "pattern": { @@ -87,15 +58,14 @@ "title": "Resource matching pattern" } }, - "required": [ - "condition" - ], + "additionalProperties": false, "type": "object" }, "type": "array", "title": "List of excluded resource patterns" } }, + "additionalProperties": false, "type": "object", "title": "Set of included and excluded lists of patterns" }, @@ -113,6 +83,7 @@ "required": [ "typeReachable" ], + "additionalProperties": false, "type": "object" }, "name": { @@ -125,18 +96,30 @@ "type": "string" }, "type": "array", - "title": "List of locales that should be registered for the resource bundle declared in " + "title": "List of locales that should be registered for this resource bundle" + }, + "classNames": { + "default": [], + "items": { + "type": "string" + }, + "type": "array", + "title": "List of fully qualified classnames of resource bundles that are directly included without performing the lookup by basename and locale." } }, - "required": [ - "condition" - ], + "additionalProperties": false, "type": "object" }, "type": "array", "title": "List of resource bundles that should be registered" } }, + "required": [ + "bundles", + "resources" + ], + "additionalProperties": false, "type": "object", - "title": "JSON schema for the resource-config that GraalVM Native Image uses" -} \ No newline at end of file + "title": "JSON schema for the resource-config that GraalVM Native Image uses", + "description": "Native Image will iterate over all resources and match their relative paths against the Java Regex specified in . If the path matches the Regex, the resource is included. The statement instructs Native Image to omit certain included resources that match the given " + } \ No newline at end of file diff --git a/docs/reference-manual/native-image/assets/serialization-config-schema.json b/docs/reference-manual/native-image/assets/serialization-config-schema-v1.0.0.json similarity index 70% rename from docs/reference-manual/native-image/assets/serialization-config-schema.json rename to docs/reference-manual/native-image/assets/serialization-config-schema-v1.0.0.json index 92f303870ee9..3d9cf6c20542 100644 --- a/docs/reference-manual/native-image/assets/serialization-config-schema.json +++ b/docs/reference-manual/native-image/assets/serialization-config-schema-v1.0.0.json @@ -1,43 +1,11 @@ { "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/serialization-config-schema-v1.0.0.json", "default": { "types": [], "lambdaCapturingTypes": [], "proxies": [] }, - "examples": [ - { - "types": [ - { - "condition": { - "typeReachable": "com.example.myPackage.ConditionClass" - }, - "name": "java.lang.Class", - "customTargetConstructorClass": "com.example.myPackage.CustomTargetConstructorClass" - } - ], - "lambdaCapturingTypes": [ - { - "condition": { - "typeReachable": "com.example.myPackage.ConditionLambdaCapturingClass" - }, - "name": "com.example.Class" - } - ], - "proxies": [ - { - "condition": { - "typeReachable": "com.example.myPackage.ConditionProxyClass" - }, - "interfaces": [ - "com.example.interface.name1", - "com.example.interface.name2", - "com.example.interface.name3" - ] - } - ] - } - ], "properties": { "types": { "default": [], @@ -53,6 +21,7 @@ "required": [ "typeReachable" ], + "additionalProperties": false, "type": "object" }, "name": { @@ -61,12 +30,13 @@ }, "customTargetConstructorClass": { "type": "string", - "title": "Fully qualified class name of the class which constructor should be used instead of serializing class constructor" + "title": "Fully qualified class name of the class whose constructor should be used to serialize the class" } }, + "additionalProperties": false, "type": "object" }, - "title": "List of classes that should be serialized", + "title": "Each entry in enables serializing and deserializing objects of the class given by ", "type": "array" }, "lambdaCapturingTypes": { @@ -83,6 +53,7 @@ "required": [ "typeReachable" ], + "additionalProperties": false, "type": "object" }, "name": { @@ -90,9 +61,10 @@ "title": "Fully qualified class name of the class that captures lambda classes that should be either serialized or deserialized" } }, + "additionalProperties": false, "type": "object" }, - "title": "List of classes that capture lambdas that should be serialized", + "title": "Each entry in enables lambda serialization. All lambdas declared in the methods of the class given by can be serialized and deserialized.", "type": "array" }, "proxies": { @@ -109,6 +81,7 @@ "required": [ "typeReachable" ], + "additionalProperties": false, "type": "object" }, "interfaces": { @@ -120,9 +93,14 @@ "title": "List of interfaces that are implemented by the proxy class that should be serialized" } }, - "type": "object" + "required": [ + "interfaces" + ], + "additionalProperties": false, + "type": "object", + "title": "Proxy that should be registered for serialization" }, - "title": "List of proxies that should be serialized", + "title": "Each entry in enables the proxy serialization by providing an interface list that a proxy implements.", "type": "array" } }, @@ -131,6 +109,7 @@ "lambdaCapturingTypes", "proxies" ], - "title": "JSON schema for the serialization-config that GraalVM Native Image uses", - "type": "object" + "additionalProperties": false, + "type": "object", + "title": "JSON schema for the serialization-config that GraalVM Native Image uses" } \ No newline at end of file