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

VerifyError appears with boolean method and long or larger primitive type in conditional operand of ternary statement

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.6
    • 1.6.1, 1.7-beta-1
    • None
    • None
    • jdk1.6_12, Vista

      Groovy 1.6 console and Grails 1.1

    Description

       
      // generates error
      class Foo {
          long id // or float or double
          
          boolean bar() {
              return (id ? true : false)
          }
      }
      Foo foo = new Foo()
      

      Running the above will result in the following exception:
      java.lang.VerifyError: (class: Foo, method: bar signature: ()Z) Expecting to find integer on stack

      Declaring id as a float or double will also generate this error; however, if Foo.id is any other type (primitive or otherwise) then the script runs properly. Similarly, explicitly casting Foo.id inside Foo.bar() does not generate this error:

       
      // no VerifyError
      class Foo {
          long id
          
          boolean bar() {
              return (long)id ? true : false
          }
      }
      
      // no VerifyError
      class Foo {
          int id // or boolean or char or Long, etc.
          
          boolean bar() {
              return id ? true : false
          }
      }
      

      Attachments

        Activity

          People

            roshandawrani Roshan Dawrani
            hippyod Evan Slatis
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: