You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Matthias Albert (JIRA)" <ji...@apache.org> on 2017/09/19 11:12:00 UTC
[jira] [Updated] (GROOVY-8323) @XmlSeeAlso annotation using Java
syntax leads to groovy compiler error
[ https://issues.apache.org/jira/browse/GROOVY-8323?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Matthias Albert updated GROOVY-8323:
------------------------------------
Description:
According to Oracle Java documentation, it should be possible to use JAXB with the @XmlSeeAlso annotaion as follows:
{quote}import javax.xml.bind.annotation.XmlSeeAlso
@XmlSeeAlso({Dog.class,Cat.class})
class Animal {}
class Dog extends Animal {}
class Cat extends Animal {}
{quote}
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
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:
> {quote}import javax.xml.bind.annotation.XmlSeeAlso
> @XmlSeeAlso({Dog.class,Cat.class})
> class Animal {}
> class Dog extends Animal {}
> class Cat extends Animal {}
> {quote}
> 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
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)