Class ClassCopierOrdinaryImpl
- java.lang.Object
-
- org.glassfish.pfl.dynamic.copyobject.impl.ClassCopierBase
-
- org.glassfish.pfl.dynamic.copyobject.impl.ClassCopierOrdinaryImpl
-
- All Implemented Interfaces:
ClassCopier
public class ClassCopierOrdinaryImpl extends ClassCopierBase
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceClassCopierOrdinaryImpl.ClassFieldCopierprivate static classClassCopierOrdinaryImpl.ClassFieldCopierUnsafeImplUse bridge to copy objects.private static classClassCopierOrdinaryImpl.ConstructorFactoryClass used as a factory for the appropriate Serialization constructors.
-
Field Summary
Fields Modifier and Type Field Description private static BridgeBRIDGE_REFBridge is used to access unsafe methods used to read and write arbitrary data members in objects.private ClassCopierOrdinaryImpl.ClassFieldCopierclassFieldCopierprivate static java.util.Map<java.lang.Class<?>,ClassCopierOrdinaryImpl.ClassFieldCopier>classToClassFieldCopierprivate static java.util.Map<java.lang.Class<?>,java.lang.reflect.Constructor<?>>classToConstructorprivate static java.lang.PackageCODEGEN_IMPLprivate static java.lang.PackageCODEGEN_SPIprivate java.lang.reflect.Constructor<?>constructorprivate static java.lang.ThreadLocal<java.lang.Boolean>isCodegenCopierAllowedprivate java.lang.invoke.MethodHandlereadResolveMethod
-
Constructor Summary
Constructors Constructor Description ClassCopierOrdinaryImpl(PipelineClassCopierFactory ccf, java.lang.Class<?> cls)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectcreateCopy(java.lang.Object source)Create a copy of source.java.lang.ObjectdoCopy(java.util.Map<java.lang.Object,java.lang.Object> oldToNew, java.lang.Object source, java.lang.Object result)Do the copying of data from source to result.private static ClassCopierOrdinaryImpl.ClassFieldCopiergetClassFieldCopier(java.lang.Class<?> cls, PipelineClassCopierFactory classCopierFactory)private static ClassCopierOrdinaryImpl.ClassFieldCopiergetSuperCopier(PipelineClassCopierFactory ccf, java.lang.Class<?> cls)private static ClassCopierOrdinaryImpl.ClassFieldCopiermakeClassFieldCopierUnsafeCodegenImpl(java.lang.Class<?> cls, PipelineClassCopierFactory classCopierFactory)Use bridge with code generated by codegen to copy objects.private java.lang.Objectresolve(java.lang.Object obj)static voidsetCodegenCopierAllowed(boolean flag)private static booleanuseCodegenCopier()-
Methods inherited from class org.glassfish.pfl.dynamic.copyobject.impl.ClassCopierBase
copy, equals, hashCode, isReflectiveClassCopier, toString
-
-
-
-
Field Detail
-
BRIDGE_REF
private static final Bridge BRIDGE_REF
Bridge is used to access unsafe methods used to read and write arbitrary data members in objects. This is very fast, and completely ignores access protections including final on fields. NOTE WELL: Unsafe is capable of causing severe damage to the VM, including causing the VM to dump core. get and put calls must only be made with offsets obtained from objectFieldOffset calls. Because of the dangerous nature of Unsafe, its use must be carefully protected.
-
classToClassFieldCopier
private static java.util.Map<java.lang.Class<?>,ClassCopierOrdinaryImpl.ClassFieldCopier> classToClassFieldCopier
-
CODEGEN_SPI
private static final java.lang.Package CODEGEN_SPI
-
CODEGEN_IMPL
private static final java.lang.Package CODEGEN_IMPL
-
isCodegenCopierAllowed
private static java.lang.ThreadLocal<java.lang.Boolean> isCodegenCopierAllowed
-
classToConstructor
private static java.util.Map<java.lang.Class<?>,java.lang.reflect.Constructor<?>> classToConstructor
-
classFieldCopier
private ClassCopierOrdinaryImpl.ClassFieldCopier classFieldCopier
-
constructor
private java.lang.reflect.Constructor<?> constructor
-
readResolveMethod
private java.lang.invoke.MethodHandle readResolveMethod
-
-
Constructor Detail
-
ClassCopierOrdinaryImpl
public ClassCopierOrdinaryImpl(PipelineClassCopierFactory ccf, java.lang.Class<?> cls) throws ReflectiveCopyException
- Throws:
ReflectiveCopyException
-
-
Method Detail
-
resolve
private java.lang.Object resolve(java.lang.Object obj)
-
useCodegenCopier
private static boolean useCodegenCopier()
-
setCodegenCopierAllowed
public static void setCodegenCopierAllowed(boolean flag)
-
getClassFieldCopier
private static ClassCopierOrdinaryImpl.ClassFieldCopier getClassFieldCopier(java.lang.Class<?> cls, PipelineClassCopierFactory classCopierFactory) throws ReflectiveCopyException
- Throws:
ReflectiveCopyException
-
getSuperCopier
private static ClassCopierOrdinaryImpl.ClassFieldCopier getSuperCopier(PipelineClassCopierFactory ccf, java.lang.Class<?> cls) throws ReflectiveCopyException
- Throws:
ReflectiveCopyException
-
makeClassFieldCopierUnsafeCodegenImpl
private static ClassCopierOrdinaryImpl.ClassFieldCopier makeClassFieldCopierUnsafeCodegenImpl(java.lang.Class<?> cls, PipelineClassCopierFactory classCopierFactory) throws ReflectiveCopyException
Use bridge with code generated by codegen to copy objects. This method must be invoked from inside a doPrivileged call.- Throws:
ReflectiveCopyException
-
createCopy
public java.lang.Object createCopy(java.lang.Object source) throws ReflectiveCopyExceptionDescription copied from class:ClassCopierBaseCreate a copy of source. The copy may or may not be fully initialized. This method must always be overridden in a subclass.- Specified by:
createCopyin classClassCopierBase- Throws:
ReflectiveCopyException
-
doCopy
public java.lang.Object doCopy(java.util.Map<java.lang.Object,java.lang.Object> oldToNew, java.lang.Object source, java.lang.Object result) throws ReflectiveCopyExceptionDescription copied from class:ClassCopierBaseDo the copying of data from source to result. This just returns the result by default, but it may be overrideden in a subclass. When this method completes, result must be fully initialized.- Overrides:
doCopyin classClassCopierBase- Throws:
ReflectiveCopyException
-
-