groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mauro Molinari (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (GROOVY-8975) GroovyCastException on the result of CliBuilder.parseFromSpec
Date Mon, 18 Feb 2019 11:03:00 GMT

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

Mauro Molinari updated GROOVY-8975:
-----------------------------------
    Description: 
I'm trying to follow the tutorial about the use of CliBuilder in Groovy with Groovy 2.5.5.
Copying the code at [Annotating methods of an interface|https://github.com/remkop/picocli/wiki/Groovy-2.5-CliBuilder-Renewal#annotating-methods-of-an-interface]
paragraph, at runtime I have the following Exception:
{noformat}
Exception in thread "main" org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot
cast object '{help=groovy.cli.picocli.CliBuilder$_extractAttributesFromMethod_closure12@3bb9a3ff}'
with class 'java.util.LinkedHashMap' to class 'mypackage.IHello' due to: groovy.lang.GroovyRuntimeException:
Could not find matching constructor for: mypackage.IHello(LinkedHashMap)
        at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnSAM(DefaultTypeTransformation.java:412)
        at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnNumber(DefaultTypeTransformation.java:328)
        at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:242)
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:617)
        at mypackage.MyMain.main(MyMain.groovy:20)Exception in thread "main" org.codehaus.groovy.runtime.typehandling.GroovyCastException:
Cannot cast object '{help=groovy.cli.picocli.CliBuilder$_extractAttributesFromMethod_closure12@3bb9a3ff}'
with class 'java.util.LinkedHashMap' to class 'mypackage.IHello' due to: groovy.lang.GroovyRuntimeException:
Could not find matching constructor for: mypackage.IHello(LinkedHashMap)
        at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnSAM(DefaultTypeTransformation.java:412)
        at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnNumber(DefaultTypeTransformation.java:328)
        at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:242)
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:617)
        at mypackage.MyMain.main(MyMain.groovy:20){noformat}
The exception occurs at this line:
 {{IHello hello = cli.parseFromSpec(IHello, argz)}}

The exception goes away (and all works fine) if I replace it with:
 {{def hello = cli.parseFromSpec(IHello, argz)}}

I tried to downgrade Groovy down to version 2.5.0 and I always get the exception. So this
really puzzles me, since the mentioned tutorial is quite simple and straight to follow...

  was:
I'm trying to follow the tutorial about the use of CliBuilder in Groovy with Groovy 2.5.5.
Copying the code at [Annotating methods of an interface|https://github.com/remkop/picocli/wiki/Groovy-2.5-CliBuilder-Renewal#annotating-methods-of-an-interface]
paragraph, at runtime I have the following Exception:
{noformat}
Exception in thread "main" org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot
cast object '{help=groovy.cli.picocli.CliBuilder$_extractAttributesFromMethod_closure12@3bb9a3ff}'
with class 'java.util.LinkedHashMap' to class 'mypackage.IHello' due to: groovy.lang.GroovyRuntimeException:
Could not find matching constructor for: mypackage.IHello(LinkedHashMap)
        at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnSAM(DefaultTypeTransformation.java:412)
        at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnNumber(DefaultTypeTransformation.java:328)
        at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:242)
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:617)
        at mypackage.MyMain.main(MyMain.groovy:20)Exception in thread "main" org.codehaus.groovy.runtime.typehandling.GroovyCastException:
Cannot cast object '{help=groovy.cli.picocli.CliBuilder$_extractAttributesFromMethod_closure12@3bb9a3ff}'
with class 'java.util.LinkedHashMap' to class 'mypackage.IHello' due to: groovy.lang.GroovyRuntimeException:
Could not find matching constructor for: mypackage.IHello(LinkedHashMap)
        at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnSAM(DefaultTypeTransformation.java:412)
        at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnNumber(DefaultTypeTransformation.java:328)
        at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:242)
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:617)
        at mypackage.MyMain.main(DcsServizi2Sdi.groovy:20){noformat}
The exception occurs at this line:
 {{IHello hello = cli.parseFromSpec(IHello, argz)}}

The exception goes away (and all works fine) if I replace it with:
 {{def hello = cli.parseFromSpec(IHello, argz)}}

I tried to downgrade Groovy down to version 2.5.0 and I always get the exception. So this
really puzzles me, since the mentioned tutorial is quite simple and straight to follow...


> GroovyCastException on the result of CliBuilder.parseFromSpec
> -------------------------------------------------------------
>
>                 Key: GROOVY-8975
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8975
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 2.5.5
>            Reporter: Mauro Molinari
>            Assignee: Paul King
>            Priority: Major
>         Attachments: GROOVY-8975.zip, TestGroovy8975.zip
>
>
> I'm trying to follow the tutorial about the use of CliBuilder in Groovy with Groovy 2.5.5.
Copying the code at [Annotating methods of an interface|https://github.com/remkop/picocli/wiki/Groovy-2.5-CliBuilder-Renewal#annotating-methods-of-an-interface]
paragraph, at runtime I have the following Exception:
> {noformat}
> Exception in thread "main" org.codehaus.groovy.runtime.typehandling.GroovyCastException:
Cannot cast object '{help=groovy.cli.picocli.CliBuilder$_extractAttributesFromMethod_closure12@3bb9a3ff}'
with class 'java.util.LinkedHashMap' to class 'mypackage.IHello' due to: groovy.lang.GroovyRuntimeException:
Could not find matching constructor for: mypackage.IHello(LinkedHashMap)
>         at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnSAM(DefaultTypeTransformation.java:412)
>         at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnNumber(DefaultTypeTransformation.java:328)
>         at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:242)
>         at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:617)
>         at mypackage.MyMain.main(MyMain.groovy:20)Exception in thread "main" org.codehaus.groovy.runtime.typehandling.GroovyCastException:
Cannot cast object '{help=groovy.cli.picocli.CliBuilder$_extractAttributesFromMethod_closure12@3bb9a3ff}'
with class 'java.util.LinkedHashMap' to class 'mypackage.IHello' due to: groovy.lang.GroovyRuntimeException:
Could not find matching constructor for: mypackage.IHello(LinkedHashMap)
>         at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnSAM(DefaultTypeTransformation.java:412)
>         at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnNumber(DefaultTypeTransformation.java:328)
>         at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:242)
>         at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:617)
>         at mypackage.MyMain.main(MyMain.groovy:20){noformat}
> The exception occurs at this line:
>  {{IHello hello = cli.parseFromSpec(IHello, argz)}}
> The exception goes away (and all works fine) if I replace it with:
>  {{def hello = cli.parseFromSpec(IHello, argz)}}
> I tried to downgrade Groovy down to version 2.5.0 and I always get the exception. So
this really puzzles me, since the mentioned tutorial is quite simple and straight to follow...



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message