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.
Alex