Initial webrev with changes for JDK 9

Peter Levart peter.levart at gmail.com
Wed Mar 16 20:04:21 UTC 2016


Hi Alan,

On 03/16/2016 09:30 AM, Alan Bateman wrote:
> I've refreshed the webrevs here:
> http://cr.openjdk.java.net/~alanb/8142968/3

I have another optimization...

In java.lang.reflect.Proxy, a package is added dynamically to the module 
the 1st time a proxy class is defined in that module. Each time new 
proxy class is defined, an array of module package names is compiled by 
concatenating two Streams, dumping them into array, wrapping it with an 
ArrayStream and searching for package if it is already defined:

  583             // add the package to the runtime module if not exists
  584             if (m.isNamed() && 
!Stream.of(m.getPackages()).anyMatch(proxyPkg::equals)) {
  585                 m.addPackage(proxyPkg);
  586             }

... just to avoid calling Module.addPackage() in case the package is 
already defined in that module, although the Module.addPackage() is 
idempotent. Presumably to avoid synchronization? But if the module has 
lots of packages, then such linear search is expensive and produces garbage.

Here's how this linear search and the synchronization in 
Module.addPackage() can be avoided:

http://cr.openjdk.java.net/~plevart/jake/Proxy.addPackage.opt/webrev.01/


Regards, Peter



More information about the jigsaw-dev mailing list