Hi Alex,

> On 25 Feb 2016, at 20:59, Alex Buckley <alex.buck...@oracle.com> wrote:
> 
> On 2/25/2016 11:24 AM, Sander Mak wrote:
>> I'm not sure I follow this. ServiceLoader lives in the java.base
>> module, and my service implementation class lives in my application
>> module (without being exported). How is it not a 'superpower' that
>> ServiceLoader can reach into my application module's non-exported
>> package to instantiate that class? Or maybe I should adjust my view
>> and think of the module system as responsible for doing the
>> instantiation by virtue of the 'provides .. with ..' clause in
>> module-info. As you can probably tell I'm not burdened by any
>> implementation knowledge of the modular service loading mechanism at
>> this point...
> 
> JavaFX isn't using ServiceLoader to discover and instantiate service 
> providers of a well known service interface. Since ServiceLoader isn't in the 
> picture, javafx.application.Application is not a service interface (no JavaFX 
> module 'uses' it) and your main class is not a service provider (no user 
> module 'provides' it).
> 
> JavaFX is simply using Core Reflection to instantiate a known class directly 
> (Class::forName/newInstance and presumably Class::isAssignableFrom to check 
> subclassing of jfx.a.Application). Core Reflection requires the class being 
> instantiated to be accessible.

I know, this was a response to a more general discussion on ServiceLoader 
capabilities, aside from my JavaFX question. Should've probably branched into a 
different thread, sorry about that.

Sander

Reply via email to