So I know that, in Java 9 modules (Project Jigsaw), split packages are not allowed. That is, the following modules couldn't both export a package with the same name and also be used at the same time at run time:
Module 1
module com.example.foo {
exports com.example.foo;
}
Module 2
module com.example.foo {
exports com.example.foo;
}
Not allowed (or, at least, they can't run at the same time). But what isn't clear to me is how subpackages come in to play. If one module exports package com.example.foo
, can another package export com.example.foo.bar
? For example, I want to do the following:
Module 1
module com.example.foo {
exports com.example.foo;
exports com.example.foo.exceptions;
exports com.example.foo.util;
}
Module 2
module com.example.foo.impl1 {
requires com.example.foo;
exports com.example.foo.impl1;
}
Module 3
module com.example.foo.impl2 {
requires com.example.foo;
exports com.example.foo.impl2;
}
Is this allowed? Will all three modules be able to be used together at runtime? Or does the fact that module com.example.foo
exports com.example.foo
preclude another module (com.example.foo.impl1
) from exporting a package with a subpackage name (com.example.foo.impl1
)?