You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2022/05/22 16:07:00 UTC

[jira] [Updated] (GROOVY-1242) Cant have a class method returning an array of complex type

     [ https://issues.apache.org/jira/browse/GROOVY-1242?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eric Milles updated GROOVY-1242:
--------------------------------
    Labels: ClassFormatError  (was: )

> Cant have a class method returning an array of complex type 
> ------------------------------------------------------------
>
>                 Key: GROOVY-1242
>                 URL: https://issues.apache.org/jira/browse/GROOVY-1242
>             Project: Groovy
>          Issue Type: Bug
>          Components: class generator
>    Affects Versions: 1.0-JSR-5
>         Environment: Windows XP/SP2 + jdk1.5.0_06
>            Reporter: Ryan Harris
>            Assignee: Jochen Theodorou
>            Priority: Blocker
>              Labels: ClassFormatError
>             Fix For: 1.0-JSR-6
>
>
> 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. 



--
This message was sent by Atlassian Jira
(v8.20.7#820007)