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 Object
implements org.glassfish.pfl.dynamic.copyobject.spi.ObjectCopier
Provides 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 ClassesModifier and TypeClassDescription(package private) class
Provides 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
FieldsModifier and TypeFieldDescriptionprivate static final org.glassfish.pfl.basic.reflection.Bridge
Bridge is used to access the reflection factory for obtaining serialization constructors.private final IdentityHashMap
private final ORB
private static Map
<Class, OldReflectObjectCopierImpl.ReflectAttrs> reflectCache is used to cache the reflection attributes of a class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate Object
Utility to copy array of primitive types or objects.private Object
private void
copyFields
(Class cls, Field[] fields, Object obj, Object copy) Utility to copy fields of an object.private Object
getClassAttrs
(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 Constructor
Returns public no-arg constructor of given class, or null if none found.private Constructor
Returns subclass-accessible no-arg constructor of first non-serializable superclass, or null if none found.static boolean
isImmutable
(String classname) private Object
makeInstanceOfClass
(Class cls) private boolean
packageEquals
(Class cl1, Class cl2) Returns true if classes are defined in the same package, false otherwise.private Object
reflectCopy
(Object obj) Utility to copy objects using Java reflection.
-
Field Details
-
objRefs
-
orb
-
reflectCache
reflectCache is used to cache the reflection attributes of a class -
bridge
private static final org.glassfish.pfl.basic.reflection.Bridge bridgeBridge is used to access the reflection factory for obtaining serialization constructors. This must be carefully protected!
-
-
Constructor Details
-
OldReflectObjectCopierImpl
-
-
Method Details
-
getExternalizableConstructor
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
Returns true if classes are defined in the same package, false otherwise. Copied from the Merlin java.io.ObjectStreamClass. -
getSerializableConstructor
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
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
-
arrayCopy
private Object arrayCopy(Object obj, Class aClass) throws RemoteException, InstantiationException, IllegalAccessException, InvocationTargetException Utility 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:
RemoteException
- if any object could not be copied.InstantiationException
IllegalAccessException
InvocationTargetException
-
copyFields
private void copyFields(Class cls, Field[] fields, Object obj, Object copy) throws RemoteException, IllegalAccessException, InstantiationException, InvocationTargetException Utility to copy fields of an object. Used by local stub to copy objects- Parameters:
obj
- the object whose fields need to be copied- Throws:
RemoteException
- if any object could not be copied.IllegalAccessException
InstantiationException
InvocationTargetException
-
makeInstanceOfClass
-
copyMap
private Object copyMap(Object obj) throws RemoteException, InstantiationException, IllegalAccessException, InvocationTargetException -
copyAnyClass
private Object copyAnyClass(OldReflectObjectCopierImpl.ReflectAttrs attrs, Object obj) throws RemoteException, InstantiationException, IllegalAccessException, InvocationTargetException -
reflectCopy
private Object reflectCopy(Object obj) throws RemoteException, InstantiationException, IllegalAccessException, InvocationTargetException Utility 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:
RemoteException
InstantiationException
IllegalAccessException
InvocationTargetException
-
copy
public Object copy(Object obj, boolean debug) throws org.glassfish.pfl.dynamic.copyobject.spi.ReflectiveCopyException - Throws:
org.glassfish.pfl.dynamic.copyobject.spi.ReflectiveCopyException
-
copy
public Object copy(Object obj) throws org.glassfish.pfl.dynamic.copyobject.spi.ReflectiveCopyException - Specified by:
copy
in interfaceorg.glassfish.pfl.dynamic.copyobject.spi.ObjectCopier
- Throws:
org.glassfish.pfl.dynamic.copyobject.spi.ReflectiveCopyException
-