Right now only 1+ arguments XOR 0 arguments are possible for jlink plugins. Sometimes it's useful to allow optional arguments for plugin options so as to override defaults the jlink plugin uses. Example case is JDK-8214796 which adds a plugin for stripping native debug symbols from executables/shared libraries. However, a soon as Plugin.hasArgument() returns true there is no way to *not* provide an argument:
$ ./build/linux-x86_64-server-release/images/jdk/bin/jlink --strip-native-debug-symbols --add-modules java.base --output custom-image --verbose
Error: no value given for --strip-native-debug-symbols
Usage: jlink <options> --module-path <modulepath> --add-modules <module>[,<module>...]
Use --help for a list of possible options
Yet, this works:
$ ./build/linux-x86_64-server-release/images/jdk/bin/jlink --strip-native-debug-symbols defaults --add-modules java.base --output custom-image --verbose
The error check related to arguments seems to be coming from this code:
http://hg.openjdk.java.net/jdk/jdk/file/3e451bff6f7f/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java#l560
There is a check for opt.hasArg() == true which, in turn, is determined by Plugin.hasArguments():
http://hg.openjdk.java.net/jdk/jdk/file/3e451bff6f7f/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java#l312
$ ./build/linux-x86_64-server-release/images/jdk/bin/jlink --strip-native-debug-symbols --add-modules java.base --output custom-image --verbose
Error: no value given for --strip-native-debug-symbols
Usage: jlink <options> --module-path <modulepath> --add-modules <module>[,<module>...]
Use --help for a list of possible options
Yet, this works:
$ ./build/linux-x86_64-server-release/images/jdk/bin/jlink --strip-native-debug-symbols defaults --add-modules java.base --output custom-image --verbose
The error check related to arguments seems to be coming from this code:
http://hg.openjdk.java.net/jdk/jdk/file/3e451bff6f7f/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java#l560
There is a check for opt.hasArg() == true which, in turn, is determined by Plugin.hasArguments():
http://hg.openjdk.java.net/jdk/jdk/file/3e451bff6f7f/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java#l312