0.14. Shallow vs deep reflection
From the book:
While we do use shallow reflection in this book, we try to avoid using deep reflection. Mark Reinhold defined these terms on the OpenJDK JPMS (JSR 376) Expert Group mailing list.
- Shallow reflective access is access at runtime via the Core Reflection API (
java.lang.reflect
) without usingsetAccessible
. Only public elements in exported packages can be accessed. - Deep reflective access is access at run time via the Core Reflection API, using the
setAccessible
method to break into non-public elements. Any element, whether public or not, in any package, whether exported or not, can be accessed. Deep reflective access implies shallow reflective access.
0 comments