A service's `module-info.java` has `exports com.example.orders.api;` but Hibernate, reflecting into JPA entities in `com.example.orders.model`, throws `InaccessibleObjectException` at startup. A teammate proposes widening `exports` to cover the model package too. Is that the right fix, and what's actually different between `exports` and `opens`?
No — exports and opens answer two different questions, and reaching for exports fixes the crash by giving away more than the problem needs. exports com.example.orders.model; would let any module compile against and directly call every public type in that package, turning internal JPA entities into permanent public API for every consumer, forever. What Hibernate actually needs is narrower: the ability to reach into private fields reflectively at run time, with no compile-time visibility implied at all — and that's precisely what opens grants. opens com.example.orders.model; (or, more narrowly, opens com.example.orders.model to org.hibernate.orm.core;) permits deep reflection into that package without making it importable, which is the fix that matches the actual requirement and leaves exports untouched.