Top Fields Constructors Methods
org.glassfish.pfl.basic.reflection

public abstract Class BridgeBase

extends Object
Class Inheritance
Known Direct Subclasses
org.glassfish.pfl.basic.reflection.Bridge
Imports
java.io.OptionalDataException, java.lang.invoke.MethodHandle, .MethodHandles, java.lang.reflect.Constructor, .Field, .Method, java.security.AccessController, .PrivilegedAction, java.util.Optional, java.util.stream.Stream, sun.misc.Unsafe

Field Summary

Modifier and TypeField and Description
public static final long
INVALID_FIELD_OFFSET

This constant differs from all results that will ever be returned from objectFieldOffset.

private final StackWalker
private final Unsafe

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Class<?>

Returns:

a new instantiable class, in the package and classloader of the anchor class.
defineClass
(Class<?>
the class from which the package and classloader of the new class are to be taken.
anchorClass
,
String
the name of the class to define
className
,
byte[]
the bytes used to define the class
classBytes
)

Defines a new class from bytecode.

public void
ensureClassInitialized(Class<?>
the class to ensure is initialized
cl
)

Ensure that the class has been initialized.

public final boolean
getBoolean(Object o, long offset)

public final byte
getByte(Object o, long offset)

public final char
getChar(Object o, long offset)

public final double
getDouble(Object o, long offset)

public final float
getFloat(Object o, long offset)

public final int

Returns:

the value fetched from the indicated Java field
getInt
(Object
Java heap object in which the field from which the offset was obtained resides
o
,
long
indication of where the field resides in a Java heap object
offset
)

Fetches a field element within the given object o at the given offset.

public ClassLoader
getLatestUserDefinedLoader()

Obtain the latest user defined ClassLoader from the call stack.

private Optional<StackWalker.StackFrame>
public final long
getLong(Object o, long offset)

public final <T> T
getObject(Object o, long offset)

public final short
getShort(Object o, long offset)

public abstract boolean
hasStaticInitializerForSerialization(Class<?> cl)

Returns true if the given class defines a static initializer method, false otherwise.

private boolean
isClassOpenToModule(Class<?> candidateClass, Module callingModule)

private boolean
public abstract <T> Constructor<T>
newConstructorForExternalization(Class<T>
the class
cl
)

Return a constructor that can be used to create an instance of the class for externalization.

public abstract <T> Constructor<T>
newConstructorForSerialization(Class<T>
the class for which a constructor should be returned.
aClass
,
Constructor<?>
the default constructor on which to model the new constructor.
cons
)

Return a no-arg constructor for the specified class which invokes the specified constructor.

public abstract <T> Constructor<T>
newConstructorForSerialization(Class<T>
the class for which a constructor should be returned.
aClass
)

Return a no-arg constructor for the specified class, based on the default constructor for its nearest non-serializable base class.

public abstract OptionalDataException

Returns:

a new OptionalDataException instance
newOptionalDataExceptionForSerialization
(boolean bool)

Return a new OptionalDataException instance.

public final long
objectFieldOffset(Field f)

Returns the offset of a non-static field, which can be passed into the set...

public final void
putBoolean(Object o, long offset, boolean x)

public final void
putByte(Object o, long offset, byte x)

public final void
putChar(Object o, long offset, char x)

public final void
putDouble(Object o, long offset, double x)

public final void
putFloat(Object o, long offset, float x)

public final void
putInt(Object
Java heap object in which the field resides, if any, else null
o
,
long
indication of where the field resides in a Java heap object.
offset
,
int
the value to store into the indicated Java field
x
)

Stores a value into a given Java field.

public final void
putLong(Object o, long offset, long x)

public final void
putObject(Object o, long offset, Object x)

public final void
putShort(Object o, long offset, short x)

public abstract MethodHandle
readObjectForSerialization(Class<?>
the class containing the method
cl
)

Returns a method handle to allow invocation of the specified class's readObject method.

public abstract MethodHandle
readResolveForSerialization(Class<?>
the class containing the method
cl
)

Returns a method handle to allow invocation of the specified class's readResolve method.

public final long
public final void
throwException(Throwable ee)

Throw the exception.

public Field

Returns:

the original field, rendered accessible, or null.
toAccessibleField
(Field
the field to make accessible
field
,
Class<?>
the class which wants to access it.
callingClass
)

Returns the specified field after calling setAccessible, if it is accessible from the specified class.

public Method

Returns:

the original method, rendered accessible, or null.
toAccessibleMethod
(Method
the method to make accessible
method
,
Class<?>
the class which wants to access it.
callingClass
)

Returns the specified method after calling setAccessible, if it is accessible from the specified class.

public abstract MethodHandle
writeObjectForSerialization(Class<?>
the class containing the method
cl
)

Returns a method handle to allow invocation of the specified class's writeObject method.

public abstract MethodHandle
writeReplaceForSerialization(Class<?>
the class containing the method
cl
)

Returns a method handle to allow invocation of the specified class's writeReplace method.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INVALID_FIELD_OFFSETback to summary
public static final long INVALID_FIELD_OFFSET

This constant differs from all results that will ever be returned from objectFieldOffset.

stackWalkerback to summary
private final StackWalker stackWalker
unsafeback to summary
private final Unsafe unsafe

Constructor Detail

BridgeBaseback to summary
public BridgeBase()

Method Detail

defineClassback to summary
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:Class<?>

the class from which the package and classloader of the new class are to be taken.

className:String

the name of the class to define

classBytes:byte[]

the bytes used to define the class

Returns:Class<?>

a new instantiable class, in the package and classloader of the anchor class.

