Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.5.11
-
None
Description
Very similar to GROOVY-9523, but here full static compilation is used.
Consider this Groovy class:
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 } } }
and a Java class to run it:
package test64; import test64.Test64.ShippingAddressSynchType; public class Test64Main { public static void main(String[] args) { Test64 t = new Test64(); ShippingAddressSynchType.ACCOUNTING.synch(t); } }
If you run this code, you'll get:
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)
Attachments
Issue Links
- is related to
-
GROOVY-10197 java.lang.VerifyError using property inside enum's constant
- Closed