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

Can't assign to native types in Groovy Beans

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-beta-8
    • 1.0-beta-9
    • None
    • None
    • Windows XP Pro under Cygwin

    Description

      If I create a GroovyBean with a "float" field then try to assign to it, I get an error:

      /cygdrive/c/Develop> groovysh
      Lets get Groovy!
      ================
      Version: 1.0-beta-8 JVM: 1.4.2_06-b03
      Type 'exit' to terminate the shell
      Type 'help' for command help
      Type 'go' to execute the statements

      groovy> class Foo

      { float x }

      groovy> y = new Foo()
      groovy> println y.x
      groovy> go
      null # How is this possible???

      groovy> y.x = 10
      groovy> go
      Exception: No such property: x for class: Foo. Reason: groovy.lang.GroovyRuntimeException: Cannot set property: x reason: null
      groovy.lang.MissingPropertyException: No such property: x for class: Foo. Reason: groovy.lang.GroovyRuntimeException: Cannot set pro
      ull
      at groovy.lang.MetaClass.setProperty(MetaClass.java:996)
      ....

      No such property: x for class: Foo. Reason: groovy.lang.GroovyRuntimeException: Cannot set property: x reason: null

      If Groovy Beans can't take native types, only their object wrappers, then I should get an error in the class definition, no?

      • Martin

      Attachments

        1. PrimitivePropertyBug.groovy
          1 kB
          Kim, Pilho
        2. patchfile.txt
          3 kB
          Kim, Pilho

        Activity

          People

            guillaume Guillaume Sauthier
            mcspanky Martin C. Martin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: