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

Paul King updated GROOVY-8323:
------------------------------
    Description: 
According to Oracle Java documentation, it should be possible to use JAXB with 
the @XmlSeeAlso annotaion as follows:
{code}
import javax.xml.bind.annotation.XmlSeeAlso
@XmlSeeAlso({Dog.class,Cat.class})
 class Animal {}
 class Dog extends Animal {}
 class Cat extends Animal {}
{code}

Running a groovy script containing the above code, results in a compiler error 
message:
{noformat}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
<subdir>\myscript.groovy: 3: expecting '}', found ',' @ line 3, column 23.
   @XmlSeeAlso({Dog.class,Cat.class})
{noformat}

Apparently, the class arguments are expected to be enclosed in square brackets 
[...].

My main question is:
It is possible, that this valid java code cannot be compiled by the groovy 
compiler?

My background is: 
I am writing a groovy script that uses java files generated by the xjc compiler 
from an XML schema file. They cannot be modified manually. I would like to 
compile these files by the groovy compiler using a CompilerConfiguration and 
adding 'java' to the scriptExtensions.

Thanks in advance.
Matthias


  was:
According to Oracle Java documentation, it should be possible to use JAXB with 
the @XmlSeeAlso annotaion as follows:

import javax.xml.bind.annotation.XmlSeeAlso
@XmlSeeAlso({Dog.class,Cat.class})
 class Animal {}
 class Dog extends Animal {}
 class Cat extends Animal {}

Running a groovy script containing the above code, results in a compiler error 
message:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
<subdir>\myscript.groovy: 3: expecting '}', found ',' @ line 3, column 23.
   @XmlSeeAlso({Dog.class,Cat.class})


Apparently, the class arguments are expected to be enclosed in square brackets 
[...].

My main question is:
It is possible, that this valid java code cannot be compiled by the groovy 
compiler?

My background is: 
I am writing a groovy script that uses java files generated by the xjc compiler 
from an XML schema file. They cannot be modified manually. I would like to 
compile these files by the groovy compiler using a CompilerConfiguration and 
adding 'java' to the scriptExtensions.

Thanks in advance.
Matthias



> @XmlSeeAlso annotation using Java syntax leads to groovy compiler error
> -----------------------------------------------------------------------
>
>                 Key: GROOVY-8323
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8323
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 2.4.12
>            Reporter: Matthias Albert
>
> According to Oracle Java documentation, it should be possible to use JAXB 
> with the @XmlSeeAlso annotaion as follows:
> {code}
> import javax.xml.bind.annotation.XmlSeeAlso
> @XmlSeeAlso({Dog.class,Cat.class})
>  class Animal {}
>  class Dog extends Animal {}
>  class Cat extends Animal {}
> {code}
> Running a groovy script containing the above code, results in a compiler 
> error message:
> {noformat}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> <subdir>\myscript.groovy: 3: expecting '}', found ',' @ line 3, column 23.
>    @XmlSeeAlso({Dog.class,Cat.class})
> {noformat}
> Apparently, the class arguments are expected to be enclosed in square 
> brackets [...].
> My main question is:
> It is possible, that this valid java code cannot be compiled by the groovy 
> compiler?
> My background is: 
> I am writing a groovy script that uses java files generated by the xjc 
> compiler from an XML schema file. They cannot be modified manually. I would 
> like to compile these files by the groovy compiler using a 
> CompilerConfiguration and adding 'java' to the scriptExtensions.
> Thanks in advance.
> Matthias



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to