jpackage with a single java property
Alexander Scherbatiy
alexander.scherbatiy at bell-sw.com
Wed Mar 4 14:24:51 UTC 2020
From a user point of view the following provided java command line
arguments are different: a="b c" (string "b c" is assigned to a) and
"a=b c" (b is assigned to a and c is an additional option).
But java command line arguments are indistinguishable in this case:
> java Main a="b c" "a=b c"
arg[0]='a=b c'
arg[1]='a=b c'
public class Main {
public static void main(String[] args) {
for (int i = 0; i < args.length; i++) {
System.out.printf("arg[%d]='%s'%n", i, args[i]);
}
}
}
Thanks,
Alexander.
On 04.03.2020 16:45, Kevin Rushforth wrote:
> No, I doubt this is a bug. If the following worked:
>
> --java-options -Dfoo="bar 2"
>
> meaning if the entire string `-Dfoo=bar 2` was treated as a single
> argument, then the following would fail:
>
> --java-options "--ea -Dfoo=bar"
>
> since it would also be treated as a single argument rather than two
> separate args as intended.
>
> -- Kevin
>
>
> On 3/4/2020 5:04 AM, Andy Herrick wrote:
>> A quick test shows me that this form works fine:
>>
>> --java-options "-Dfoo='bar 2'"
>>
>> where this form fails:
>>
>> --java-options -Dfoo="bar 2"
>>
>> Initially I can see no reason both form shouldn't work, so this looks
>> like a bug to me.
>>
>> /Andy
>>
>>
>> On 3/4/2020 5:20 AM, Alexander Scherbatiy wrote:
>>> Hello,
>>>
>>> CSR for JEP 343: Packaging Tool [1] has description for option value
>>> which consists of a list of strings:
>>>
>>> "If an option value is otherwise a list of strings, they must
>>> separated by space characters. Since the shell would otherwise take
>>> them as separate arguments, the list must be quoted. "
>>>
>>> For example:
>>>
>>> --java-options -server --java-options "--ea -Dfoo=bar"
>>>
>>>
>>> What about a single java property which value contains space
>>> characters (-Dfoo="bar 2")? Should it be possible to pass it in the way:
>>>
>>> --java-options -Dfoo="bar 2"
>>>
>>> or the whole property should be quoted like:
>>>
>>> --java-options "-Dfoo='bar 2'"
>>>
>>>
>>> [1] https://bugs.openjdk.java.net/browse/JDK-8213087
>>>
>>> Thanks,
>>>
>>> Alexander.
>>>
>>>
>
More information about the core-libs-dev
mailing list