Class BridgeBase

  • Direct Known Subclasses:
    Bridge

    public abstract class BridgeBase
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      BridgeBase()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      java.lang.Class<?> defineClass​(java.lang.Class<?> anchorClass, java.lang.String className, byte[] classBytes)
      Defines a new class from bytecode.
      java.lang.Class<?> defineClass​(java.lang.String className, byte[] classBytes, java.lang.ClassLoader classLoader, java.security.ProtectionDomain protectionDomain)
      Deprecated.
      will not work in Java 11 or later.
      void ensureClassInitialized​(java.lang.Class<?> cl)
      Ensure that the class has been initialized.
      boolean getBoolean​(java.lang.Object o, long offset)  
      byte getByte​(java.lang.Object o, long offset)  
      char getChar​(java.lang.Object o, long offset)  
      double getDouble​(java.lang.Object o, long offset)  
      float getFloat​(java.lang.Object o, long offset)  
      int getInt​(java.lang.Object o, long offset)
      Fetches a field element within the given object o at the given offset.
      abstract java.lang.ClassLoader getLatestUserDefinedLoader()
      Obtain the latest user defined ClassLoader from the call stack.
      long getLong​(java.lang.Object o, long offset)  
      <T> T getObject​(java.lang.Object o, long offset)  
      short getShort​(java.lang.Object o, long offset)  
      abstract boolean hasStaticInitializerForSerialization​(java.lang.Class<?> cl)
      Returns true if the given class defines a static initializer method, false otherwise.
      abstract <T> java.lang.reflect.Constructor<?> newConstructorForExternalization​(java.lang.Class<T> cl)
      Return a constructor that can be used to create an instance of the class for externalization.
      abstract <T> java.lang.reflect.Constructor<T> newConstructorForSerialization​(java.lang.Class<T> aClass)
      Return a no-arg constructor for the specified class, based on the default constructor for its nearest non-serializable base class.
      abstract <T> java.lang.reflect.Constructor<T> newConstructorForSerialization​(java.lang.Class<T> aClass, java.lang.reflect.Constructor<?> cons)
      Return a no-arg constructor for the specified class which invokes the specified constructor.
      abstract java.io.OptionalDataException newOptionalDataExceptionForSerialization​(boolean bool)
      Return a new OptionalDataException instance.
      long objectFieldOffset​(java.lang.reflect.Field f)
      Returns the offset of a non-static field, which can be passed into the set...
      void putBoolean​(java.lang.Object o, long offset, boolean x)  
      void putByte​(java.lang.Object o, long offset, byte x)  
      void putChar​(java.lang.Object o, long offset, char x)  
      void putDouble​(java.lang.Object o, long offset, double x)  
      void putFloat​(java.lang.Object o, long offset, float x)  
      void putInt​(java.lang.Object o, long offset, int x)
      Stores a value into a given Java field.
      void putLong​(java.lang.Object o, long offset, long x)  
      void putObject​(java.lang.Object o, long offset, java.lang.Object x)  
      void putShort​(java.lang.Object o, long offset, short x)  
      abstract java.lang.invoke.MethodHandle readObjectForSerialization​(java.lang.Class<?> cl)
      Returns a method handle to allow invocation of the specified class's readObject method.
      abstract java.lang.invoke.MethodHandle readResolveForSerialization​(java.lang.Class<?> cl)
      Returns a method handle to allow invocation of the specified class's readResolve method.
      long staticFieldOffset​(java.lang.reflect.Field f)  
      void throwException​(java.lang.Throwable ee)
      Throw the exception.
      java.lang.reflect.Field toAccessibleField​(java.lang.reflect.Field field, java.lang.Class callingClass)
      Returns the specified field after calling setAccessible, if it is accessible from the specified class.
      java.lang.reflect.Method toAccessibleMethod​(java.lang.reflect.Method method, java.lang.Class callingClass)
      Returns the specified method after calling setAccessible, if it is accessible from the specified class.
      abstract java.lang.invoke.MethodHandle writeObjectForSerialization​(java.lang.Class<?> cl)
      Returns a method handle to allow invocation of the specified class's writeObject method.
      abstract java.lang.invoke.MethodHandle writeReplaceForSerialization​(java.lang.Class<?> cl)
      Returns a method handle to allow invocation of the specified class's writeReplace method.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BridgeBase

        public BridgeBase()
    • Method Detail

      • getInt

        public final int getInt​(java.lang.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:
        java.lang.RuntimeException - No defined exceptions are thrown, not even NullPointerException
      • putInt

        public final void putInt​(java.lang.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:
        java.lang.RuntimeException - No defined exceptions are thrown, not even NullPointerException
      • getObject

        public final <T> T getObject​(java.lang.Object o,
                                     long offset)
        See Also:
        getInt(Object, long)
      • putObject

        public final void putObject​(java.lang.Object o,
                                    long offset,
                                    java.lang.Object x)
        See Also:
        putInt(Object, long, int)
      • getBoolean

        public final boolean getBoolean​(java.lang.Object o,
                                        long offset)
        See Also:
        getInt(Object, long)
      • putBoolean

        public final void putBoolean​(java.lang.Object o,
                                     long offset,
                                     boolean x)
        See Also:
        putInt(Object, long, int)
      • getByte

        public final byte getByte​(java.lang.Object o,
                                  long offset)
        See Also:
        getInt(Object, long)
      • getShort

        public final short getShort​(java.lang.Object o,
                                    long offset)
        See Also:
        getInt(Object, long)
      • getChar

        public final char getChar​(java.lang.Object o,
                                  long offset)
        See Also:
        getInt(Object, long)
      • getLong

        public final long getLong​(java.lang.Object o,
                                  long offset)
        See Also:
        getInt(Object, long)
      • getFloat

        public final float getFloat​(java.lang.Object o,
                                    long offset)
        See Also:
        getInt(Object, long)
      • getDouble

        public final double getDouble​(java.lang.Object o,
                                      long offset)
        See Also:
        getInt(Object, long)
      • putDouble

        public final void putDouble​(java.lang.Object o,
                                    long offset,
                                    double x)
        See Also:
        putInt(Object, long, int)
      • objectFieldOffset

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

        public final long staticFieldOffset​(java.lang.reflect.Field f)
      • throwException

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

        @Deprecated
        public java.lang.Class<?> defineClass​(java.lang.String className,
                                              byte[] classBytes,
                                              java.lang.ClassLoader classLoader,
                                              java.security.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 java.lang.Class<?> defineClass​(java.lang.Class<?> anchorClass,
                                              java.lang.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​(java.lang.Class<?> cl)
        Ensure that the class has been initialized.
        Parameters:
        cl - the class to ensure is initialized
      • getLatestUserDefinedLoader

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

        public abstract <T> java.lang.reflect.Constructor<?> newConstructorForExternalization​(java.lang.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> java.lang.reflect.Constructor<T> newConstructorForSerialization​(java.lang.Class<T> aClass,
                                                                                            java.lang.reflect.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> java.lang.reflect.Constructor<T> newConstructorForSerialization​(java.lang.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​(java.lang.Class<?> cl)
        Returns true if the given class defines a static initializer method, false otherwise.
      • writeObjectForSerialization

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

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

        public abstract java.lang.invoke.MethodHandle readResolveForSerialization​(java.lang.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 java.lang.invoke.MethodHandle writeReplaceForSerialization​(java.lang.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 java.io.OptionalDataException newOptionalDataExceptionForSerialization​(boolean bool)
        Return a new OptionalDataException instance.
        Returns:
        a new OptionalDataException instance
      • toAccessibleField

        public java.lang.reflect.Field toAccessibleField​(java.lang.reflect.Field field,
                                                         java.lang.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 java.lang.reflect.Method toAccessibleMethod​(java.lang.reflect.Method method,
                                                           java.lang.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.