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

Primitive types don't have default values

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-beta-8, 1.0-beta-9, 1.0-beta-10, 1.0-JSR-1, 1.0-JSR-2, 1.0-JSR-3
    • 1.0-JSR-4
    • None
    • None
    • Java 1.5.0_03 on Windows XP

    Description

      In the following code, I declare a member as a primitive type. In Java, it could never have a "null" value, and its value would default to 0. But in Groovy:

      groovy> class Foo

      { public float x }

      groovy> y = new Foo()
      groovy> println y.x
      groovy> go
      null

      So, when the primitive type is boxed (i.e. changed from float to Float), it should also get a default value if it doesn't already have one.

      This is part of GROOVY-683 that somehow got overlooked.

      Attachments

        Activity

          People

            phkim Kim, Pilho
            mcspanky Martin C. Martin
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: