This page is no longer maintained — Please continue to the home page at

Annotations requiring an array literal of other Annotations

No replies
Ryan Richt
Joined: 2011-05-02,
User offline. Last seen 42 years 45 weeks ago.
Dear Group,
I cannot for the life of me figure out how to do this (from Ektorp) in Scala:
    @View(name = "view_1", map = "function(doc) { ... }"),
    @View(name = "view_2", map = "function(doc) { ... }"),
    @View(name = "view_3", map = "function(doc) { ... }")
public class MyRepository {
I found the tip on StackOverflow to for the simpler case of an annotation of other (non annotation) things:
But this fails to compile with: "Illegal start of simple expression" at the site of the declaration of the inner annotation.
@Views(Array(@View(name = "foo", map = "bar"), @View( name = "baz", map = "bat") ))
And if Retronym's paste of the spec is correct, annotations are indeed not listed as valid:

6.24 Constant Expressions Constant expressions are expressions that the Scala compiler can evaluate to a constant. The definition of “constant expression” depends on the platform, but they include at least the expressions of the following forms:

  • A literal of a value class, such as an integer
  • A string literal
  • A class constructed with Predef.classOf (§12.4)
  • An element of an enumeration from the underlying platform
  • A literal array, of the form Array(c1, . . . , cn), where all of the ci ’s are themselves constant expressions
  • An identifier defined by a constant value definition (§4.1).

Any help would be much appreciated!
Ryan Richt Monsanto
This e-mail message may contain privileged and/or confidential information, and is intended to be received only by persons entitled
to receive such information. If you have received this e-mail in error, please notify the sender immediately. Please delete it and
all attachments from any servers, hard drives or any other media. Other use of this e-mail by you is strictly prohibited.

All e-mails and attachments sent and received are subject to monitoring, reading and archival by Monsanto, including its
subsidiaries. The recipient of this e-mail is solely responsible for checking for the presence of "Viruses" or other "Malware".
Monsanto, along with its subsidiaries, accepts no liability for any damage caused by any such code transmitted by or accompanying
this e-mail or any attachment.

The information contained in this email may be subject to the export control laws and regulations of the United States, potentially
including but not limited to the Export Administration Regulations (EAR) and sanctions regulations issued by the U.S. Department of
Treasury, Office of Foreign Asset Controls (OFAC).  As a recipient of this information you are obligated to comply with all
applicable U.S. export laws and regulations.

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland