Error message when accessing non-public type

Alan Bateman Alan.Bateman at oracle.com
Thu Jun 23 07:45:39 UTC 2016


On 22/06/2016 21:31, Alex Buckley wrote:

> Hi Gunnar,
>
> Thanks. Yes, I suspected you were using ServiceLoader::load to get a 
> dummy instance of each custom constraint validator class (in general, 
> there might be multiple modules providing a validator for 
> @Min-on-int), and then obtaining each dummy's Class object and doing 
> your own instantiations of validator classes thereafter.
>
> It wouldn't help if ServiceLoader simply returned the Class objects 
> for service implementations, because you still wouldn't be able to 
> newInstance() them without the export. You would need ServiceLoader to 
> take one of those Class objects back (call it cImpl), along with the 
> Class object for a service interface (call it cIntf), and then 
> instantiate cImpl on your behalf if a) cIntf.isAssignableFrom(cImpl) 
> and b) <<some caller-sensitive conditions>>. No more export needed.
There has been a number of experiments and proposals along these lines 
over the years. I think the most recent was a way to filter and order 
based on the provider type. It needs more thought to see if this is the 
right thing to do or not.

-Alan.


More information about the jigsaw-dev mailing list