Requires optional permits <was> Re: Service provider module resolution

David Holmes david.holmes at oracle.com
Tue Jul 10 23:28:07 PDT 2012


On 11/07/2012 4:12 PM, Paul Sandoz wrote:
> On Jul 11, 2012, at 3:53 AM, David Holmes wrote:
>>>
>>> IIUC from reading the Jigsaw Big Picture document an optional dependency must resolve at compile time, if such a dependency is not resolvable due to permits or otherwise no module being present then resolution should fail.
>>
>> Are you only referring to an optional dependency on a module which in turns has a permits clause?
>
> An optional dependency in general. From the Jigsaw Big Picture document:
>
> "
> Optional dependences
> A dependence from one module to another can be declared optional:
>
> module bar {
>      requires optional foo;
> }
>
> If no foo module is available then bar can still be installed and invoked. Code in bar that uses types from foo must be written defensively so that it operates properly when foo is not available.
>
> A foo module must still be available when compiling bar since code in bar can depend upon types declared in foo.
> "
>
>> I would not in general expect to have to resolve an optional dependency at compile time.
>
> I was of the same opinion but then changed my mind.
>
> If there is an optional dependency then presumably code in the depending module must be using types exported by the optional dependent module. Reflection is one way to use those types, another is a little bit of indirection (static or via reflection) to static usage of those types.

I think this is wrong. I can use the optional module reflectively so 
that there is no direct type dependency (else the dependency would not 
be optional!). There is no reason that it needs to be present at compile 
time if I don't use those types directly. I would think the above 
statement from the Big Picture should read:

"A foo module must still be available when compiling bar _if_ code in 
bar depends upon types declared in foo."

Cheers,
David
-----

> Paul.



More information about the jigsaw-dev mailing list