Class BridgeBase

java.lang.Object
org.glassfish.pfl.basic.reflection.BridgeBase
Direct Known Subclasses:
Bridge

public abstract class BridgeBase extends Object
  • Field Details

  • Constructor Details

    • BridgeBase

      public BridgeBase()
  • Method Details

    • getInt

      public final int getInt(Object o, long offset)
      Fetches a field element within the given object o at the given offset. The result is undefined unless the offset was obtained from objectFieldOffset(java.lang.reflect.Field) on the Field of some Java field and the object referred to by o is of a class compatible with that field's class.
      Parameters:
      o - Java heap object in which the field from which the offset was obtained resides
      offset - indication of where the field resides in a Java heap object
      Returns:
      the value fetched from the indicated Java field
      Throws:
      RuntimeException - No defined exceptions are thrown, not even NullPointerException
    • putInt

      public final void putInt(Object o, long offset, int x)
      Stores a value into a given Java field.

      The first two parameters are interpreted exactly as with getInt(Object, long) to refer to a specific Java field. The given value is stored into that field.

      The field must be of the same type as the method parameter x.

      Parameters:
      o - Java heap object in which the field resides, if any, else null
      offset - indication of where the field resides in a Java heap object.
      x - the value to store into the indicated Java field
      Throws:
      RuntimeException - No defined exceptions are thrown, not even NullPointerException
    • getObject

      public final <T> T getObject(Object o, long offset)
      See Also:
    • putObject

      public final void putObject(Object o, long offset, Object x)
      See Also:
    • getBoolean

      public final boolean getBoolean(Object o, long offset)
      See Also:
    • putBoolean

      public final void putBoolean(Object o, long offset, boolean x)
      See Also:
    • getByte

      public final byte getByte(Object o, long offset)
      See Also:
    • putByte

      public final void putByte(Object o, long offset, byte x)
      See Also:
    • getShort

      public final short getShort(Object o, long offset)
      See Also:
    • putShort

      public final void putShort(Object o, long offset, short x)
      See Also:
    • getChar

      public final char getChar(Object o, long offset)
      See Also:
    • putChar

      public final void putChar(Object o, long offset, char x)
      See Also:
    • getLong

      public final long getLong(Object o, long offset)
      See Also:
    • putLong

      public final void putLong(Object o, long offset, long x)
      See Also:
    • getFloat

      public final float getFloat(Object o, long offset)
      See Also:
    • putFloat

      public final void putFloat(Object o, long offset, float x)
      See Also:
    • getDouble

      public final double getDouble(Object o, long offset)
      See Also:
    • putDouble

      public final void putDouble(Object o, long offset, double x)
      See Also:
    • objectFieldOffset

      public final long objectFieldOffset(Field f)
      Returns the offset of a non-static field, which can be passed into the set... or get... methods.
      See Also:
    • staticFieldOffset

      public final long staticFieldOffset(Field f)
    • throwException

      public final void throwException(Throwable ee)
      Throw the exception. The exception may be an undeclared checked exception.
    • defineClass

      @Deprecated public Class<?> defineClass(String className, byte[] classBytes, ClassLoader classLoader, ProtectionDomain protectionDomain)
      Deprecated.
      will not work in Java 11 or later. Use defineClass(Class, String, byte[]) instead
      Defines a class is a specified classloader.
      Parameters:
      className - the name of the class
      classBytes - the byte code for the class
      classLoader - the classloader in which it is to be defined
      protectionDomain - the domain in which the class should be defined
    • defineClass

      public Class<?> defineClass(Class<?> anchorClass, String className, byte[] classBytes)
      Defines a new class from bytecode. The class will be defined in the classloader and package associated with a specified 'anchor class'.
      Parameters:
      anchorClass - the class from which the package and classloader of the new class are to be taken.
      className - the name of the class to define
      classBytes - the bytes used to define the class
      Returns:
      a new instantiable class, in the package and classloader of the anchor class.
    • ensureClassInitialized

      public final void ensureClassInitialized(Class<?> cl)
      Ensure that the class has been initialized.
      Parameters:
      cl - the class to ensure is initialized
    • getLatestUserDefinedLoader

      public abstract ClassLoader getLatestUserDefinedLoader()
      Obtain the latest user defined ClassLoader from the call stack. This is required by the RMI-IIOP specification.
    • newConstructorForExternalization

      public abstract <T> Constructor<?> newConstructorForExternalization(Class<T> cl)
      Return a constructor that can be used to create an instance of the class for externalization.
      Parameters:
      cl - the class
    • newConstructorForSerialization

      public abstract <T> Constructor<T> newConstructorForSerialization(Class<T> aClass, Constructor<?> cons)
      Return a no-arg constructor for the specified class which invokes the specified constructor.
      Parameters:
      aClass - the class for which a constructor should be returned.
      cons - the default constructor on which to model the new constructor.
    • newConstructorForSerialization

      public abstract <T> Constructor<T> newConstructorForSerialization(Class<T> aClass)
      Return a no-arg constructor for the specified class, based on the default constructor for its nearest non-serializable base class.
      Parameters:
      aClass - the class for which a constructor should be returned.
    • hasStaticInitializerForSerialization

      public abstract boolean hasStaticInitializerForSerialization(Class<?> cl)
      Returns true if the given class defines a static initializer method, false otherwise.
    • writeObjectForSerialization

      public abstract MethodHandle writeObjectForSerialization(Class<?> cl) throws NoSuchMethodException, IllegalAccessException
      Returns a method handle to allow invocation of the specified class's writeObject method.
      Parameters:
      cl - the class containing the method
      Throws:
      NoSuchMethodException
      IllegalAccessException
    • readObjectForSerialization

      public abstract MethodHandle readObjectForSerialization(Class<?> cl) throws NoSuchMethodException, IllegalAccessException
      Returns a method handle to allow invocation of the specified class's readObject method.
      Parameters:
      cl - the class containing the method
      Throws:
      NoSuchMethodException
      IllegalAccessException
    • readResolveForSerialization

      public abstract MethodHandle readResolveForSerialization(Class<?> cl)
      Returns a method handle to allow invocation of the specified class's readResolve method.
      Parameters:
      cl - the class containing the method
    • writeReplaceForSerialization

      public abstract MethodHandle writeReplaceForSerialization(Class<?> cl)
      Returns a method handle to allow invocation of the specified class's writeReplace method.
      Parameters:
      cl - the class containing the method
    • newOptionalDataExceptionForSerialization

      public abstract OptionalDataException newOptionalDataExceptionForSerialization(boolean bool)
      Return a new OptionalDataException instance.
      Returns:
      a new OptionalDataException instance
    • toAccessibleField

      public Field toAccessibleField(Field field, Class callingClass)
      Returns the specified field after calling setAccessible, if it is accessible from the specified class.
      Parameters:
      field - the field to make accessible
      callingClass - the class which wants to access it.
      Returns:
      the original field, rendered accessible, or null.
    • toAccessibleMethod

      public Method toAccessibleMethod(Method method, Class callingClass)
      Returns the specified method after calling setAccessible, if it is accessible from the specified class.
      Parameters:
      method - the method to make accessible
      callingClass - the class which wants to access it.
      Returns:
      the original method, rendered accessible, or null.