Re: Groovy 5.0.7 and getter naming convention
Adrien Guichard <[email protected]> Fri, 17 Jul 2026 19:56:40 +0200
| Newsgroups | gmane.comp.lang.groovy.user |
|---|---|
| Message-ID | <CAJHGhwAOPyXX0wXpyFMXMp=j-L3vq-FGAXMoeuwgd2_j77b44Q@mail.gmail.com> |
--00000000000019a03e0656d24845 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable FYI, I found the issue, it has nothing to do with the getter's name... Sorry for the confusion. The failure was delayed after executing the code causing the issue: // Groovy4 seems happy with the following line, but not groovy 5 (Class Cast Exception from String to MethodNode) // sceGetDeclaredField.setNodeMetaData(StaticTypesMarker.DIRECT_METHOD_CALL_TA= RGET, "getDeclaredField"); // Groovy 5 OK version sceGetDeclaredField.setNodeMetaData(StaticTypesMarker.DIRECT_METHOD_CALL_TA= RGET, findDeclaredMethod(classNode, "getDeclaredField", 1)); The 2nd arg of setNodeMetaData is "Object" so both versions compile OK .. Le ven. 17 juil. 2026 =C3=A0 18:47, Adrien Guichard <adrien.guichard@citel.= fr> a =C3=A9crit : > Thanks, for this quick and simple test-case! > > Will have to debug to provide a relevant test-case on my side. > > Regards > > Le ven. 17 juil. 2026, 17:51, Jochen Theodorou <[email protected]> a > =C3=A9crit : > >> Hi Adrien, >> >> I just tested with this code: >> >> class X { >> def getFirstName_(){"Adrien"} >> } >> >> assert new X().firstName_ =3D=3D "Adrien" >> >> The assert works, no exception. I think this is not because of Groovy >> 5.0.7 then >> >> bye Jochen >> >> On 7/17/26 16:05, Adrien Guichard wrote: >> > Hello, >> > >> > >> > We are porting our framework to Grails 8.0.0(-M3), which defaults to >> > Groovy 5.0.7. >> > >> > This framework generates getters from an AST Transformation at compile >> > time. Symbols generated are then used into some DSLs to compose >> elements >> > of our apps. >> > >> > There is an exception when launching our test app if the name of the >> > getters ends with an '_'; like in "getFirstName*_*()", if I replace th= e >> > '_' with another char, it fails after (missing symbols, because I use >> > 'someone.firstName_' in the code). >> > >> > Is there any restriction regarding the naming conventions for getters >> in >> > Groovy 5 ? >> > >> > If not, I will dig further and fill an eventual bug report if needed. >> > >> > >> > Regards >> > >> > -- >> > Adrien Guichard >> > + 33 6 10 78 75 88 >> > Taack / Citel / Obsta >> > 29 Boulevard Edgar Quinet >> > 75014 Paris >> >> --=20 Adrien Guichard + 33 6 10 78 75 88 Taack / Citel / Obsta 29 Boulevard Edgar Quinet 75014 Paris --00000000000019a03e0656d24845 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">FYI, I found the issue, it has nothing to do with the gett= er's name... Sorry for the=C2=A0confusion.<div><br></div><div>The failu= re was delayed after executing the code causing the issue:=C2=A0<div><br></= div><div>// Groovy4 seems happy with the following line, but not groovy 5 (= Class Cast Exception from String to MethodNode)</div><div>//=C2=A0 =C2=A0 = =C2=A0 sceGetDeclaredField.setNodeMetaData(StaticTypesMarker.DIRECT_METHOD_= CALL_TARGET, "getDeclaredField");</div><div>// Groovy 5 OK versio= n</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 sceGetDeclaredField.setNodeMetaData= (StaticTypesMarker.DIRECT_METHOD_CALL_TARGET,=C2=A0</div><div><span style= =3D"background-color:transparent">=C2=A0 =C2=A0 =C2=A0 =C2=A0</span><span s= tyle=3D"background-color:transparent">=C2=A0</span>=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0findDeclaredMeth= od(classNode, "getDeclaredField", 1));<br></div></div><div>The 2n= d arg of setNodeMetaData=C2=A0is "Object" so both versions=C2=A0c= ompile=C2=A0OK ..</div><div><br></div></div><br><div class=3D"gmail_quote g= mail_quote_container"><div dir=3D"ltr" class=3D"gmail_attr">Le=C2=A0ven. 17= juil. 2026 =C3=A0=C2=A018:47, Adrien Guichard <<a href=3D"mailto:adrien= [email protected]">[email protected]</a>> a =C3=A9crit=C2=A0:<br= ></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;= border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><= div dir=3D"auto">Thanks, for this quick and simple test-case!<div dir=3D"au= to"><br></div><div>Will have to debug to provide a relevant test-case on my= side.</div><div><br></div><div>Regards=C2=A0</div></div></div><br><div cla= ss=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">Le ven. 17 juil. 2= 026, 17:51, Jochen Theodorou <<a href=3D"mailto:[email protected]" targe= t=3D"_blank">[email protected]</a>> a =C3=A9crit=C2=A0:<br></div><blockq= uote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1p= x solid rgb(204,204,204);padding-left:1ex">Hi Adrien,<br> <br> I just tested with this code:<br> <br> class X {<br> =C2=A0 =C2=A0def getFirstName_(){"Adrien"}<br> }<br> <br> assert new X().firstName_ =3D=3D "Adrien"<br> <br> The assert works, no exception. I think this is not because of Groovy <br> 5.0.7 then<br> <br> bye Jochen<br> <br> On 7/17/26 16:05, Adrien Guichard wrote:<br> > Hello,<br> > <br> > <br> > We are=C2=A0porting our framework to Grails 8.0.0(-M3), which defaults= to <br> > Groovy 5.0.7.<br> > <br> > This framework=C2=A0generates getters from an AST Transformation at co= mpile <br> > time. Symbols generated are then used into some DSLs to compose elemen= ts <br> > of our apps.<br> > <br> > There is an exception when launching our test app if the name of the <= br> > getters ends with an '_'; like in "getFirstName*_*()"= ;, if I replace the <br> > '_' with another char, it fails after (missing symbols, becaus= e I use <br> > 'someone.firstName_' in the code).<br> > <br> > Is there any restriction regarding the naming conventions for getters = in <br> > Groovy 5 ?<br> > <br> > If not, I will dig further and fill an eventual bug report if needed.<= br> > <br> > <br> > Regards<br> > <br> > -- <br> > Adrien Guichard<br> > + 33 6 10 78 75 88<br> > Taack / Citel / Obsta<br> > 29 Boulevard Edgar Quinet<br> > 75014 Paris<br> <br> </blockquote></div> </blockquote></div><div><br clear=3D"all"></div><div><br></div><span class= =3D"gmail_signature_prefix">-- </span><br><div dir=3D"ltr" class=3D"gmail_s= ignature"><div dir=3D"ltr"><div dir=3D"ltr">Adrien Guichard<div>+ 33 6 10 7= 8 75 88<br><div>Taack / Citel / Obsta</div><div>29 Boulevard Edgar Quinet<b= r></div><div><div>75014 Paris<br></div></div></div></div></div></div> --00000000000019a03e0656d24845--