shell:new command fails when there are constructors with wildcard parameterized arguments

Solution Unverified - Updated -

Issue

Using the Karaf command shell:new gives an illegal state exception when passing arguments if the class has a constructor that takes a parameterized argument. For example, try the following:

test = shell:new java.util.ArrayList 2

This produces the error below. This is because ArrayList has a constructor that takes a wildcard parameterized argument which the org.apache.felix.gogo.commands.converter.GenericType doesn't handle. It seems to happen for any similar class with wildcard parameterized constructors.

2016-08-25 15:06:34,965 | ERROR | l Console Thread | Console                          | 38 - org.apache.karaf.shell.console - 2.4.0.redhat-621084 | Exception caught while executing command
java.lang.IllegalStateException
        at org.apache.felix.gogo.commands.converter.GenericType.parametersOf(GenericType.java:161)
        at org.apache.felix.gogo.commands.converter.GenericType.(GenericType.java:53)
        at org.apache.felix.gogo.commands.converter.GenericType.parametersOf(GenericType.java:154)
        at org.apache.felix.gogo.commands.converter.GenericType.(GenericType.java:53)
        at org.apache.karaf.shell.commands.NewAction.findMatchingConstructors(NewAction.java:110)
        at org.apache.karaf.shell.commands.NewAction.doExecute(NewAction.java:68)
        at org.apache.karaf.shell.console.AbstractAction.execute(AbstractAction.java:33)
        at org.apache.felix.gogo.commands.basic.AbstractCommand.execute(AbstractCommand.java:35)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_80]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_80]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_80]
        at java.lang.reflect.Method.invoke(Method.java:606)[:1.7.0_80]
        at org.apache.aries.proxy.impl.ProxyHandler$1.invoke(ProxyHandler.java:54)[19:org.apache.aries.proxy.impl:1.0.4]
        at org.apache.aries.proxy.impl.ProxyHandler.invoke(ProxyHandler.java:119)[19:org.apache.aries.proxy.impl:1.0.4]
        at org.apache.karaf.shell.console.commands.$BlueprintCommand36996461.execute(Unknown Source)[38:org.apache.karaf.shell.console:2.4.0.redhat-621084]
        at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:78)[38:org.apache.karaf.shell.console:2.4.0.redhat-621084]
        at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:477)[38:org.apache.karaf.shell.console:2.4.0.redhat-621084]
        at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:394)[38:org.apache.karaf.shell.console:2.4.0.redhat-621084]
        at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[38:org.apache.karaf.shell.console:2.4.0.redhat-621084]
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)[38:org.apache.karaf.shell.console:2.4.0.redhat-621084]
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)[38:org.apache.karaf.shell.console:2.4.0.redhat-621084]
        at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:92)[38:org.apache.karaf.shell.console:2.4.0.redhat-621084]
        at org.apache.karaf.shell.console.jline.Console.run(Console.java:197)[38:org.apache.karaf.shell.console:2.4.0.redhat-621084]
        at org.apache.karaf.shell.console.jline.DelayedStarted.run(DelayedStarted.java:79)[38:org.apache.karaf.shell.console:2.4.0.redhat-621084]

Environment

  • JBoss Fuse
    • 6.2.1

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content