This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Groovy and the fly likes Having multiple @Grab annotations not within a @Grapes annotation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Languages » Groovy
Bookmark "Having multiple @Grab annotations not within a @Grapes annotation" Watch "Having multiple @Grab annotations not within a @Grapes annotation" New topic
Author

Having multiple @Grab annotations not within a @Grapes annotation

David Karr
Greenhorn

Joined: Jan 06, 2008
Posts: 12
I have an existing groovy script with 3 @Grab annotations before the first import, to get dependencies.

I've recently been reading "Making Java Groovy" (on Safari). In chapter 5, I saw the following statement:

"Because a member of a class can only have a single instance of a particular annotation, the @Grapes annotation is used to combine multiple @Grab annotations."

In the context of my script, which works just fine with multiple separate @Grab annotations, this is obviously false, but I imagine this statement likely used to be true. Does anyone know if that's the case?
Jochen Theodorou
Greenhorn

Joined: Dec 13, 2006
Posts: 4
Normally Java does not support multiple annotations of the same type at one element. Extra for this JEP120 was issued (http://openjdk.java.net/jeps/120) -with target Java8. But the openjdk already supports it (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7151010).

Now in Groovy there are limits we are bound to by the JVM and thus we had to have @Grapes. Groovy already supports multiple annotations of the same type for a while, but if it works or not, depends on your JVM
 
GeeCON Prague 2014
 
subject: Having multiple @Grab annotations not within a @Grapes annotation