You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/reference-manual/native-image/ReachabilityMetadata.md
+6-10
Original file line number
Diff line number
Diff line change
@@ -331,11 +331,10 @@ In case the field-value-access metadata is missing, the following methods will t
331
331
332
332
### Unsafe Allocation of a Type
333
333
334
-
For unsafe allocation of a type via `sun.misc.Unsafe#allocateInstance(Class<?>)`, or from native code via `AllocObject(jClass)`, we must provide the following metadata:
334
+
For unsafe allocation of a type via `sun.misc.Unsafe#allocateInstance(Class<?>)`, or from native code via `AllocObject(jClass)`, the type must be registered for reflection. The following metadata is sufficient:
335
335
```json
336
336
{
337
-
"type": "FullyQualifiedUnsafeAllocatedType",
338
-
"unsafeAllocated": true
337
+
"type": "FullyQualifiedUnsafeAllocatedType"
339
338
}
340
339
```
341
340
Otherwise, these methods will throw a `MissingReflectionRegistrationError`.
@@ -360,8 +359,7 @@ The overall definition of a type in JSON can have the following values:
360
359
"allDeclaredMethods": true,
361
360
"allPublicMethods": true,
362
361
"allDeclaredFields": true,
363
-
"allPublicFields": true,
364
-
"unsafeAllocated": true
362
+
"allPublicFields": true
365
363
}
366
364
```
367
365
@@ -430,13 +428,12 @@ As a convenience, one can allow method invocation for groups of methods by addin
430
428
`allDeclaredConstructors` and `allDeclaredMethods` allow calls invocations of methods declared on a given type.
431
429
`allPublicConstructors` and `allPublicMethods` allow invocations of all public methods defined on a type and all of its supertypes.
432
430
433
-
To allocate objects of a type with `AllocObject`, the metadata must be stored in the `reflection` section:
431
+
To allocate objects of a type with `AllocObject`, the type must be registered in the `reflection` section:
434
432
```json
435
433
{
436
434
"reflection": [
437
435
{
438
-
"type": "jni.accessed.Type",
439
-
"unsafeAllocated": true
436
+
"type": "jni.unsafe.allocated.Type"
440
437
}
441
438
]
442
439
}
@@ -698,8 +695,7 @@ See below is a sample reachability metadata configuration that you can use in _r
* (GR-60234) Remove `"customTargetConstructorClass"` field from the serialization JSON metadata. All possible constructors are now registered by default when registering a type for serialization.
20
+
* (GR-60235) Remove `"unsafeAllocated"` field from the reflection JSON metadata. All reflectively-accessible types are now automatically registered for unsafe allocation.
20
21
21
22
## GraalVM for JDK 23 (Internal Version 24.1.0)
22
23
* (GR-51520) The old class initialization strategy, which was deprecated in GraalVM for JDK 22, is removed. The option `StrictImageHeap` no longer has any effect.
Copy file name to clipboardexpand all lines: substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/ParserConfigurationAdapter.java
-6
Original file line number
Diff line number
Diff line change
@@ -81,12 +81,6 @@ public boolean registerAllConstructors(UnresolvedConfigurationCondition conditio
Copy file name to clipboardexpand all lines: substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/LegacyReflectionConfigurationParser.java
if (!unsafeAllocatedWarningTriggered && data.containsKey("unsafeAllocated")) {
100
+
unsafeAllocatedWarningTriggered = true;
101
+
LogUtils.warning("\"unsafeAllocated\" is deprecated in reflection-config.json. All reflectively-accessed classes can be instantiated through unsafe without the use of the flag.");
Copy file name to clipboardexpand all lines: substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ReflectionConfigurationParserDelegate.java
-2
Original file line number
Diff line number
Diff line change
@@ -68,8 +68,6 @@ public interface ReflectionConfigurationParserDelegate<C, T> {
if (!unsafeAllocatedWarningTriggered && data.containsKey("unsafeAllocated")) {
105
+
unsafeAllocatedWarningTriggered = true;
106
+
LogUtils.warning("\"unsafeAllocated\" is deprecated in reachability-metadata.json. All reflectively-accessed classes can be instantiated through unsafe without the use of the flag.");
0 commit comments