The master factory for all reflective objects, both those in java.lang.reflect (Fields, Methods, Constructors) as well as their delegates (FieldAccessors, MethodAccessors, ConstructorAccessors).
The methods in this class are extremely unsafe and can cause
subversion of both the language and the verifier. For this reason,
they are all instance methods, and access to the constructor of
this factory is guarded by a security check, in similar style to
jdk..
| Modifier and Type | Class and Description |
|---|---|
| private static record | ReflectionFactory.
The configurations for the reflection factory. |
| Modifier and Type | Field and Description |
|---|---|
| private static ReflectionFactory. | config
The configuration is lazily initialized after the module system is initialized. |
| private static final ReflectionFactory. | |
| private static volatile Method | |
| private final JavaLangReflectAccess | |
| private static final Set | nonSerializableLeafClasses
These are specific leaf classes which appear to be Serializable, but which have special semantics according to the serialization specification. |
| private static final ReflectionFactory |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| private final ClassFileFormatVersion | |
| private static ReflectionFactory. | |
| public <T> Constructor | |
| public Field | |
| public Method | |
| public final MethodHandle | |
| public final MethodHandle | |
| private static boolean | |
| private final MethodHandle | |
| private final Constructor | |
| public Class | |
| public byte[] | getExecutableTypeAnnotationBytes(Executable ex)
Gets the byte[] that encodes TypeAnnotations on an executable. |
| public static ReflectionFactory | |
| private MethodHandle | Returns: a MethodHandle for the method ornull if not found or
has the wrong signature.a serializable class cl, String the method name to find methodName)Lookup readResolve or writeReplace on a class with specified signature constraints. |
| private static boolean | |
| public final boolean | hasStaticInitializerForSerialization(Class<?> cl)
Returns true if the given class defines a static initializer method, false otherwise. |
| public Method | |
| private static ReflectionFactory. | |
| public ConstructorAccessor | |
| public final Constructor | |
| public final Constructor | |
| public final Constructor | Returns: the generated constructor, or null if none is availablethe class for which a constructor is to be found cl)Returns a constructor that allocates an instance of cl and that then initializes the instance by calling the no-arg constructor of its first non-serializable superclass. |
| public FieldAccessor | |
| public <T> T | |
| public MethodAccessor | |
| public final Constructor | Returns: the eof constructor for OptionalDataExceptionReturn the accessible constructor for OptionalDataException signaling eof. |
| private static boolean | Returns: true if the two classes are in the same classloader and packagea class cl1, Class<?> another class cl2)Returns true if classes are defined in the classloader and same package, false otherwise. |
| public final Set | |
| public final MethodHandle | |
| public final MethodHandle | |
| public final MethodHandle | Returns: thewriteReplace MethodHandle or null if not founda serializable class cl)Returns a MethodHandle for |
| public final ObjectStreamField[] | |
| private boolean | Returns: whether the superclass has a constructor accessible from clthe class from which access is checked cl)Given a class, determines whether its superclass has any constructors that are accessible from the class. |
| pack-priv static boolean | |
| public final MethodHandle | |
| public final MethodHandle | Returns: thewriteReplace MethodHandle or null if not founda serializable class cl)Returns a MethodHandle for |
| config | back to summary |
|---|---|
| private static ReflectionFactory. The configuration is lazily initialized after the module system is initialized. The default config would be used before the proper config is loaded. The static initializer of ReflectionFactory is run before the system properties are set up. The class initialization is caused by the class initialization of java.lang.reflect.Method (more properly, caused by the class initialization for java.lang.reflect.AccessibleObject) that happens very early VM startup, initPhase1. | |
| DEFAULT_CONFIG | back to summary |
|---|---|
| private static final ReflectionFactory. | |
| hasStaticInitializerMethod | back to summary |
|---|---|
| private static volatile Method hasStaticInitializerMethod | |
| langReflectAccess | back to summary |
|---|---|
| private final JavaLangReflectAccess langReflectAccess | |
| nonSerializableLeafClasses | back to summary |
|---|---|
| private static final Set<Class<?>> nonSerializableLeafClasses These are specific leaf classes which appear to be Serializable, but which have special semantics according to the serialization specification. We could theoretically include array classes here, but it is easier and clearer to just use `Class#isArray` instead. | |
| soleInstance | back to summary |
|---|---|
| private static final ReflectionFactory soleInstance | |
| ReflectionFactory | back to summary |
|---|---|
| private ReflectionFactory() | |
| classFileFormatVersion | back to summary |
|---|---|
| private final ClassFileFormatVersion classFileFormatVersion(Class<?> cl) | |
| config | back to summary |
|---|---|
| private static ReflectionFactory. | |
| copyConstructor | back to summary |
|---|---|
| public <T> Constructor Makes a copy of the passed constructor. The returned constructor is a "child" of the passed one; see the comments in Constructor.java for details. | |
| copyField | back to summary |
|---|---|
| public Field copyField(Field arg) Makes a copy of the passed field. The returned field is a "child" of the passed one; see the comments in Field.java for details. | |
| copyMethod | back to summary |
|---|---|
| public Method copyMethod(Method arg) Makes a copy of the passed method. The returned method is a "child" of the passed one; see the comments in Method.java for details. | |
| defaultReadObjectForSerialization | back to summary |
|---|---|
| public final MethodHandle defaultReadObjectForSerialization(Class<?> cl) | |
| defaultWriteObjectForSerialization | back to summary |
|---|---|
| public final MethodHandle defaultWriteObjectForSerialization(Class<?> cl) | |
| disableSerialConstructorChecks | back to summary |
|---|---|
| private static boolean disableSerialConstructorChecks() | |
| findReadWriteObjectForSerialization | back to summary |
|---|---|
| private final MethodHandle findReadWriteObjectForSerialization(Class<?> cl, String methodName, Class<?> streamClass) | |
| generateConstructor | back to summary |
|---|---|
| private final Constructor | |
| getExecutableSharedParameterTypes | back to summary |
|---|---|
| public Class | |
| getExecutableTypeAnnotationBytes | back to summary |
|---|---|
| public byte[] getExecutableTypeAnnotationBytes(Executable ex) Gets the byte[] that encodes TypeAnnotations on an executable. | |
| getReflectionFactory | back to summary |
|---|---|
| public static ReflectionFactory getReflectionFactory() Provides the caller with the capability to instantiate reflective objects. The returned | |
| getReplaceResolveForSerialization | back to summary |
|---|---|
| private MethodHandle getReplaceResolveForSerialization(Class<?> cl, String methodName) Lookup readResolve or writeReplace on a class with specified signature constraints.
| |
| hasDefaultOrNoSerialization | back to summary |
|---|---|
| private static boolean hasDefaultOrNoSerialization(Class<?> cl) | |
| hasStaticInitializerForSerialization | back to summary |
|---|---|
| public final boolean hasStaticInitializerForSerialization(Class<?> cl) Returns true if the given class defines a static initializer method, false otherwise. | |
| leafCopyMethod | back to summary |
|---|---|
| public Method leafCopyMethod(Method arg) Makes a copy of the passed method. The returned method is NOT a "child" but a "sibling" of the Method in arg. Should only be used on non-root methods. | |
| loadConfig | back to summary |
|---|---|
| private static ReflectionFactory. | |
| newConstructorAccessor | back to summary |
|---|---|
| public ConstructorAccessor newConstructorAccessor(Constructor<?> c) | |
| newConstructorForExternalization | back to summary |
|---|---|
| public final Constructor | |
| newConstructorForSerialization | back to summary |
|---|---|
| public final Constructor | |
| newConstructorForSerialization | back to summary |
|---|---|
| public final Constructor Returns a constructor that allocates an instance of cl and that then initializes the instance by calling the no-arg constructor of its first non-serializable superclass. This is specified in the Serialization Specification, section 3.1, in step 11 of the deserialization process. If cl is not serializable, returns cl's no-arg constructor. If no accessible constructor is found, or if the class hierarchy is somehow malformed (e.g., a serializable class has no superclass), null is returned.
| |
| newFieldAccessor | back to summary |
|---|---|
| public FieldAccessor newFieldAccessor(Field field, boolean override) | |
| newInstance | back to summary |
|---|---|
| public <T> T newInstance(Constructor<T> ctor, Object[] args, Class<?> caller) throws IllegalAccessException, InstantiationException, InvocationTargetException | |
| newMethodAccessor | back to summary |
|---|---|
| public MethodAccessor newMethodAccessor(Method method, boolean callerSensitive) | |
| newOptionalDataExceptionForSerialization | back to summary |
|---|---|
| public final Constructor Return the accessible constructor for OptionalDataException signaling eof.
| |
| packageEquals | back to summary |
|---|---|
| private static boolean packageEquals(Class<?> cl1, Class<?> cl2) Returns true if classes are defined in the classloader and same package, false otherwise. | |
| parseAccessFlags | back to summary |
|---|---|
| public final Set | |
| readObjectForSerialization | back to summary |
|---|---|
| public final MethodHandle readObjectForSerialization(Class<?> cl) | |
| readObjectNoDataForSerialization | back to summary |
|---|---|
| public final MethodHandle readObjectNoDataForSerialization(Class<?> cl) | |
| readResolveForSerialization | back to summary |
|---|---|
| public final MethodHandle readResolveForSerialization(Class<?> cl) Returns a MethodHandle for
| |
| serialPersistentFields | back to summary |
|---|---|
| public final ObjectStreamField[] serialPersistentFields(Class<?> cl) | |
| superHasAccessibleConstructor | back to summary |
|---|---|
| private boolean superHasAccessibleConstructor(Class<?> cl) Given a class, determines whether its superclass has any constructors that are accessible from the class. This is a special purpose method intended to do access checking for a serializable class and its superclasses up to, but not including, the first non-serializable superclass. This also implies that the superclass is always non-null, because a serializable class must be a class (not an interface) and Object is not serializable.
| |
| useNativeAccessorOnly | back to summary |
|---|---|
| pack-priv static boolean useNativeAccessorOnly() | |
| writeObjectForSerialization | back to summary |
|---|---|
| public final MethodHandle writeObjectForSerialization(Class<?> cl) | |
| writeReplaceForSerialization | back to summary |
|---|---|
| public final MethodHandle writeReplaceForSerialization(Class<?> cl) Returns a MethodHandle for
| |
| Modifier and Type | Field and Description |
|---|---|
| private final boolean | disableSerialConstructorChecks
Record Component accessed by disableSerialConstructorChecks(). |
| private final boolean | useNativeAccessorOnly
Record Component accessed by useNativeAccessorOnly(). |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public final boolean | equals(Object o)
Implements abstract java. Indicates whether some other object is "equal to" this one. |
| public final int | |
| public final String | toString()
Implements abstract java. Returns a string representation of the record. |
| public boolean |
| disableSerialConstructorChecks | back to summary |
|---|---|
| private final boolean disableSerialConstructorChecks Record Component accessed by disableSerialConstructorChecks(). | |
| useNativeAccessorOnly | back to summary |
|---|---|
| private final boolean useNativeAccessorOnly Record Component accessed by useNativeAccessorOnly(). | |
| Config | back to summary |
|---|---|
| private Config(boolean useNativeAccessorOnly, boolean disableSerialConstructorChecks) | |
| disableSerialConstructorChecks | back to summary |
|---|---|
| public boolean disableSerialConstructorChecks() Record Component getter of disableSerialConstructorChecks. | |
| equals | back to summary |
|---|---|
| public final boolean equals(Object o) Implements abstract java. Doc from java. Indicates whether some other object is "equal to" this one. In addition
to the general contract of
R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
| |
| hashCode | back to summary |
|---|---|
| public final int hashCode() Implements abstract java. Doc from java. Returns a hash code value for the record.
Obeys the general contract of | |
| toString | back to summary |
|---|---|
| public final String toString() Implements abstract java. Doc from java. Returns a string representation of the record.
In accordance with the general contract of In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves. | |
| useNativeAccessorOnly | back to summary |
|---|---|
| public boolean useNativeAccessorOnly() Record Component getter of useNativeAccessorOnly. | |