J.VIII · Java 25 practice question
In a normal (non-open) module, which packages are accessible via the Core Reflection API from other modules?
Check answer and explanation
Correct answer: Only packages that are explicitly exported, explicitly opened, or both
Explanation
A normal module permits reflective access only to types in packages that are explicitly exported, explicitly opened, or both.
Common trap
This wrongly excludes exported packages, which do grant reflective access to their public and protected types and members. Having a public class in a package does not grant reflective access unless the package is explicitly exported or opened.
Source: JLS SE 25 §7.7. Module Declarations
Checked against the cited text on 2026-11-25.