Reflection ਇੱਕ ਪ੍ਰੋਗ੍ਰਾਮ ਨੂੰ ਕਲਾਸਿਜ਼, methods, ਅਤੇ fields ਨੂੰ runtime ਤੇ inspect ਅਤੇ manipulate ਕਰਨ ਦੇਤਾ ਹੈ — ਉਹ ਵੀ ਜੋ compile time ਤੇ ਅਣਜਾਣ ਹੋਣ। Annotations code ਵਿੱਚ metadata ਨੂੰ attach ਕਰਦੇ ਹਨ ਜੋ tools ਅਤੇ frameworks ਪੜ੍ਹਦੇ ਹਨ (ਅਕਸਰ reflection ਦੁਆਰਾ) ਵਿਹਾਰ ਨੂੰ drive ਕਰਨ ਲਈ। ਇਕਠੇ ਉਹ Java's framework "magic" ਦਾ ਬਹੁਤ ਕੁਝ ਸ਼ਕਤੀ ਦਿੰਦੇ ਹਨ (Spring, JPA, JUnit)।
Reflection — runtime inspection ਅਤੇ invocation
Class<?> clazz = Class.forName();
(Field field : clazz.getDeclaredFields()) {
System.out.println(field.getName() + + field.getType());
}
(Method method : clazz.getDeclaredMethods()) {
System.out.println(method.getName());
}
clazz.getDeclaredConstructor().newInstance();
clazz.getMethod(, String.class);
m.invoke(instance, );
clazz.getDeclaredField();
f.setAccessible();
