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

Eric Milles resolved GROOVY-9524.
---------------------------------
    Fix Version/s: 4.0.0-alpha-3
       Resolution: Fixed

> VerifyError when referencing a private enum method
> --------------------------------------------------
>
>                 Key: GROOVY-9524
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9524
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation
>    Affects Versions: 2.5.11
>            Reporter: Mauro Molinari
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 4.0.0-alpha-3
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> Very similar to GROOVY-9523, but here full static compilation is used.
> Consider this Groovy class:
> {code:groovy}
> package test64
> import groovy.transform.CompileStatic
> @CompileStatic
> class Test64 {
>       static enum ShippingAddressSynchType {
>               ACCOUNTING {
>                       @Override
>                       void synch(Test64 customer) {
>                               truncate('foo', 2)
>                       }
>               };
>               void synch(Test64 customer) { }
>               private String truncate(String input, int maxLength) {
>                       if(!input)
>                               return input
>                       if(input.length() > maxLength)
>                               input = input[0..maxLength - 1]
>                       return input
>               }
>       }
> }
> {code}
> and a Java class to run it:
> {code:java}
> package test64;
> import test64.Test64.ShippingAddressSynchType;
> public class Test64Main {
>       public static void main(String[] args) {
>               Test64 t = new Test64();
>               ShippingAddressSynchType.ACCOUNTING.synch(t);
>       }
> }
> {code}
> If you run this code, you'll get:
> {noformat}
> Exception in thread "main" java.lang.VerifyError: Bad type on operand stack
> Exception Details:
>   Location:
>     test64/Test64$ShippingAddressSynchType$1.synch(Ltest64/Test64;)V @1: 
> invokevirtual
>   Reason:
>     Type 'test64/Test64$ShippingAddressSynchType$1' (current frame, stack[0]) 
> is not assignable to 'groovy/lang/Closure'
>   Current Frame:
>     bci: @1
>     flags: { }
>     locals: { 'test64/Test64$ShippingAddressSynchType$1', 'test64/Test64' }
>     stack: { 'test64/Test64$ShippingAddressSynchType$1' }
>   Bytecode:
>     0x0000000: 2ab6 0036 c000 0412 3805 b800 3c57 b1  
>         at test64.Test64$ShippingAddressSynchType.<clinit>(Test64.groovy)
>         at test64.Test64Main.main(Test64Main.java:9)
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to