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 2022/02/03 22:35:01 UTC

[jira] [Closed] (GROOVY-10191) NoSuchMethodError during static field inlining is not caught, unlike NoSuchFieldException

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

Paul King closed GROOVY-10191.
------------------------------

> NoSuchMethodError during static field inlining is not caught, unlike NoSuchFieldException
> -----------------------------------------------------------------------------------------
>
>                 Key: GROOVY-10191
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10191
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 2.5.14, 3.0.8, 4.0.0-alpha-3
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 4.0.0-beta-1, 3.0.9, 2.5.16
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> This is a bit hard to reproduce.  We have a situation something like this:
> {code:groovy}
> class Main {
>   private static final x = Type.CONST
> }
> {code}
> Then, this is defined in a separate project or jar:
> {code:groovy}
> class Type {
>   public static final CONST = 'value'
>   static {
>     // some other class initialization that is failing due to classpath ordering
>   }
> }
> {code}
> When {{Verifier}} tries to inline the initial value for {{x}}, {{ExpressionUtils}} falls into the non-primary type path ({{Type}} is in separate project or jar).  We had a situation where we had two versions of a 3rd-party library on the classpath and it ended up throwing {{NoSuchMethodError}} when the lower version was picked up.  This can be simulated by adding {{throw new NoSuchMethodError()}} to the static initializer of {{Type}}.
> https://github.com/apache/groovy/blob/d7684d101d64ca6da28fdb8069ea92475d011168/src/main/java/org/apache/groovy/ast/tools/ExpressionUtils.java#L236



--
This message was sent by Atlassian Jira
(v8.20.1#820001)