Class SunUnsafeReflectionProvider

  • All Implemented Interfaces:
    ReflectionProvider
    Direct Known Subclasses:
    Sun14ReflectionProvider

    public class SunUnsafeReflectionProvider
    extends SunLimitedUnsafeReflectionProvider
    Instantiates a new object bypassing the constructor using undocumented internal JDK features.

    The code in the constructor will never be executed and parameters do not have to be known. This is the same method used by the internals of standard Java serialization, but relies on internal code (sun.misc.Unsafe) that may not be present on all JVMs.

    The implementation will use the same internals to write into fields. This is a lot faster and was additionally the only possibility to set final fields prior to Java 5.

    Since:
    1.4.7
    • Field Detail

      • fieldOffsetCache

        private transient java.util.Map fieldOffsetCache
    • Constructor Detail

      • SunUnsafeReflectionProvider

        public SunUnsafeReflectionProvider()
        Since:
        1.4.7
      • SunUnsafeReflectionProvider

        public SunUnsafeReflectionProvider​(FieldDictionary dic)
        Since:
        1.4.7
    • Method Detail

      • write

        private void write​(java.lang.reflect.Field field,
                           java.lang.Object object,
                           java.lang.Object value)
      • getFieldOffset

        private long getFieldOffset​(java.lang.reflect.Field f)
      • readResolve

        private java.lang.Object readResolve()