Class Bridge
java.lang.Object
org.glassfish.pfl.basic.reflection.BridgeBase
org.glassfish.pfl.basic.reflection.Bridge
public final class Bridge
extends org.glassfish.pfl.basic.reflection.BridgeBase
This class provides the methods for fundamental JVM operations
needed in the ORB that are not part of the public Java API. This includes:
- throwException, which can throw undeclared checked exceptions. This is needed to handle throwing arbitrary exceptions across a standardized OMG interface that (incorrectly) does not specify appropriate exceptions.
- putXXX/getXXX methods that allow unchecked access to fields of objects. This is used for setting uninitialzed non-static final fields (which is impossible with reflection) and for speed.
- objectFieldOffset to obtain the field offsets for use in the putXXX/getXXX methods
- newConstructorForSerialization to get the special constructor required for a Serializable class
- latestUserDefinedLoader to get the latest user defined class loader from the call stack as required by the RMI-IIOP specification (really from the JDK 1.1 days)
- RuntimePermission "reflectionFactoryAccess"
- BridgePermission "getBridge"
- ReflectPermission "suppressAccessChecks"
All of these permissions are required to obtain and correctly initialize the instance of Bridge. No security checks are performed on calls made to Bridge instance methods, so access to the Bridge instance must be protected.
This class is a singleton (per ClassLoader of course). Access to the instance is obtained through the Bridge.get() method.
-
Field Summary
Fields inherited from class org.glassfish.pfl.basic.reflection.BridgeBase
INVALID_FIELD_OFFSET -
Method Summary
Modifier and TypeMethodDescriptionClass<?> defineClass(Class<?> anchorClass, String className, byte[] classBytes) Class<?> defineClass(String className, byte[] classBytes, ClassLoader classLoader, ProtectionDomain protectionDomain) static Bridgeget()Fetch the Bridge singleton.final ClassLoaderfinal booleanReturns true if the given class defines a static initializer method, false otherwise.final <T> Constructor<T> <T> Constructor<T> newConstructorForSerialization(Class<T> aClass) final <T> Constructor<T> newConstructorForSerialization(Class<T> aClass, Constructor<?> cons) final OptionalDataExceptionnewOptionalDataExceptionForSerialization(boolean bool) final MethodHandlereadObjectForSerialization(Class<?> cl) final MethodHandlefinal MethodHandlereadResolveForSerialization(Class<?> cl) toAccessibleField(Field field, Class callingClass) toAccessibleMethod(Method method, Class callingClass) final MethodHandlewriteObjectForSerialization(Class<?> cl) final MethodHandleMethods inherited from class org.glassfish.pfl.basic.reflection.BridgeBase
ensureClassInitialized, getBoolean, getByte, getChar, getDouble, getFloat, getInt, getLong, getObject, getShort, objectFieldOffset, putBoolean, putByte, putChar, putDouble, putFloat, putInt, putLong, putObject, putShort, staticFieldOffset, throwException
-
Method Details
-
get
Fetch the Bridge singleton. This requires the following permissions:- RuntimePermission "reflectionFactoryAccess"
- BridgePermission "getBridge"
- ReflectPermission "suppressAccessChecks"
- Returns:
- The singleton instance of the Bridge class
- Throws:
SecurityException- if the caller does not have the required permissions and the caller has a non-null security manager.
-
defineClass
public Class<?> defineClass(String className, byte[] classBytes, ClassLoader classLoader, ProtectionDomain protectionDomain) - Overrides:
defineClassin classorg.glassfish.pfl.basic.reflection.BridgeBase
-
defineClass
- Overrides:
defineClassin classorg.glassfish.pfl.basic.reflection.BridgeBase
-
getLatestUserDefinedLoader
- Specified by:
getLatestUserDefinedLoaderin classorg.glassfish.pfl.basic.reflection.BridgeBase
-
newConstructorForExternalization
- Specified by:
newConstructorForExternalizationin classorg.glassfish.pfl.basic.reflection.BridgeBase
-
newConstructorForSerialization
public final <T> Constructor<T> newConstructorForSerialization(Class<T> aClass, Constructor<?> cons) - Specified by:
newConstructorForSerializationin classorg.glassfish.pfl.basic.reflection.BridgeBase
-
newConstructorForSerialization
- Specified by:
newConstructorForSerializationin classorg.glassfish.pfl.basic.reflection.BridgeBase
-
hasStaticInitializerForSerialization
Returns true if the given class defines a static initializer method, false otherwise.- Specified by:
hasStaticInitializerForSerializationin classorg.glassfish.pfl.basic.reflection.BridgeBase
-
writeObjectForSerialization
- Specified by:
writeObjectForSerializationin classorg.glassfish.pfl.basic.reflection.BridgeBase
-
readObjectForSerialization
- Specified by:
readObjectForSerializationin classorg.glassfish.pfl.basic.reflection.BridgeBase
-
readObjectNoDataForSerialization
-
readResolveForSerialization
- Specified by:
readResolveForSerializationin classorg.glassfish.pfl.basic.reflection.BridgeBase
-
writeReplaceForSerialization
- Specified by:
writeReplaceForSerializationin classorg.glassfish.pfl.basic.reflection.BridgeBase
-
newOptionalDataExceptionForSerialization
- Specified by:
newOptionalDataExceptionForSerializationin classorg.glassfish.pfl.basic.reflection.BridgeBase
-
toAccessibleField
- Overrides:
toAccessibleFieldin classorg.glassfish.pfl.basic.reflection.BridgeBase
-
toAccessibleMethod
- Overrides:
toAccessibleMethodin classorg.glassfish.pfl.basic.reflection.BridgeBase
-