[
https://issues.apache.org/jira/browse/FELIX-4425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13908781#comment-13908781
]
Nicolas Roduit commented on FELIX-4425:
---------------------------------------
The following fix works with Java 7 and Java 8:
Replace
{code}
int i = 0;
for (String c : arg.substring(1).split("")) {
if (i++ == 0)
continue;
...
{code}
by
{code}
for (int i = 1; i < arg.length(); i++) {
String c = String.valueOf(arg.charAt(i));
...
{code}
> Short command in Gogo Shell not working with Java 8
> ----------------------------------------------------
>
> Key: FELIX-4425
> URL: https://issues.apache.org/jira/browse/FELIX-4425
> Project: Felix
> Issue Type: Bug
> Components: Gogo Command
> Environment: Java 8
> Reporter: Nicolas Roduit
>
> The bug comes from the different interpretation of String.split() method in
> line 474 of org.apache.felix.gogo.options.Options (in Gogo Shell).
> Here are the different results of the split method:
> String val = "-k".substring(1).split("");
> Java < 8:
> val[0]=""
> val[1]="k"
> Java 8:
> val[0]="k"
> A simple fix can be an iteration of the characters instead of using split().
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)