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

Paul Sandoz paul.sandoz at oracle.com
Tue Jul 10 23:12:03 PDT 2012


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.

Paul.


More information about the jigsaw-dev mailing list