Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-360

Unable to use the default hashmap constructor for groovy classes

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 1.0
    • 0.9.1252
    • Groovy
    • None
    • Groovy script

    Description

      Unable to use the default hashmap constructor (Syntaxt : new Person(name:"Martin", firstName:"John") ).

      This script show differrent result in groovy (JSR-06) from XWiki.
      The script:

      class Person

      { def Personne(pName, pFN, pAge, pFeet, pOld) { name = pName firstname = pFN age = pAge old = pOld }

      String name
      String firstname
      int age
      int feet
      int old
      }

      mytable=[new Person(name:"Georges",firstname:"Arthur",age:34,feet:2,old:4),
      new Person(name:"Schputz",firstname:"Lolo",age:32,feet:2,old:4),
      new Person(name:"Moran",firstname:"Marcel",age:11,feet:3,old:5),
      new Person(name:"Flutor",firstname:"Jacques",age:23,feet:2,old:8)];

      println mytable.size() //
      for ( myi in mytable)
      {
      println myi.firstname
      }

      Result in grooyv
      4
      Arthur
      Lolo
      Marcel
      Jacques

      Result in XWiki
      4 null null null null

      I can get around by using an explicit constructor, but its quite verbose.

      Attachments

        Activity

          People

            jvdrean Jean-Vincent Drean
            pkernevez Philippe Kernevez
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: