ReflectionUtil (Apache Tomcat 11.0.23 API Documentation)
Description: declaration: package: org.apache.el.util, class: ReflectionUtil

# Class ReflectionUtil

java.lang.Object
org.apache.el.util.ReflectionUtil

public class ReflectionUtil extends Object
Utilities for Managing Serialization and Reflection.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected static final String[]`
  `PRIMITIVE_NAMES`
  Names of Java primitive types.
  `protected static final Class<?>[]`
  `PRIMITIVES`
  Class objects for Java primitive types, in the same order as `PRIMITIVE_NAMES`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static Class<?>`
  `forName(String name)`
  Loads a class by name, supporting primitive types and array notation.
  `protected static Class<?>`
  `forNamePrimitive(String name)`
  Looks up a primitive class by name.
  `static Method`
  `getMethod(EvaluationContext ctx, Object base, Object property, Class<?>[] paramTypes, Object[] paramValues)`
  Returns a method based on the criteria.
  `static Class<?>[]`
  `toTypeArray(String[] s)`
  Converts an array of Class names to Class types.
  `static String[]`
  `toTypeNameArray(Class<?>[] c)`
  Converts an array of Class types to Class names.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### PRIMITIVE_NAMES

    protected static final String[] PRIMITIVE_NAMES
    Names of Java primitive types.

  - ### PRIMITIVES

    protected static final Class<?>[] PRIMITIVES
    Class objects for Java primitive types, in the same order as `PRIMITIVE_NAMES`.

- ## Method Details

  - ### forName

    public static Class<?> forName(String name) throws ClassNotFoundException
    Loads a class by name, supporting primitive types and array notation.
    Parameters:
      `name` - the class name to load
    Returns:
      the Class object, or `null` if the name is empty
    Throws:
      `ClassNotFoundException` - if the class cannot be found

  - ### forNamePrimitive

    protected static Class<?> forNamePrimitive(String name)
    Looks up a primitive class by name.
    Parameters:
      `name` - the primitive type name
    Returns:
      the corresponding Class object, or `null` if not a primitive

  - ### toTypeArray

    public static Class<?>[] toTypeArray(String[] s) throws ClassNotFoundException
    Converts an array of Class names to Class types.
    Parameters:
      `s` - The array of class names
    Returns:
      An array of Class instance where the element at index i in the result is an instance of the class with the name at index i in the input
    Throws:
      `ClassNotFoundException` - If a class of a given name cannot be found

  - ### toTypeNameArray

    public static String[] toTypeNameArray(Class<?>[] c)
    Converts an array of Class types to Class names.
    Parameters:
      `c` - The array of class instances
    Returns:
      An array of Class names where the element at index i in the result is the name of the class instance at index i in the input

  - ### getMethod

    public static Method getMethod(EvaluationContext ctx, Object base, Object property, Class<?>[] paramTypes, Object[] paramValues) throws MethodNotFoundException
    Returns a method based on the criteria.
    Parameters:
      `ctx` - the context in which the expression is being evaluated
      `base` - the object that owns the method
      `property` - the name of the method
      `paramTypes` - the parameter types to use
      `paramValues` - the parameter values
    Returns:
      the method specified
    Throws:
      `MethodNotFoundException` - If a method cannot be found that matches the given criteria