Splitting of packages between modules

Alan Bateman Alan.Bateman at oracle.com
Sun Oct 7 07:14:10 PDT 2012


On 05/10/2012 19:52, Richard Warburton wrote:
> Hey all,
>
> I'm still a bit uncertain of mail aliases, but I'm assuming its
> acceptable to post questions/design to this alias.  If this is just
> openjdk stuff I'm sorry and could you send me in the right direction.
>
> Suppose I have an API that I wish to split into smaller and larger
> versions.  I have a package called com.foo.bar and which is split into
> some set of classes that I wish to put into the smaller API and some
> into the larger API.  My natural instinct would be to have a module
> say called "Foo-Minimal" and another module called "Foo-Extras".
> Foo-Extras would depend on Foo-Minimal.  Is it possible for me to
> split the com.foo.bar package between Foo-Minimal and Foo-Extras or am
> I required to introduce a com.foo.bar.extras package?
>
> regards,
>
>    Richard
The current Jigsaw prototype supports this, using "requires local". In 
this case Foo_Minimal and Foo_Extras could be separate physical modules 
and with requires local they will be brought together at runtime so 
classes from both modules are loaded by the same module class loader. 
There's a lot issues that stem from this and it creates a lot of 
challenges, particularly with figuring out and specifying how certain 
cases should work. That plus having it easily understood by the average 
developer. It remains to be seen where this ultimately goes. One of 
benefits of moving out Jigsaw to beyond JDK 8 is that it provides an 
opportunity to re-examine some of the cases in JDK where this has been 
needed.

That said, I don't know if you have a specific Foo in mind, maybe it 
could be refactored without breaking too many existing consumers? Are 
you thinking about a well established API? Does it rely heavily on 
package-private access?

-Alan



More information about the jigsaw-dev mailing list