8154956: Module system implementation refresh (4/2016)

Alan Bateman Alan.Bateman at oracle.com
Mon May 2 07:31:53 UTC 2016


On 02/05/2016 06:52, Andrej Golovnin wrote:
> :
>
> I don't know how often the method #deriveModuleDescriptor(JarFile)
> is executed. But compiling regular expressions over and over doesn't really
> helps from the performance standpoint of view:
>
>   400         Matcher matcher = Pattern.compile("-(\\d+(\\.|$))").matcher(mn);
>
>   415         mn =  mn.replaceAll("[^A-Za-z0-9]", ".")  // replace
> non-alphanumeric
>   416                 .replaceAll("(\\.)(\\1)+", ".")   // collapse
> repeating dots
>   417                 .replaceAll("^\\.", "")           // drop leading dots
>   418                 .replaceAll("\\.$", "");          // drop trailing dots
>
> Maybe the regular expressions in the above lines should be precompiled
> in static final fields (Pattern objects are immutable and thread safe)
> to improve
> the performance of the #deriveModuleDescriptor(JarFile)-method.
>
This is the pattern matching to derive the module name for an automatic 
module. You are right that this is inefficient, we should only need to 
compile the pattern once. Probably not a static field though as it also 
has to be lazy. I think we have enough in this update so if you don't 
mind, I would prefer to leave this until another refresh.

-Alan


More information about the jigsaw-dev mailing list