Package com.sun.corba.ee.impl.copyobject
Class OldReflectObjectCopierImpl
- java.lang.Object
-
- com.sun.corba.ee.impl.copyobject.OldReflectObjectCopierImpl
-
- All Implemented Interfaces:
org.glassfish.pfl.dynamic.copyobject.spi.ObjectCopier
public class OldReflectObjectCopierImpl extends java.lang.Object implements org.glassfish.pfl.dynamic.copyobject.spi.ObjectCopierProvides the functionality of copying objects using reflection. NOTE: Currently the implementation does not implement this copying functionality for objects which have fields whose types are based on inner classes. If for any reason copying cannot be done using reflection it uses the original ORB serialization to implement the copying
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classOldReflectObjectCopierImpl.ReflectAttrsProvides the functionality of a cache for storing the various reflection attributes of a class so that access to these methods is not done repeatedly
-
Field Summary
Fields Modifier and Type Field Description private static org.glassfish.pfl.basic.reflection.BridgebridgeBridge is used to access the reflection factory for obtaining serialization constructors.private java.util.IdentityHashMapobjRefsprivate ORBorbprivate static java.util.Map<java.lang.Class,OldReflectObjectCopierImpl.ReflectAttrs>reflectCachereflectCache is used to cache the reflection attributes of a class
-
Constructor Summary
Constructors Constructor Description OldReflectObjectCopierImpl(ORB orb)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.ObjectarrayCopy(java.lang.Object obj, java.lang.Class aClass)Utility to copy array of primitive types or objects.java.lang.Objectcopy(java.lang.Object obj)java.lang.Objectcopy(java.lang.Object obj, boolean debug)private java.lang.ObjectcopyAnyClass(OldReflectObjectCopierImpl.ReflectAttrs attrs, java.lang.Object obj)private voidcopyFields(java.lang.Class cls, java.lang.reflect.Field[] fields, java.lang.Object obj, java.lang.Object copy)Utility to copy fields of an object.private java.lang.ObjectcopyMap(java.lang.Object obj)private OldReflectObjectCopierImpl.ReflectAttrsgetClassAttrs(java.lang.Class cls)Gets the reflection attributes for a class from the cache or if it is not in the cache yet, computes the attributes and populates the cacheprivate java.lang.reflect.ConstructorgetExternalizableConstructor(java.lang.Class cl)Returns public no-arg constructor of given class, or null if none found.private java.lang.reflect.ConstructorgetSerializableConstructor(java.lang.Class cl)Returns subclass-accessible no-arg constructor of first non-serializable superclass, or null if none found.static booleanisImmutable(java.lang.String classname)private java.lang.ObjectmakeInstanceOfClass(java.lang.Class cls)private booleanpackageEquals(java.lang.Class cl1, java.lang.Class cl2)Returns true if classes are defined in the same package, false otherwise.private java.lang.ObjectreflectCopy(java.lang.Object obj)Utility to copy objects using Java reflection.
-
-
-
Field Detail
-
objRefs
private final java.util.IdentityHashMap objRefs
-
orb
private final ORB orb
-
reflectCache
private static java.util.Map<java.lang.Class,OldReflectObjectCopierImpl.ReflectAttrs> reflectCache
reflectCache is used to cache the reflection attributes of a class
-
bridge
private static final org.glassfish.pfl.basic.reflection.Bridge bridge
Bridge is used to access the reflection factory for obtaining serialization constructors. This must be carefully protected!
-
-
Constructor Detail
-
OldReflectObjectCopierImpl
public OldReflectObjectCopierImpl(ORB orb)
-
-
Method Detail
-
getExternalizableConstructor
private java.lang.reflect.Constructor getExternalizableConstructor(java.lang.Class cl)
Returns public no-arg constructor of given class, or null if none found. Access checks are disabled on the returned constructor (if any), since the defining class may still be non-public.
-
packageEquals
private boolean packageEquals(java.lang.Class cl1, java.lang.Class cl2)Returns true if classes are defined in the same package, false otherwise. Copied from the Merlin java.io.ObjectStreamClass.
-
getSerializableConstructor
private java.lang.reflect.Constructor getSerializableConstructor(java.lang.Class cl)
Returns subclass-accessible no-arg constructor of first non-serializable superclass, or null if none found. Access checks are disabled on the returned constructor (if any).
-
getClassAttrs
private OldReflectObjectCopierImpl.ReflectAttrs getClassAttrs(java.lang.Class cls)
Gets the reflection attributes for a class from the cache or if it is not in the cache yet, computes the attributes and populates the cache- Parameters:
cls- the class whose attributes are needed- Returns:
- the attributes needed for reflection This method must be synchronized so that reflectCache.put can safely update the reflectCache.
-
isImmutable
public static boolean isImmutable(java.lang.String classname)
-
arrayCopy
private java.lang.Object arrayCopy(java.lang.Object obj, java.lang.Class aClass) throws java.rmi.RemoteException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetExceptionUtility to copy array of primitive types or objects. Used by local stubs to copy objects- Parameters:
obj- the object to copy or connect.- Returns:
- the copied object.
- Throws:
java.rmi.RemoteException- if any object could not be copied.java.lang.InstantiationExceptionjava.lang.IllegalAccessExceptionjava.lang.reflect.InvocationTargetException
-
copyFields
private void copyFields(java.lang.Class cls, java.lang.reflect.Field[] fields, java.lang.Object obj, java.lang.Object copy) throws java.rmi.RemoteException, java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.reflect.InvocationTargetExceptionUtility to copy fields of an object. Used by local stub to copy objects- Parameters:
obj- the object whose fields need to be copied- Throws:
java.rmi.RemoteException- if any object could not be copied.java.lang.IllegalAccessExceptionjava.lang.InstantiationExceptionjava.lang.reflect.InvocationTargetException
-
makeInstanceOfClass
private java.lang.Object makeInstanceOfClass(java.lang.Class cls) throws java.lang.IllegalAccessException, java.lang.InstantiationException- Throws:
java.lang.IllegalAccessExceptionjava.lang.InstantiationException
-
copyMap
private java.lang.Object copyMap(java.lang.Object obj) throws java.rmi.RemoteException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException- Throws:
java.rmi.RemoteExceptionjava.lang.InstantiationExceptionjava.lang.IllegalAccessExceptionjava.lang.reflect.InvocationTargetException
-
copyAnyClass
private java.lang.Object copyAnyClass(OldReflectObjectCopierImpl.ReflectAttrs attrs, java.lang.Object obj) throws java.rmi.RemoteException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
- Throws:
java.rmi.RemoteExceptionjava.lang.InstantiationExceptionjava.lang.IllegalAccessExceptionjava.lang.reflect.InvocationTargetException
-
reflectCopy
private java.lang.Object reflectCopy(java.lang.Object obj) throws java.rmi.RemoteException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetExceptionUtility to copy objects using Java reflection. Used by the local stub to copy objects- Parameters:
obj- the object to copy or connect.- Returns:
- the copied object.
- Throws:
java.rmi.RemoteExceptionjava.lang.InstantiationExceptionjava.lang.IllegalAccessExceptionjava.lang.reflect.InvocationTargetException
-
copy
public java.lang.Object copy(java.lang.Object obj, boolean debug) throws org.glassfish.pfl.dynamic.copyobject.spi.ReflectiveCopyException- Throws:
org.glassfish.pfl.dynamic.copyobject.spi.ReflectiveCopyException
-
copy
public java.lang.Object copy(java.lang.Object obj) throws org.glassfish.pfl.dynamic.copyobject.spi.ReflectiveCopyException- Specified by:
copyin interfaceorg.glassfish.pfl.dynamic.copyobject.spi.ObjectCopier- Throws:
org.glassfish.pfl.dynamic.copyobject.spi.ReflectiveCopyException
-
-