Class Reflections
Warning: This class is part of the internal implementation and is not considered public API. It may change or be removed at any time without notice, and should not be used directly in external code.
-
Method Summary
Modifier and TypeMethodDescriptionextractMembers(Object instance) Extracts all declared field values from the given object instance, including fields inherited from superclasses (up to but excludingObject).static ObjectgetFieldValueSafely(Object instance, Field field) Get value of given instance field, temporarily switching to an accessible field to get the value.
-
Method Details
-
extractMembers
Extracts all declared field values from the given object instance, including fields inherited from superclasses (up to but excludingObject).The returned map preserves the encounter order of the fields as they are discovered in the class hierarchy (starting from the concrete class and moving up to its superclasses). Field names are used as keys and their corresponding values are the map values.
If a field with the same name exists in both a subclass and a superclass, the value from the subclass takes precedence. The returned map is unmodifiable; attempts to modify it will result in
UnsupportedOperationException.Internal API: This method is intended for internal use only and is not part of the public API. Its behavior and signature may change without notice.
- Parameters:
instance- The object to introspect; may benull.- Returns:
- An unmodifiable map containing field names as keys and their values
as retrieved from the given instance. If
instanceisnull, an empty map is returned. - Throws:
FieldAccessException- if a field value cannot be accessed via reflection.
-
getFieldValueSafely
-