Initial webrev with changes for JDK 9
Mandy Chung
mandy.chung at oracle.com
Wed Mar 16 21:03:53 UTC 2016
> On Mar 16, 2016, at 11:50 AM, Mandy Chung <mandy.chung at oracle.com> wrote:
>
>> On Mar 16, 2016, at 10:30 AM, Peter Levart <peter.levart at gmail.com> wrote:
>>
>> In java.lang.ClassLoader:
>>
>> ...the package-private definePackage(String name, Module m) is OK to use a single packages.compute(...) call performance-wise since it is pre-screened with packages.get() in public getDefinedPackage(String name) method.
Peter - thanks for clarifying this. This suggests no need to change definePackage(String,Module).
>> But there's also a package-private packages() method (a basis for public methods getPackages() and getDefinedPackages()) that constructs a Stream<Package> of defined Packages which unnecessarily calls definePackage() for each value of packages map:
>>
>> Stream<Package> packages() {
>> return packages.values().stream()
>> .map(p -> definePackage(p.packageName(), p.module()));
>> }
>>
>>
>> It would be nice performance-wise to avoid calling definePackage if the value is already a Package:
>>
>> Stream<Package> packages() {
>> return packages.values().stream()
>> .map(p -> p instanceof Package
>> ? (Package) p
>> : definePackage(p.packageName(), p.module()));
>> }
>>
I have cleaned up the code to use toPackage instead:
http://cr.openjdk.java.net/~mchung/jigsaw/webrevs/jigsaw-m3/webrev-03-16/index.html
Mandy
More information about the jigsaw-dev
mailing list