diff --git a/spring-core/src/main/java/org/springframework/aot/hint/MemberCategory.java b/spring-core/src/main/java/org/springframework/aot/hint/MemberCategory.java index 05b60208a6..4025366932 100644 --- a/spring-core/src/main/java/org/springframework/aot/hint/MemberCategory.java +++ b/spring-core/src/main/java/org/springframework/aot/hint/MemberCategory.java @@ -166,6 +166,14 @@ public enum MemberCategory { * when {@link ReflectionHints#registerType(Class, MemberCategory...) adding a reflection hint for a type}. */ @Deprecated(since = "7.0", forRemoval = true) - DECLARED_CLASSES + DECLARED_CLASSES, + + /** + * A category that represents the need for + * {@link sun.misc.Unsafe#allocateInstance(Class) unsafe allocation} + * for this type. + * @since 6.2.1 + */ + UNSAFE_ALLOCATED } diff --git a/spring-core/src/main/java/org/springframework/aot/nativex/ReflectionHintsAttributes.java b/spring-core/src/main/java/org/springframework/aot/nativex/ReflectionHintsAttributes.java index 4d7b2b27a4..468a9d51fb 100644 --- a/spring-core/src/main/java/org/springframework/aot/nativex/ReflectionHintsAttributes.java +++ b/spring-core/src/main/java/org/springframework/aot/nativex/ReflectionHintsAttributes.java @@ -129,6 +129,9 @@ class ReflectionHintsAttributes { case INVOKE_PUBLIC_METHODS -> attributes.put("allPublicMethods", true); case INVOKE_DECLARED_METHODS -> attributes.put("allDeclaredMethods", true); + case PUBLIC_CLASSES -> attributes.put("allPublicClasses", true); + case DECLARED_CLASSES -> attributes.put("allDeclaredClasses", true); + case UNSAFE_ALLOCATED -> attributes.put("unsafeAllocated", true); } } ); diff --git a/spring-core/src/test/java/org/springframework/aot/nativex/RuntimeHintsWriterTests.java b/spring-core/src/test/java/org/springframework/aot/nativex/RuntimeHintsWriterTests.java index e0f832d35a..b4ffbe861e 100644 --- a/spring-core/src/test/java/org/springframework/aot/nativex/RuntimeHintsWriterTests.java +++ b/spring-core/src/test/java/org/springframework/aot/nativex/RuntimeHintsWriterTests.java @@ -84,7 +84,8 @@ class RuntimeHintsWriterTests { .onReachableType(String.class) .withMembers(MemberCategory.INVOKE_PUBLIC_FIELDS, MemberCategory.INVOKE_DECLARED_FIELDS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, - MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_DECLARED_METHODS) + MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_DECLARED_METHODS, + MemberCategory.UNSAFE_ALLOCATED) .withField("DEFAULT_CHARSET") .withField("defaultCharset") .withField("aScore") @@ -101,6 +102,7 @@ class RuntimeHintsWriterTests { "allDeclaredConstructors": true, "allPublicMethods": true, "allDeclaredMethods": true, + "unsafeAllocated": true, "fields": [ { "name": "aScore" }, { "name": "DEFAULT_CHARSET" },