You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2019/05/01 14:00:00 UTC

[jira] [Commented] (GROOVY-9007) Getting java.lang.NoSuchFieldError with groovy version 2.5.6

    [ https://issues.apache.org/jira/browse/GROOVY-9007?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16831012#comment-16831012 ] 

Paul King commented on GROOVY-9007:
-----------------------------------

[~emilles] those changes definitely seem to fix a few issues we have with the current code. I don't believe it covers some of the non-closure cases the previous code was trying to handle but I am inclined to merge your changes and then fix from there. I didn't have test cases for all of the cases - there were some Grails/Micronaut inspired tests that I was running by hand but they weren't standalone. I'll endeavour to get some standalone tests to cover those cases.

> 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
>            Priority: Critical
>
> 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)