RFR: JDK-8158402 - jlink: should use regex for all pattern operations (--order-resources or --exclude-resources)

Chris Hegarty chris.hegarty at oracle.com
Thu Jun 9 11:58:43 UTC 2016


> On 9 Jun 2016, at 12:57, Jim Laskey (Oracle) <james.laskey at oracle.com> wrote:
> 
> 
>> On Jun 9, 2016, at 8:52 AM, Chris Hegarty <chris.hegarty at oracle.com> wrote:
>> 
>>> 
>>> On 9 Jun 2016, at 11:16, Alan Bateman <Alan.Bateman at oracle.com> wrote:
>>> 
>>> On 08/06/2016 20:45, Jim Laskey (Oracle) wrote:
>>> 
>>>> Consistent use of PathPatterns for jlink, jimage and jmod options.
>>>> 
>>>> —optionName=(regex:|glob:|<nil>)<pattern> ?? where <nil><pattern> => glob:<pattern>
>>>> 
>>>> http://cr.openjdk.java.net/~jlaskey/8158402/webrev/index.html <http://cr.openjdk.java.net/~jlaskey/8158402/webrev/index.html>
>>>> https://bugs.openjdk.java.net/browse/JDK-8158402 <https://bugs.openjdk.java.net/browse/JDK-8158402>
>>>> 
>>> This look okay to me but two questions:
>>> 
>>> 1. Do any of the usage resources need to be updated?
>>> 
>>> 2. Does this introduce an inconsistency in the jmod tool in that --hash-modules takes a regex whereas --exclude takes a pattern that is a glob (at least by default, it could be a regex too if prefixed with "regex:").
>> 
>> As things currently stand --hash-modules accepts a regex, and --exclude 
>> accepts a glob. So this change does not affect default behaviour.
>> 
>> It makes sense for --exclude to take a glob ( and optionally a regex ).
>> I don’t think it makes sense for --hash-modules to take anything other
>> than a regex.
>> 
>> Are there issues with this?
>> 
>> Jim,   can you please rename GlobConverter to PatternConverter or ExcludeConverter,
>> or similar.
> 
> diff -r 766e969fc3e0 src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java
> --- a/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java	Thu Jun 09 07:55:38 2016 -0300
> +++ b/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java	Thu Jun 09 08:56:46 2016 -0300
> @@ -1072,6 +1072,10 @@
>         @Override
>         public Pattern convert(String value) {
>             try {
> +                if (value.startsWith("regex:")) {
> +                    value = value.substring("regex:".length()).trim();
> +                }
> +                
>                 return Pattern.compile(value);
>             } catch (PatternSyntaxException e) {
>                 throw new CommandException("err.bad.pattern", value);
> @@ -1083,7 +1087,7 @@
>         @Override public String valuePattern() { return "pattern"; }
>     }
> 
> -    static class GlobConverter implements ValueConverter<PathMatcher> {
> +    static class PathMatcherConverter implements ValueConverter<PathMatcher> {
>         @Override
>         public PathMatcher convert(String pattern) {
>             try {
> @@ -1199,7 +1203,7 @@
>         OptionSpec<PathMatcher> excludes
>                 = parser.accepts("exclude", getMessage("main.opt.exclude"))
>                         .withRequiredArg()
> -                        .withValuesConvertedBy(new GlobConverter());
> +                        .withValuesConvertedBy(new PathMatcherConverter());
> 
>         OptionSpec<Pattern> hashModules
>                 = parser.accepts("hash-modules", getMessage("main.opt.hash-modules”))

That looks fine. Thanks.

-Chris.



More information about the jigsaw-dev mailing list