Groovy
  1. Groovy
  2. GROOVY-4741

VerifyError: Expecting to find integer on stack

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 1.8-rc-3
    • Fix Version/s: 1.8-rc-4
    • Component/s: Compiler
    • Labels:
      None

      Description

      Hi, I have the same issue as in GROOVY-4587.

      For the inputs

      [0.0], [], [], [543]
      

      the function-code below does throw an Exception which can be fixed by changing

      if (ReWK < 0) {
      

      to

      if (((int)ReWK) < 0) {
      

      Seems like a bug to me or am I doing it wrong? Various other inputs run fine.

      Gesamtbetrag,Direktabzug,Prozent,Einzelbetrag->                                                               
      
      def int ReWK = 0
      def arrAbzWK = []; 
      
      Gesamtbetrag.eachWithIndex {
                                                                  
      	it, index ->                                                                                                          
         
      	if(Gesamtbetrag[index] > 0){ 
      
      		                                               
              	if(Prozent[index] != 0 && Prozent[index] != null) {  
      			ReWK = Math.ceil( Gesamtbetrag[index] * (100 - Prozent[index]) / 100 ) 
      
      		} else if (Direktabzug[index] > 0 ) {           
               
      			ReWK = Math.ceil( Gesamtbetrag[index] - Direktabzug[index] )    
               
      			if (ReWK < 0) { 
      				ReWK = 0
      			}                                     
      
               	} 
                      else if (Einzelbetrag[index] > 0) { 
      			ReWK = Math.ceil( Einzelbetrag[index] )                                                                           		
      		} else {			
      			ReWK = 0	
      		}                                                                                     
         	}                                                                                  
                                                                                                                 
         	arrAbzWK.add(ReWK)    
                                                                                     
      }
      
      return arrAbzWK 
      
      1. gmaven-1.3.tgz
        2.43 MB
        David Hansmann
      2. test.groovy
        0.9 kB
        David Hansmann

        Activity

        Hide
        Jochen Theodorou added a comment -

        this sounds indeed very like that the issue you mentioned. To really fix that bug I need a runnable test case. The example you gave does not look complete

        Show
        Jochen Theodorou added a comment - this sounds indeed very like that the issue you mentioned. To really fix that bug I need a runnable test case. The example you gave does not look complete
        Hide
        David Hansmann added a comment -

        I'll try to provide one if I find the time - unfortunately this is only a small function in a rather complex construct of groovy-scripts running in a java-environment (hundreds of formulas using hundreds of functions doing german tax calculation), so there might be many factors at work.

        As a side note: 1.8.0-rc-3 seems to work very well, but I had to make a custom gmaven version using the good (but outdated)

        http://www.yeap.de/blog2.0/archives/233-Build-Groovy++-with-Maven.html

        and gmaven-1.3. Is the project abandoned or so you know anybody who might wan to check the stuff in? I could send a tar file.

        Greetings,

        David

        Show
        David Hansmann added a comment - I'll try to provide one if I find the time - unfortunately this is only a small function in a rather complex construct of groovy-scripts running in a java-environment (hundreds of formulas using hundreds of functions doing german tax calculation), so there might be many factors at work. As a side note: 1.8.0-rc-3 seems to work very well, but I had to make a custom gmaven version using the good (but outdated) http://www.yeap.de/blog2.0/archives/233-Build-Groovy++-with-Maven.html and gmaven-1.3. Is the project abandoned or so you know anybody who might wan to check the stuff in? I could send a tar file. Greetings, David
        Hide
        Guillaume Delcroix added a comment -

        I'm looking forward a reproducable example. That's likely something related to our int primitive optimizations. That would really be great if we could reproduce the problem, in order to fix the underlying issue.

        As for GMaven, well, it's not actively developed these days.
        If you're willing to contribute to it, that would be great, for those relying on GMaven.

        Show
        Guillaume Delcroix added a comment - I'm looking forward a reproducable example. That's likely something related to our int primitive optimizations. That would really be great if we could reproduce the problem, in order to fix the underlying issue. As for GMaven, well, it's not actively developed these days. If you're willing to contribute to it, that would be great, for those relying on GMaven.
        Hide
        David Hansmann added a comment -

        Example code

        Show
        David Hansmann added a comment - Example code
        Hide
        David Hansmann added a comment -

        gmaven-1.3 with gmaven-runtime-1.8 so providerSelection 1.8 works

        Show
        David Hansmann added a comment - gmaven-1.3 with gmaven-runtime-1.8 so providerSelection 1.8 works
        Hide
        David Hansmann added a comment -

        Seems to be easily reproducible, I attached the example and wish you good luck hunting the bug down.

        As for the gmaven stuff: I attached my full .tgz, can you assign it to somebody who can check the stuff in? I am not familiar how the process here works and don't want to create an issue in the GMaven-Jira if it's abandoned.

        Show
        David Hansmann added a comment - Seems to be easily reproducible, I attached the example and wish you good luck hunting the bug down. As for the gmaven stuff: I attached my full .tgz, can you assign it to somebody who can check the stuff in? I am not familiar how the process here works and don't want to create an issue in the GMaven-Jira if it's abandoned.
        Hide
        Guillaume Delcroix added a comment -

        Thanks for the code sample!
        I've managed to reduce the failing example to this snippet:

        int a = 0
        [].each { 
            if (a < 0) {}
        }
        

        For the GMaven stuff, could you please open an issue in the GMaven JIRA?
        http://jira.codehaus.org/browse/GMAVEN
        Thanks in advance for that.

        Show
        Guillaume Delcroix added a comment - Thanks for the code sample! I've managed to reduce the failing example to this snippet: int a = 0 [].each { if (a < 0) {} } For the GMaven stuff, could you please open an issue in the GMaven JIRA? http://jira.codehaus.org/browse/GMAVEN Thanks in advance for that.
        Hide
        Guillaume Delcroix added a comment -

        David, as a workaround for now, till we fix the issue, you can use an Integer instead of an int, for the ReWK variable. So you can say Integer ReWK = 0, or simply def ReWK = 0

        Show
        Guillaume Delcroix added a comment - David, as a workaround for now, till we fix the issue, you can use an Integer instead of an int, for the ReWK variable. So you can say Integer ReWK = 0, or simply def ReWK = 0
        Hide
        David Hansmann added a comment -

        Wow, that's a lot shorter than mine. I'll rather not touch my ((int)ReWK) workaround for now as I have to run a full build and tests then, but nice to know!

        I'll open another bug for the GMaven stuff.

        Show
        David Hansmann added a comment - Wow, that's a lot shorter than mine. I'll rather not touch my ((int)ReWK) workaround for now as I have to run a full build and tests then, but nice to know! I'll open another bug for the GMaven stuff.
        Hide
        Jochen Theodorou added a comment -

        works now

        Show
        Jochen Theodorou added a comment - works now

          People

          • Assignee:
            Jochen Theodorou
            Reporter:
            David Hansmann
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development