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)
The code that calls Bridge.get() must have the following Permissions:
  • 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.

  • Method Details

    • get

      public static Bridge 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:
      defineClass in class org.glassfish.pfl.basic.reflection.BridgeBase
    • defineClass

      public Class<?> defineClass(Class<?> anchorClass, String className, byte[] classBytes)
      Overrides:
      defineClass in class org.glassfish.pfl.basic.reflection.BridgeBase
    • getLatestUserDefinedLoader

      public final ClassLoader getLatestUserDefinedLoader()
      Specified by:
      getLatestUserDefinedLoader in class org.glassfish.pfl.basic.reflection.BridgeBase
    • newConstructorForExternalization

      public final <T> Constructor<T> newConstructorForExternalization(Class<T> cl)
      Specified by:
      newConstructorForExternalization in class org.glassfish.pfl.basic.reflection.BridgeBase
    • newConstructorForSerialization

      public final <T> Constructor<T> newConstructorForSerialization(Class<T> aClass, Constructor<?> cons)
      Specified by:
      newConstructorForSerialization in class org.glassfish.pfl.basic.reflection.BridgeBase
    • newConstructorForSerialization

      public <T> Constructor<T> newConstructorForSerialization(Class<T> aClass)
      Specified by:
      newConstructorForSerialization in class org.glassfish.pfl.basic.reflection.BridgeBase
    • hasStaticInitializerForSerialization

      public final boolean hasStaticInitializerForSerialization(Class<?> cl)
      Returns true if the given class defines a static initializer method, false otherwise.
      Specified by:
      hasStaticInitializerForSerialization in class org.glassfish.pfl.basic.reflection.BridgeBase
    • writeObjectForSerialization

      public final MethodHandle writeObjectForSerialization(Class<?> cl)
      Specified by:
      writeObjectForSerialization in class org.glassfish.pfl.basic.reflection.BridgeBase
    • readObjectForSerialization

      public final MethodHandle readObjectForSerialization(Class<?> cl)
      Specified by:
      readObjectForSerialization in class org.glassfish.pfl.basic.reflection.BridgeBase
    • readObjectNoDataForSerialization

      public final MethodHandle readObjectNoDataForSerialization(Class<?> cl)
    • readResolveForSerialization

      public final MethodHandle readResolveForSerialization(Class<?> cl)
      Specified by:
      readResolveForSerialization in class org.glassfish.pfl.basic.reflection.BridgeBase
    • writeReplaceForSerialization

      public final MethodHandle writeReplaceForSerialization(Class<?> cl)
      Specified by:
      writeReplaceForSerialization in class org.glassfish.pfl.basic.reflection.BridgeBase
    • newOptionalDataExceptionForSerialization

      public final OptionalDataException newOptionalDataExceptionForSerialization(boolean bool)
      Specified by:
      newOptionalDataExceptionForSerialization in class org.glassfish.pfl.basic.reflection.BridgeBase
    • toAccessibleField

      public Field toAccessibleField(Field field, Class callingClass)
      Overrides:
      toAccessibleField in class org.glassfish.pfl.basic.reflection.BridgeBase
    • toAccessibleMethod

      public Method toAccessibleMethod(Method method, Class callingClass)
      Overrides:
      toAccessibleMethod in class org.glassfish.pfl.basic.reflection.BridgeBase