The baby and the bathwater

Remi Forax forax at univ-mlv.fr
Wed Mar 28 07:41:26 UTC 2018


yes, 
!Whatever.class.getModule().isNamed()

Rémi

----- Mail original -----
> De: "Peter Levart" <peter.levart at gmail.com>
> À: "mark reinhold" <mark.reinhold at oracle.com>, "jigsaw-dev" <jigsaw-dev at openjdk.java.net>
> Envoyé: Mercredi 28 Mars 2018 09:28:23
> Objet: Re: The baby and the bathwater

> On 03/26/18 20:08, mark.reinhold at oracle.com wrote:
>> Stephen closes with a specific suggestion:
>>
>>    "There needs to be a way for a library author to insist that the
>>     modular jar file they are producing can only be run on the module-path
>>     (with any attempt to use it on the class-path preventing application
>>     startup).  This would eliminate the need for testing both class-path
>>     and module-path."
> 
> 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");
>         }
>     }
> 
> 
> Regards, Peter


More information about the jigsaw-dev mailing list