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

Cant have a class method returning an array of complex type

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 1.0-JSR-5
    • 1.0-JSR-6
    • class generator
    • Windows XP/SP2 + jdk1.5.0_06

    Description

      Here is a script returning a Caught: java.lang.ClassFormatError: Illegal field name "class$Person_]" in class PersonServiceImpl

      class Person {
      @Property String firstName
      @Property int id

      String toString() {"${firstName} has id ${id}"}
      }

      class PersonServiceImpl {
      private List persons = new ArrayList()

      PersonServiceImpl()

      { persons = [ new Person(firstName:"Guillaume", id:1), new Person(firstName:"Jochen", id:2), new Person(firstName:"Dierk", id:3), new Person(firstName:"Graeme", id:4)] }

      Person[] getPersons()

      { return persons.toArray(new Person[persons.size()]) }

      Person findPerson(int id)

      { return persons[id] }

      }

      def ps = new PersonServiceImpl()
      println ps.findPerson(0)

      NOTA1: Removung the Person[] getPersons() {} blocks makes the script working
      NOTA2: Replacing the Person[] type by a native type (int for example) makes things going smooth.

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            galleon Ryan Harris
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: