The baby and the bathwater

Stephen Colebourne scolebourne at joda.org
Wed Mar 28 09:18:27 UTC 2018


On 28 March 2018 at 08:28, Peter Levart <peter.levart at gmail.com> wrote:
> That's easy to enforce in runtime. Just take a "victim" class from your
> library that is most often needed when your library is being used (or take a
> couple of them) and add a class initialization block like the following to
> them:
>
> public class Whatever {
>
>     static {
>         if (Whatever.class.getModule().getName() == null) {
>             throw new Error("Can only use this library as a module");
>         }
>     }

Agreed that this has always been possible, but it is code not
metadata. Really, it should be a startup JPMS error if the module
isn't running in the expected mode. That way tools like Maven and
Gradle can also take decisions based on the metadata.

Stephen


More information about the jigsaw-dev mailing list