Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-9524

VerifyError when referencing a private enum method

    XMLWordPrintableJSON

Details

    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

          Activity

            People

              emilles Eric Milles
              mauromol Mauro Molinari
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h