[ 
https://issues.apache.org/jira/browse/FELIX-2337?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Derek Baum resolved FELIX-2337.
-------------------------------

    Resolution: Fixed

This has been fixed by not automatically converting return values that are 
Array[] into ArrayList.

If you want to explicitly convert an Array[] into an List, then use:

g! b = (bundles)

g! lb = [ $b ]

g! set lb
ArrayList       lb              [org.apache.felix.framework [0], org.apache.f...

g! set b
Bundle[]        b               [Lorg.osgi.framework.Bundle;@538f1d7e
g! 

To access elements of an array or list, use:

g! $b 1
Location             
file:/Users/derek/Downloads/felix-framework-2.0.4/bundle/org.apache.felix.gogo.command-0.5.0-SNAPSHOT.jar

...
or

g! $lb get 1
Location             
file:/Users/derek/Downloads/felix-framework-2.0.4/bundle/org.apache.felix.gogo.command-0.5.0-SNAPSHOT.jar
...


> [gogo] no way to access array[] elements produced by assignment
> ---------------------------------------------------------------
>
>                 Key: FELIX-2337
>                 URL: https://issues.apache.org/jira/browse/FELIX-2337
>             Project: Felix
>          Issue Type: Bug
>          Components: Gogo
>            Reporter: Derek Baum
>            Assignee: Derek Baum
>            Priority: Minor
>             Fix For: gogo-0.6.0
>
>
> the following two alternative assignments, should be equivalent:
> x = command args ...
> x = (command args ..)
> but they are not, if the result is an array:
> % x = [a b c] toarray
> % $x get 0
> IllegalArgumentException: Cannot coerce get[0] to any of []
> % x = ([a b c] toarray)
> % $x get 0
> This is because gogo normally converts any array result into a list 
> (Closure.java:228):
>         if (last.result instanceof Object[])
>         {
>             return Arrays.asList((Object[]) last.result);
>         }
> but the assignment without () bypasses this conversion, and results in a real 
> array.
> I can obviously fix this so that the conversion to a List occurs in all 
> cases, but I was wondering whether gogo should be performing this conversion 
> in the first place? If the conversion is not performed, then we'll need to 
> support ($array $index) to access arrays.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to