java.lang.Object
org.glassfish.pfl.basic.reflection.BridgeBase
- Direct Known Subclasses:
Bridge
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longThis constant differs from all results that will ever be returned fromobjectFieldOffset(java.lang.reflect.Field). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionClass<?>defineClass(Class<?> anchorClass, String className, byte[] classBytes) Defines a new class from bytecode.voidensureClassInitialized(Class<?> cl) Ensure that the class has been initialized.final booleangetBoolean(Object o, long offset) final bytefinal charfinal doublefinal floatfinal intFetches a field element within the given objectoat the given offset.Obtain the latest user defined ClassLoader from the call stack.final longfinal <T> Tfinal shortabstract booleanReturns true if the given class defines a static initializer method, false otherwise.abstract <T> Constructor<T>Return a constructor that can be used to create an instance of the class for externalization.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.abstract <T> Constructor<T>newConstructorForSerialization(Class<T> aClass, Constructor<?> cons) Return a no-arg constructor for the specified class which invokes the specified constructor.abstract OptionalDataExceptionnewOptionalDataExceptionForSerialization(boolean bool) Return a new OptionalDataException instance.final longReturns the offset of a non-static field, which can be passed into the set... or get... methods.final voidputBoolean(Object o, long offset, boolean x) final voidfinal voidfinal voidfinal voidfinal voidStores a value into a given Java field.final voidfinal voidfinal voidabstract MethodHandlereadObjectForSerialization(Class<?> cl) Returns a method handle to allow invocation of the specified class's readObject method.abstract MethodHandlereadResolveForSerialization(Class<?> cl) Returns a method handle to allow invocation of the specified class's readResolve method.final longfinal voidThrow the exception.toAccessibleField(Field field, Class<?> callingClass) Returns the specified field after calling setAccessible, if it is accessible from the specified class.toAccessibleMethod(Method method, Class<?> callingClass) Returns the specified method after calling setAccessible, if it is accessible from the specified class.abstract MethodHandlewriteObjectForSerialization(Class<?> cl) Returns a method handle to allow invocation of the specified class's writeObject method.abstract MethodHandleReturns a method handle to allow invocation of the specified class's writeReplace method.
-
Field Details
-
INVALID_FIELD_OFFSET
public static final long INVALID_FIELD_OFFSETThis constant differs from all results that will ever be returned fromobjectFieldOffset(java.lang.reflect.Field).- See Also:
-
-
Constructor Details
-
BridgeBase
public BridgeBase()
-
-
Method Details
-
getInt
Fetches a field element within the given objectoat the given offset. The result is undefined unless the offset was obtained fromobjectFieldOffset(java.lang.reflect.Field)on theFieldof some Java field and the object referred to byois of a class compatible with that field's class.- Parameters:
o- Java heap object in which the field from which the offset was obtained residesoffset- 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 evenNullPointerException
-
putInt
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 nulloffset- 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 evenNullPointerException
-
getObject
- See Also:
-
putObject
- See Also:
-
getBoolean
- See Also:
-
putBoolean
- See Also:
-
getByte
- See Also:
-
putByte
- See Also:
-
getShort
- See Also:
-
putShort
- See Also:
-
getChar
- See Also:
-
putChar
- See Also:
-
getLong
- See Also:
-
putLong
- See Also:
-
getFloat
- See Also:
-
putFloat
- See Also:
-
getDouble
- See Also:
-
putDouble
- See Also:
-
objectFieldOffset
Returns the offset of a non-static field, which can be passed into the set... or get... methods.- See Also:
-
staticFieldOffset
-
throwException
Throw the exception. The exception may be an undeclared checked exception. -
defineClass
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 defineclassBytes- the bytes used to define the class- Returns:
- a new instantiable class, in the package and classloader of the anchor class.
-
ensureClassInitialized
Ensure that the class has been initialized.- Parameters:
cl- the class to ensure is initialized
-
getLatestUserDefinedLoader
Obtain the latest user defined ClassLoader from the call stack. This is required by the RMI-IIOP specification. -
newConstructorForExternalization
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
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
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:
NoSuchMethodExceptionIllegalAccessException
-
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:
NoSuchMethodExceptionIllegalAccessException
-
readResolveForSerialization
Returns a method handle to allow invocation of the specified class's readResolve method.- Parameters:
cl- the class containing the method
-
writeReplaceForSerialization
Returns a method handle to allow invocation of the specified class's writeReplace method.- Parameters:
cl- the class containing the method
-
newOptionalDataExceptionForSerialization
Return a new OptionalDataException instance.- Returns:
- a new OptionalDataException instance
-
toAccessibleField
Returns the specified field after calling setAccessible, if it is accessible from the specified class.- Parameters:
field- the field to make accessiblecallingClass- the class which wants to access it.- Returns:
- the original field, rendered accessible, or null.
-
toAccessibleMethod
Returns the specified method after calling setAccessible, if it is accessible from the specified class.- Parameters:
method- the method to make accessiblecallingClass- the class which wants to access it.- Returns:
- the original method, rendered accessible, or null.
-