Class#getMethod(String, Class[])) tries to access an element that was not registered
for reflection in the program. When an element is not registered, the exception will be
thrown both for elements that exist and elements that do not exist on the given classpath.
The purpose of this exception is to easily discover unregistered elements and to assure that all reflective operations for registered elements have the expected behaviour.
We distinguish between two types of reflective queries: bulk queries and individual queries.
Class#getFields() which return a complete list of
corresponding elements. Those queries need to be explicitly registered for reflection in order to
be called. If that is not the case, a MissingReflectionRegistrationError will be
thrown.Class#getField(String) which return a single
element. Those queries will succeed (or throw the expected ReflectiveOperationException
if either the element was individually registered for reflection, or the corresponding bulk query
was registered for reflection. If that is not the case, a
MissingReflectionRegistrationError will be thrown. Some individual queries, like
Class#forName(String), do not have a corresponding bulk query and as such need their
arguments to be individually registered for reflection in order to behave correctly.
Registration: "queryAllDeclaredMethods": true
declaringClass.getDeclaredMethods() will succeed.
declaringClass.getDeclaredMethod("existingMethod") will return the expected method.
declaringClass.getDeclaredMethod("nonexistentMethod") will throw a
NoSuchMethodException.
Registration: "fields": [{"name": "registeredField"}, {"name":
"registeredNonexistentField"}]
declaringClass.getDeclaredFields() will throw a
MissingReflectionRegistrationError.
declaringClass.getField("registeredField") will return the expected field.
declaringClass.getField("registeredNonexistentField") will throw a
NoSuchFieldException.
declaringClass.getField("unregisteredField") will throw a
MissingReflectionRegistrationError.
declaringClass.getField("unregisteredNonexistentField") will throw a
MissingReflectionRegistrationError.
| Modifier and Type | Field and Description |
|---|---|
| private final Class | |
| private final String | |
| private final Class | |
| private final Class | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Class | Returns: The class on which the missing query was tried, or null on static queries (e.g.Class#forName(String)).
|
| public String | |
| public Class | Returns: The type of the element trying to be queried (Class, Method,
Field or Constructor), or null if the query is a bulk query (like
Class#getMethods()).
|
| public Class | Returns: The parameter types passed to the query, or null if the query doesn't take parameter types as argument.
|
| declaringClass | back to summary |
|---|---|
| private final Class<?> declaringClass | |
| elementName | back to summary |
|---|---|
| private final String elementName | |
| elementType | back to summary |
|---|---|
| private final Class<?> elementType | |
| parameterTypes | back to summary |
|---|---|
| private final Class<?>[] parameterTypes | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides java. | |
| MissingReflectionRegistrationError | back to summary |
|---|---|
public MissingReflectionRegistrationError(String message, Class<?> elementType, Class<?> declaringClass, String elementName, Class<?>[] parameterTypes)
| |
| getDeclaringClass | back to summary |
|---|---|
public Class
| |
| getElementName | back to summary |
|---|---|
public String getElementName()
| |
| getElementType | back to summary |
|---|---|
public Class
| |
| getParameterTypes | back to summary |
|---|---|
public Class
| |