12 Reflection in a modular world

This chapter covers

  • Opening packages and modules to reflection
  • Combining modules and reflection
  • Alternatives to the reflection API
  • Analyzing and modifying module properties

If you’re working on a Java application, chances are good that you rely on Spring, Hibernate, JAXP, GSON, or the like. What are “the like”? Frameworks that use Java’s reflection API to inspect your code, search for annotations, instantiate objects, or call methods. Thanks to reflection, they can do all that without having to compile against your code.

Moreover, the reflection API allows frameworks to access nonpublic classes and nonpublic members. It has superpowers beyond what’s possible with compiled code, which bounces off of package boundaries ...

Get The Java Module System now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.