ensureClassInitializedback to summary
public void ensureClassInitialized(Class<?> cl)

Ensure that the class has been initialized.

Parameters
cl:Class<?>

the class to ensure is initialized

getBooleanback to summary
public final boolean getBoolean(Object o, long offset)
See Also
getInt(Object, long)
getByteback to summary
public final byte getByte(Object o, long offset)
See Also
getInt(Object, long)
getCharback to summary
public final char getChar(Object o, long offset)
See Also
getInt(Object, long)
getDoubleback to summary
public final double getDouble(Object o, long offset)
See Also
getInt(Object, long)
getFloatback to summary
public final float getFloat(Object o, long offset)
See Also
getInt(Object, long)
getIntback to summary
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 on the java.lang.reflect.Field of some Java field and the object referred to by o is of a class compatible with that field's class.

Parameters
o:Object

Java heap object in which the field from which the offset was obtained resides

offset:long

indication of where the field resides in a Java heap object

Returns:int

the value fetched from the indicated Java field

Exceptions
RuntimeException:
No defined exceptions are thrown, not even NullPointerException
getLatestUserDefinedLoaderback to summary
public ClassLoader getLatestUserDefinedLoader()

Obtain the latest user defined ClassLoader from the call stack. This is required by the RMI-IIOP specification.

getLatestUserDefinedLoaderFrameback to summary
private Optional<StackWalker.StackFrame> getLatestUserDefinedLoaderFrame(Stream<StackWalker.StackFrame> stream)
getLongback to summary
public final long getLong(Object o, long offset)
See Also
getInt(Object, long)
getObjectback to summary
public final <T> T getObject(Object o, long offset)
Annotations
@SuppressWarnings:unchecked
See Also
getInt(Object, long)
getShortback to summary
public final short getShort(Object o, long offset)
See Also
getInt(Object, long)
hasStaticInitializerForSerializationback to summary
public abstract boolean hasStaticInitializerForSerialization(Class<?> cl)

Returns true if the given class defines a static initializer method, false otherwise.

isClassOpenToModuleback to summary
private boolean isClassOpenToModule(Class<?> candidateClass, Module callingModule)
isUserLoaderback to summary
private boolean isUserLoader(StackWalker.StackFrame sf)
newConstructorForExternalizationback to summary
public abstract <T> Constructor<T> newConstructorForExternalization(Class<T> cl)

Return a constructor that can be used to create an instance of the class for externalization.

Parameters
cl:Class<T>

the class

newConstructorForSerializationback to summary
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:Class<T>

the class for which a constructor should be returned.

cons:Constructor<?>

the default constructor on which to model the new constructor.

newConstructorForSerializationback to summary
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:Class<T>

the class for which a constructor should be returned.

newOptionalDataExceptionForSerializationback to summary
public abstract OptionalDataException newOptionalDataExceptionForSerialization(boolean bool)

Return a new OptionalDataException instance.

Returns:OptionalDataException

a new OptionalDataException instance

objectFieldOffsetback to summary
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
getInt(Object, long)
putBooleanback to summary
public final void putBoolean(Object o, long offset, boolean x)
See Also
putInt(Object, long, int)
putByteback to summary
public final void putByte(Object o, long offset, byte x)
See Also
putInt(Object, long, int)
putCharback to summary
public final void putChar(Object o, long offset, char x)
See Also
putInt(Object, long, int)
putDoubleback to summary
public final void putDouble(Object o, long offset, double x)
See Also
putInt(Object, long, int)
putFloatback to summary
public final void putFloat(Object o, long offset, float x)
See Also
putInt(Object, long, int)
putIntback to summary
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:Object

Java heap object in which the field resides, if any, else null

offset:long

indication of where the field resides in a Java heap object.

x:int

the value to store into the indicated Java field

Exceptions
RuntimeException:
No defined exceptions are thrown, not even NullPointerException
putLongback to summary
public final void putLong(Object o, long offset, long x)
See Also
putInt(Object, long, int)
putObjectback to summary
public final void putObject(Object o, long offset, Object x)
See Also
putInt(Object, long, int)
putShortback to summary
public final void putShort(Object o, long offset, short x)
See Also
putInt(Object, long, int)
readObjectForSerializationback to summary
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:Class<?>

the class containing the method

readResolveForSerializationback to summary
public abstract MethodHandle readResolveForSerialization(Class<?> cl)

Returns a method handle to allow invocation of the specified class's readResolve method.

Parameters
cl:Class<?>

the class containing the method

staticFieldOffsetback to summary
public final long staticFieldOffset(Field f)
throwExceptionback to summary
public final void throwException(Throwable ee)

Throw the exception. The exception may be an undeclared checked exception.

toAccessibleFieldback to summary
public Field toAccessibleField(Field field, Class<?> callingClass)

Returns the specified field after calling setAccessible, if it is accessible from the specified class.

Parameters
field:Field

the field to make accessible

callingClass:Class<?>

the class which wants to access it.

Returns:Field

the original field, rendered accessible, or null.

toAccessibleMethodback to summary
public Method toAccessibleMethod(Method method, Class<?> callingClass)

Returns the specified method after calling setAccessible, if it is accessible from the specified class.

Parameters
method:Method

the method to make accessible

callingClass:Class<?>

the class which wants to access it.

Returns:Method

the original method, rendered accessible, or null.

writeObjectForSerializationback to summary
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:Class<?>

the class containing the method

writeReplaceForSerializationback to summary
public abstract MethodHandle writeReplaceForSerialization(Class<?> cl)

Returns a method handle to allow invocation of the specified class's writeReplace method.

Parameters
cl:Class<?>

the class containing the method