From notifications-return-15537-archive-asf-public=cust-asf.ponee.io@groovy.apache.org Mon Feb 18 05:13:05 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 24689180657 for ; Mon, 18 Feb 2019 06:13:04 +0100 (CET) Received: (qmail 58764 invoked by uid 500); 18 Feb 2019 05:13:04 -0000 Mailing-List: contact notifications-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list notifications@groovy.apache.org Received: (qmail 58755 invoked by uid 99); 18 Feb 2019 05:13:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Feb 2019 05:13:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 1FBB7C1AF3 for ; Mon, 18 Feb 2019 05:13:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -109.501 X-Spam-Level: X-Spam-Status: No, score=-109.501 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id WNZ7aSQGivEF for ; Mon, 18 Feb 2019 05:13:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 260376244C for ; Mon, 18 Feb 2019 05:13:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 5B1A6E092E for ; Mon, 18 Feb 2019 05:13:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 19D30244FB for ; Mon, 18 Feb 2019 05:13:00 +0000 (UTC) Date: Mon, 18 Feb 2019 05:13:00 +0000 (UTC) From: "Paul King (JIRA)" To: notifications@groovy.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (GROOVY-8975) GroovyCastException on the result of CliBuilder.parseFromSpec MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/GROOVY-8975?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D167= 70786#comment-16770786 ]=20 Paul King commented on GROOVY-8975: ----------------------------------- [~remkop@yahoo.com] You have this in your example: {code} def options =3D cli.parseFromSpec(GreeterI, argz) {code} whereas I suspect there might be problems if you had: {code} GreeterI options =3D cli.parseFromSpec(GreeterI, argz) {code} but this would work (though shouldn't be needed): {code} GreeterI options =3D cli.parseFromSpec(GreeterI, argz) as GreeterI {code} > 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: Remko Popma > Priority: Major > Attachments: GROOVY-8975.zip > > > I'm trying to follow the tutorial about the use of CliBuilder in Groovy w= ith Groovy 2.5.5. Copying the code at [Annotating methods of an interface|h= ttps://github.com/remkop/picocli/wiki/Groovy-2.5-CliBuilder-Renewal#annotat= ing-methods-of-an-interface] paragraph, at runtime I have the following Exc= eption: > {noformat} > Exception in thread "main" org.codehaus.groovy.runtime.typehandling.Groov= yCastException: Cannot cast object '{help=3Dgroovy.cli.picocli.CliBuilder$_= extractAttributesFromMethod_closure12@3bb9a3ff}' with class 'java.util.Link= edHashMap' to class 'mypackage.IHello' due to: groovy.lang.GroovyRuntimeExc= eption: Could not find matching constructor for: mypackage.IHello(LinkedHas= hMap) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 at org.codehaus.groovy.runtime= .typehandling.DefaultTypeTransformation.continueCastOnSAM(DefaultTypeTransf= ormation.java:412) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 at org.codehaus.groovy.runtime= .typehandling.DefaultTypeTransformation.continueCastOnNumber(DefaultTypeTra= nsformation.java:328) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 at org.codehaus.groovy.runtime= .typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformatio= n.java:242) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 at org.codehaus.groovy.runtime= .ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:617) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 at mypackage.MyMain.main(MyMai= n.groovy:20)Exception in thread "main" org.codehaus.groovy.runtime.typehand= ling.GroovyCastException: Cannot cast object '{help=3Dgroovy.cli.picocli.Cl= iBuilder$_extractAttributesFromMethod_closure12@3bb9a3ff}' with class 'java= .util.LinkedHashMap' to class 'mypackage.IHello' due to: groovy.lang.Groovy= RuntimeException: Could not find matching constructor for: mypackage.IHello= (LinkedHashMap) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 at org.codehaus.groovy.runtime= .typehandling.DefaultTypeTransformation.continueCastOnSAM(DefaultTypeTransf= ormation.java:412) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 at org.codehaus.groovy.runtime= .typehandling.DefaultTypeTransformation.continueCastOnNumber(DefaultTypeTra= nsformation.java:328) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 at org.codehaus.groovy.runtime= .typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformatio= n.java:242) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 at org.codehaus.groovy.runtime= .ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:617) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 at mypackage.MyMain.main(DcsSe= rvizi2Sdi.groovy:20){noformat} > The exception occurs at this line: > {{IHello hello =3D cli.parseFromSpec(IHello, argz)}} > The exception goes away (and all works fine) if I replace it with: > {{def hello =3D cli.parseFromSpec(IHello, argz)}} > I tried to downgrade Groovy down to version 2.5.0 and I always get the ex= ception. So this really puzzles me, since the mentioned tutorial is quite s= imple and straight to follow... -- This message was sent by Atlassian JIRA (v7.6.3#76005)