Class PropertyAccessorFactoryUnsafe
java.lang.Object
com.alibaba.fastjson2.introspect.PropertyAccessorFactory
com.alibaba.fastjson2.introspect.PropertyAccessorFactoryLambda
com.alibaba.fastjson2.introspect.PropertyAccessorFactoryUnsafe
A specialized property accessor factory that uses Unsafe operations for field access
to provide better performance compared to reflection-based access.
This factory creates property accessors that use direct memory access via Unsafe
to get and set field values, which is faster than traditional reflection.
Note: This factory is named "Unsafe" because it uses sun.misc.Unsafe, which is not part of the standard Java API and may not be available in all JVM implementations.
This class extends PropertyAccessorFactory and overrides specific methods to provide Unsafe-based implementations for field access while maintaining compatibility with the parent class's method-based and function-based access patterns.
-
Nested Class Summary
Nested classes/interfaces inherited from class PropertyAccessorFactory
PropertyAccessorFactory.PropertyAccessorBigDecimal, PropertyAccessorFactory.PropertyAccessorBigInteger, PropertyAccessorFactory.PropertyAccessorBoolean, PropertyAccessorFactory.PropertyAccessorBooleanValue, PropertyAccessorFactory.PropertyAccessorByte, PropertyAccessorFactory.PropertyAccessorByteValue, PropertyAccessorFactory.PropertyAccessorCharacter, PropertyAccessorFactory.PropertyAccessorCharValue, PropertyAccessorFactory.PropertyAccessorDouble, PropertyAccessorFactory.PropertyAccessorDoubleValue, PropertyAccessorFactory.PropertyAccessorFloat, PropertyAccessorFactory.PropertyAccessorInteger, PropertyAccessorFactory.PropertyAccessorIntValue, PropertyAccessorFactory.PropertyAccessorLong, PropertyAccessorFactory.PropertyAccessorLongValue, PropertyAccessorFactory.PropertyAccessorNumber, PropertyAccessorFactory.PropertyAccessorObject, PropertyAccessorFactory.PropertyAccessorShort, PropertyAccessorFactory.PropertyAccessorShortValue, PropertyAccessorFactory.PropertyAccessorString -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected PropertyAccessorcreateInternal(Field field) Creates an Unsafe-based property accessor for the specified field.Methods inherited from class PropertyAccessorFactoryLambda
create, createBiFunction, createDoubleFunction, createFunction, createIntFunction, createLongFunction, createSupplier, createSupplier, getBoolean, getByte, getChar, getDouble, getFloat, getInt, getLong, getObject, getShort, lookup, setBoolean, setByte, setChar, setDouble, setFloat, setInt, setLong, setObject, setObject, setShort
-
Constructor Details
-
PropertyAccessorFactoryUnsafe
public PropertyAccessorFactoryUnsafe()
-
-
Method Details
-
createInternal
Creates an Unsafe-based property accessor for the specified field. This method analyzes the field type and returns an appropriate accessor implementation optimized for that type using Unsafe operations.- Overrides:
createInternalin classPropertyAccessorFactory- Parameters:
field- the field to create an accessor for- Returns:
- a PropertyAccessor instance for the specified field using Unsafe operations
-