Overriding requirements of 3rd party modules

Gunnar Morling gunnar at hibernate.org
Tue May 3 12:46:57 UTC 2016


Hi,

While looking into Jigsaw-enabling some existing code, I came across the
following use case for which I'm seeking advice on how to deal with.

Consider a 3rd party library that contains JPA entities. Application
developers will include that library into their app and work with its
entities as part of their model. The library author doesn't know which JPA
provider will be used (Hibernate, EclipseLink etc.), so the library should
work with any compatible provider.

Now the different providers all have their own JPA API Jar. Thus in the
module-info.java of the library, there'd be a "requires" clause to one of
the API Jars (e.g. "hibernate-jpa-2.1-api") for compiling and testing the
library.

But users of the lib might want to use *another* JPA provider and hence
 API Jar for their app. What's Jigsaw's approach for letting the user deal
with that? I.e. how could the user override the requirement of the lib in
order to work with the provider of their choice?

I vaguely remember a concept of "module aliases" in earlier drafts which
might have been used for that (for instance, all the different API Jars
could act as "jpa-2.1"), but I cannot seem to find that in the current docs
anymore.

Thanks,

--Gunnar


More information about the jigsaw-dev mailing list