Package java.lang.reflect
Classes in this package, along with java.lang.Class
accommodate applications such as debuggers, interpreters, object inspectors, class browsers, and services such as Object Serialization and JavaBeans that need access to either the public members of a target object (based on its runtime class) or the members declared by a given class.
AccessibleObject
allows suppression of access checks if the necessary ReflectPermission
is available.
Array
provides static methods to dynamically create and access arrays.
Java programming language and JVM modeling in core reflection
The components of core reflection, which include types in this package as well as Class
, Package
, and Module
, fundamentally present a JVM model of the entities in question rather than a Java programming language model. A Java compiler, such as javac
, translates Java source code into executable output that can be run on a JVM, primarily class
files. Compilers for source languages other than Java can and do target the JVM as well.
The translation process, including from Java language sources, to executable output for the JVM is not a one-to-one mapping. Structures present in the source language may have no representation in the output and structures not
present in the source language may be present in the output. The latter are called synthetic structures. Synthetic structures can include methods, fields, parameters, classes and interfaces. One particular kind of synthetic method is a bridge method. It is possible a synthetic structure may not be marked as such. In particular, not all class
file versions support marking a parameter as synthetic. A source language compiler generally has multiple ways to translate a source program into a class
file representation. The translation may also depend on the version of the class
file format being targeted as different class
file versions have different capabilities and features. In some cases the modifiers present in the class
file representation may differ from the modifiers on the originating element in the source language, including final
on a parameter and protected
, private
, and static
on classes and interfaces.
Besides differences in structural representation between the source language and the JVM representation, core reflection also exposes runtime specific information. For example, the class loaders and protection domains of a Class
are runtime concepts without a direct analogue in source code.
- See Java Language Specification:
- Moved out of a link with destination https://docs.oracle.com/javase/specs/jls/se21/html/jls-13.html#jls-13.1.Moved to a link with destination https://docs.oracle.com/javase/specs/jls/se22/html/jls-13.html#jls-13.1. Moved out of a link with destination https://docs.oracle.com/javase/specs/jls/se21/html/jls-13.html#jls-13.1.Moved to a link with destination https://docs.oracle.com/javase/specs/jls/se22/html/jls-13.html#jls-13.1.13.1 The Form of a Binary
- See Java Virtual Machine Specification:
- Moved out of a link with destination https://docs.oracle.com/javase/specs/jvms/se21/html/jvms-1.html#jvms-1.2.Moved to a link with destination https://docs.oracle.com/javase/specs/jvms/se22/html/jvms-1.html#jvms-1.2. Moved out of a link with destination https://docs.oracle.com/javase/specs/jvms/se21/html/jvms-1.html#jvms-1.2.Moved to a link with destination https://docs.oracle.com/javase/specs/jvms/se22/html/jvms-1.html#jvms-1.2.1.2 The Java Virtual Machine
Moved out of a link with destination https://docs.oracle.com/javase/specs/jvms/se21/html/jvms-4.html#jvms-4.7.8.Moved to a link with destination https://docs.oracle.com/javase/specs/jvms/se22/html/jvms-4.html#jvms-4.7.8.4.7.8 The Synthetic Attribute
Moved out of a link with destination https://docs.oracle.com/javase/specs/jvms/se21/html/jvms-5.html#jvms-5.3.1.Moved to a link with destination https://docs.oracle.com/javase/specs/jvms/se22/html/jvms-5.html#jvms-5.3.1.5.3.1 Loading Using the Bootstrap Class Loader
Moved out of a link with destination https://docs.oracle.com/javase/specs/jvms/se21/html/jvms-5.html#jvms-5.3.2.Moved to a link with destination https://docs.oracle.com/javase/specs/jvms/se22/html/jvms-5.html#jvms-5.3.2.5.3.2 Loading Using a User-defined Class Loader
- Since:
- 1.1
Types
- ✗ AccessFlag
- ✗ AccessibleObject
- ✗ AnnotatedArrayType
- ✗ AnnotatedElement
- ✗ AnnotatedParameterizedType
- ✗ AnnotatedType
- ✗ AnnotatedTypeVariable
- ✗ AnnotatedWildcardType
- ✗ Array
- ✗ ClassFileFormatVersion
- ✗ Constructor
- ✗ Executable
- ✗ Field
- ✗ GenericArrayType
- ✓ GenericDeclaration
- ✓ GenericSignatureFormatError
- ✓ InaccessibleObjectException
- ✓ InvocationHandler
- ✓ InvocationTargetException
- ✓ MalformedParameterizedTypeException
- ✓ MalformedParametersException
- ✗ Member
- ✗ Method
- ✗ Modifier
- ✗ Parameter
- ✗ ParameterizedType
- ✓ Proxy
- ✗ RecordComponent
- ✓ ReflectPermission
- ✗ Type
- ✗ TypeVariable
- ✓ UndeclaredThrowableException
- ✗ WildcardType
Summary
Elements | Comments | Descriptions | Total | |||||||
---|---|---|---|---|---|---|---|---|---|---|
Added | Changed | Removed | Added | Changed | Removed | Added | Changed | Removed | ||
java.lang.reflect | 5 | 5 | ||||||||
AccessFlag | 24 | 24 | ||||||||
AccessibleObject | 4 | 4 | ||||||||
AnnotatedArrayType | 1 | 1 | ||||||||
AnnotatedElement | 5 | 5 | ||||||||
AnnotatedParameterizedType | 1 | 1 | ||||||||
AnnotatedType | 9 | 9 | ||||||||
AnnotatedTypeVariable | 1 | 1 | ||||||||
AnnotatedWildcardType | 1 | 1 | ||||||||
Array | 2 | 4 | 6 | |||||||
ClassFileFormatVersion | 1 | 1 | 2 | 4 | ||||||
Constructor | 9 | 2 | 11 | |||||||
Executable | 1 | 9 | 10 | |||||||
Field | 7 | 2 | 9 | |||||||
GenericArrayType | 1 | 1 | ||||||||
Member | 1 | 1 | ||||||||
Method | 16 | 2 | 18 | |||||||
Modifier | 11 | 11 | ||||||||
Parameter | 5 | 5 | ||||||||
ParameterizedType | 1 | 1 | ||||||||
RecordComponent | 2 | 2 | ||||||||
Type | 8 | 8 | ||||||||
TypeVariable | 3 | 3 | ||||||||
WildcardType | 1 | 1 | ||||||||
Total | 1 | 4 | 127 | 10 | 142 |