J.VIII · Java 25 practice question
A team exports `com.acme.model` from their module without adding an `opens` directive. Can another module use reflection to access public types and members in `com.acme.model`?
Check answer and explanation
Correct answer: Yes, exporting a package also grants reflective access to its public and protected types and members
Explanation
An exports directive grants reflective access to the exported package's public and protected types and members in addition to compile-time and run-time access.
Common trap
Developers often conflate deep reflection on private members (which requires opens) with all reflective access, forgetting that exports already permits reflection on public and protected elements. Reflective access to exported public and protected types is granted to code in other modules in general, not restricted to unnamed modules.
Source: JLS SE 25 §7.7.2. Exported and Opened Packages
Checked against the cited text on 2026-11-25.