Further investigation shows:

g! type bundles
bundles is Bundle[] context:bundles()
true

g! type headers
headers is void felix:headers(Bundle[])
true

// so bundles appears to return the Bundle[] type required by the headers
command

g! b = (bundles)
    0|Active     |    0|org.apache.felix.framework (2.0.4)
    1|Active     |    1|org.apache.felix.gogo.command (0.5.0.SNAPSHOT)
    2|Active     |    1|org.apache.felix.gogo.runtime (0.5.0.SNAPSHOT)
    3|Active     |    1|org.apache.felix.gogo.shell (0.5.0.SNAPSHOT)

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


// but the result is actually converted into an ArrayList
// and the current coercion mechanism is failing to convert the ArrayList
back to the required Array[]

// explicit conversion works, but should not be necessary:

g! ba = $b toarray
    0|Active     |    0|org.apache.felix.framework (2.0.4)
    1|Active     |    1|org.apache.felix.gogo.command (0.5.0.SNAPSHOT)
    2|Active     |    1|org.apache.felix.gogo.runtime (0.5.0.SNAPSHOT)
    3|Active     |    1|org.apache.felix.gogo.shell (0.5.0.SNAPSHOT)

g! set ba
Bundle[]        ba              [Lorg.osgi.framework.Bundle;@67d225a7
g! headers $ba

System Bundle (0)
-----------------
Bundle-Description = This bundle is system specific; it implements various
system services.
// etc


Note: https://issues.apache.org/jira/browse/FELIX-2337 is also related to
this, as

x = command args

can set x to an array[], while

x = (command args)

will always convert the result to an ArrayList.

ArrayLists are undoubtedly more "useful", but I wonder whether array[]
results should be automatically converted to ArrayLists, rather than just
coerced as needed, like any other type.


Derek

On 28 May 2010 00:12, Richard S. Hall <he...@ungoverned.org> wrote:

> On 5/27/10 7:10 PM, Guillaume Nodet wrote:
>
>> It seems the new coercion mechanism is a bit flawed:
>>
>> g! headers (bundles)
>> gogo: IllegalArgumentException: Cannot coerce
>> headers[[org.apache.felix.framework [0], org.apache.felix.bundlerepository
>> [1], org.apache.felix.gogo.command [2], org.apache.felix.gogo.runtime [3],
>> org.apache.felix.gogo.shell [4]]] to any of [(Bundle[])]
>>
>> That should work without problems. The coercer needs to be enhacned with
>> the
>> following code:
>>
>>
>> http://svn.apache.org/repos/asf/felix/trunk/gogo/commands/src/main/java/org/apache/felix/gogo/commands/converter/DefaultConverter.java
>>
>>
>
> Thanks. I will try to look into it tomorrow.
>
> -> richard
>
>
>  On Thu, May 27, 2010 at 20:49, Richard S. Hall<he...@ungoverned.org>
>>  wrote:
>>
>>
>>
>>> So, we are gearing up to release the 3.0 version of the framework. As
>>> part
>>> of this release, we're going to include Gogo as the default shell in the
>>> framework binary distribution. Gogo requires Java 5 or later, but don't
>>> worry, the framework still targets lesser JREs. :-)
>>>
>>> I've uploaded a snapshot of the distribution in tar.gz and zip if anyone
>>> wants to play with it:
>>>
>>>
>>>
>>> https://repository.apache.org/content/groups/snapshots-group/org/apache/felix/org.apache.felix.main.distribution/2.1.0-SNAPSHOT/
>>>
>>> Word of warning, the "ps" command has been renamed to "lb" (i.e., list
>>> bundles)...type "help" to see available commands.
>>>
>>> ->  richard
>>>
>>>
>>>
>>
>>
>>
>>
>

Reply via email to