jakartaee / persistence

https://jakartaee.github.io/persistence/
Other
187 stars 55 forks source link

Support compatibility with JPMS #491

Open lukasj opened 10 months ago

lukasj commented 10 months ago

JPMS introduced the concept of the module path in addition to the classpath but the spec currently strongly requires usage on the classpath in a way disallowing users to pass their entities (etc) through the module path. For example, in section 8.2.1.6, there we have:

The classes and/or jars that are named as part of a persistence unit must be on the classpath and All classes must be on the classpath to ensure....

While obvious and trivial solution to this is to add or on the module path, I do not think it is the right way to approach this.

Another thing to consider is to how to allow and define dealing with reflective access required by persistence providers. My way of thinking here is that as a user, I want to define my JPMS descriptor following way:

module org.my {
    requires jakarta.persistence;
    opens org.my.entities to jakarta.persistence;
}

and let the runtime API to find the right provider and pass the open declaration to him - something similar to what XML Binding has: If JAXB-annotated classes or packages referenced in context path are defined in a Java Platform Module System (JSR 376) module, they must be open (as specified in javadoc of java.lang.Module#isOpen()) to at least jakarta.xml.bind module.