[ https://issues.apache.org/jira/browse/GROOVY-9007?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King closed GROOVY-9007. ----------------------------- > Getting java.lang.NoSuchFieldError with groovy version 2.5.6 > ------------------------------------------------------------ > > Key: GROOVY-9007 > URL: https://issues.apache.org/jira/browse/GROOVY-9007 > Project: Groovy > Issue Type: Bug > Components: class generator, groovy-runtime > Affects Versions: 2.5.6 > Environment: Windows7, Java8, Spring-Boot 2.1.3 > Reporter: Pankaj > Assignee: Paul King > Priority: Critical > Fix For: 3.0.0-beta-1, 2.5.7 > > > Recently, I upgrade my spring boot application with version 2.1.3. I found > many test cases started failing with error {color:#d04437}(Caused by: > java.lang.NoSuchFieldError: *it*){color}. After drilling down dependency list > I noticed that groovy version 2.5.6 is being used. Which might be cauing > these issues. Earlier it was groovy version 2.5.5 and my application was > working just fine. I tried using version 2.5.5 explicitely in pom.xml and > application again started working. > This looks like a possible bug with version 2.5.6. After compaing .class file > generated for both version found some difference which might be causing this > issue: > *2.5.6 generated .class code:* Here > "TestGroovyNewVersion.AddressInd{color:#d04437}.it.{color}addressInd" looks > incorrect as 'it' not defined as var for AddressInd enum. Here 'it' isn't > getting treated as an explicit parameter for closures. > {code:java} > return > ScriptBytecodeAdapter.compareEqual(TestGroovyNewVersion.AddressInd.it.addressInd, > addressInd.get());{code} > > *2.5.5 generated .class code:* > {code:java} > return > ScriptBytecodeAdapter.compareEqual(((TestGroovyNewVersion.AddressInd)it).addressInd,addressInd.get());{code} > +Here is my groovy code and below line of code is given error:+ > *AddressInd indicator = values().find\{ it.addressInd == addressInd }* > > {code:java} > import com.fasterxml.jackson.annotation.JsonCreator > import groovy.transform.CompileStatic > import groovy.transform.ToString > @ToString > @CompileStatic > class TestGroovyNewVersion { > private enum AddressInd { > REGISITERED_ADD('Registered add'), TRADING_ADD('Trading add'), > DELIVERY_ADD('Delivery add'), INVOICE_ADD('Invoice add') > protected String addressInd > private AddressInd(final String addressInd) { > this.addressInd = addressInd > } > @JsonCreator > static AddressInd create(final String addressInd) { > AddressInd indicator = values().find{ it.addressInd == addressInd } > if (!indicator) > { > throw new IllegalArgumentException() > } > indicator > } > } > String ref > String companyNo > String name > }{code} > > I would prefer to not make code changes in my code as I have similar at too > many places at same time I don't want to use older version of groovy lib. Pls > look into matter and suggest a solution or fix this issue if it is a possible > bug in groovy 2.5.6. > -- This message was sent by Atlassian JIRA (v7.6.3#76005)