You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2017/09/19 11:38:00 UTC

[jira] [Commented] (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:comment-tabpanel&focusedCommentId=16171555#comment-16171555 ] 

Paul King commented on GROOVY-8323:
-----------------------------------

It isn't supported currently - curly braces are for closures in Groovy. In the Parrot parser, we were able to relax those restrictions around particular forms of Java-style array declarations. I am not sure whether it might be possible for the Parrot parser to handle this case also - we'd have to explore that further.

> @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:
> 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



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