reflection
7 tutorials tagged “reflection”.
- Calling a Private Method Using ReflectionHow setAccessible(true) lets reflection call private methods and change private fields, what still stays protected, and how modules limit deep reflection.
- Creating Objects and Calling Methods with ReflectionCreate objects with Constructor.newInstance, call methods with Method.invoke, handle InvocationTargetException, and build a mini test runner with @Test.
- Custom Annotations in JavaDeclare your own annotations with @interface: elements, defaults, allowed types and the value shortcut, then read them with reflection in a field validator.
- Dynamic Proxies in JavaA dynamic proxy is an object created at run time that implements interfaces and sends every call to one InvocationHandler. Learn how Spring-style wrappers work.
- Inspecting Classes, Fields, Methods and ConstructorsUse reflection to list a class's members: getFields vs getDeclaredFields, Field, Method, Constructor and Parameter objects, modifiers and record components.
- Method Handles in JavaA method handle is a typed, directly callable reference to a method. Learn Lookup, MethodType, invoke vs invokeExact, bindTo, and how it compares to reflection.
- Reflection API in JavaReflection lets a program examine and use classes at run time. Learn the Class object, three ways to get it, what it can tell you, and what reflection costs.