Proposal: #ServiceLoaderEnhancements

Stephen Colebourne scolebourne at joda.org
Tue Sep 13 21:55:26 UTC 2016


On 13 September 2016 at 21:04,  <mark.reinhold at oracle.com> wrote:
> 2016/9/12 15:08:41 -0700, Stephen Colebourne <scolebourne at joda.org>:
>> My preference of these three options is option 2.
>
> Sorry if I wasn't clear, but this isn't meant to be a "choose one"
> proposal.  It's a set of check boxes, not radio buttons.  The proposal
> is to implement suggestions (2) and (3) of your original comment, as
> captured and labeled in the issue text, but not (1).

OK, I see. I think thats fine.

>>                                                   However, I would
>> prefer to see the method name be defined by the module definition as
>> previously suggested [1]:
>>
>> module {
>>  provides java.sql.Driver with com.mysql.jdbc.Driver::instance;
>> }
>>
>> This would allow ::staticMethod or ::staticConstant, and avoid
>> hard-coding "provider" as a special method name.
>>
>> (For my motivating use case, the Chronology classes of ThreeTen-Extra
>> [2] it would be distracting to have a method named provider(). While a
>> separate class in a non-exported package would be possible to hold the
>> provider() method, as a solution that seems like overkill relative to
>> the syntax above.)
>
> The semantics of the `::` syntax as it already exists is tightly bound
> up with type inference.  Also, it can only be used to refer to methods,
> not fields, so it'd have to be extended to support `::staticConstant`.
>
> Working out the details is not impossible, but it's certainly far from
> trivial.  It's not clear to me that, even with more time, it should be
> at the top of our priority list.

I would be OK with just ::staticMethod. It avoids blessing a
particular method name and allows multiple methods on the same class,
but provider() is significantly better than we have today.

Stephen


More information about the jigsaw-dev mailing list