RFR: JDK-8161230 ClassLoader: add resource methods returning java.util.stream.Stream

Paul Sandoz paul.sandoz at oracle.com
Wed Sep 7 20:59:24 UTC 2016


> On 7 Sep 2016, at 13:14, Patrick Reinhart <patrick at reini.net> wrote:
> 
> 
> Hi Paul,
> 
> With the change for  https://bugs.openjdk.java.net/browse/JDK-8165563
> that Mandy has sent to review here:
> 
> http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-September/043363.html
> 
> the method getSystemResources where systemResources method relies on, in
> my understanding should be working.
> 
> If I'm correct I will make my enhancement dependent on JDK-8165563
> 

You are not blocked on JDK-8165563, the two can proceed independently.

Just remove the method systemResources from your patch, we don’t need it as Mandy noted, since JDK-8165563 will render redundant the methods getSystemResource/getSystemResources and thus by extension would also render redundant a new method systemResources.

Paul.

> -Patrick
> 
> 
> On 07.09.2016 21:09, Paul Sandoz wrote:
>> Hi Patrick,
>> 
>> I will sponsor this.
>> 
>> Given what Mandy says about the system class loader i think we can drop the method systemResources. There is some “race memory" not captured in the specification, which should be updated, as Mandy says.
>> 
>> Then…
>> 
>> 1401     public Stream<URL> resources(String name) {
>> 1402         return streamOf(() -> {
>> 1403             try {
>> 1404                 return getResources(name).asIterator();
>> 1405             } catch (IOException e) {
>> 1406                 throw new UncheckedIOException(e);
>> 1407             }
>> 1408         });
>> 1409     }
>> 1410
>> 1411     private static final int RESOURCE_CHARACTERISTICS = Spliterator.NONNULL | Spliterator.IMMUTABLE;
>> 1412
>> 1413     static Stream<URL> streamOf(Supplier<Iterator<URL>> iteratorSupplier) {
>> 1414         return StreamSupport.stream(
>> 1415                 () -> Spliterators.spliteratorUnknownSize(iteratorSupplier.get(), RESOURCE_CHARACTERISTICS),
>> 1416                 RESOURCE_CHARACTERISTICS, false);
>> 1417     }
>> 1418
>> 
>> … you can merge the suppliers e.g:
>> 
>>  Supplier<Spliterator<URL>> si = () -> {
>>    try {
>>      return Spliterators.spliteratorUnknownSize(getResources(name).asIterator(), …);
>>    } catch (IOException e) {
>>      throw new UncheckedIOException(e);
>>    }
>>  };
>>  return StreamSupport.stream(si, …);
>> 
>> ?
>> 
>> Paul.
>> 
>> 
>>> On 7 Sep 2016, at 11:38, Patrick Reinhart <patrick at reini.net> wrote:
>>> 
>>> The current changes can be found here:
>>> 
>>> http://cr.openjdk.java.net/~reinhapa/reviews/8161230/webrev.03
>>> 
>> 
>> 
>> 
> 
> 



More information about the core-libs-dev mailing list