This page is no longer maintained — Please continue to the home page at www.scala-lang.org

'Not-Constant' Annotation Parameters using JDO in Scala 2.8

2 replies
Nicolas Gramlich
Joined: 2010-01-30,
User offline. Last seen 2 years 39 weeks ago.
Hi,

I am recently facing the following problem when trying to use the JDO annotations with the new syntax of Scala 2.8 (2.8.0.r20733-b20100130020228)
(various sources indicate it was possible in < 2.8)
#################
import javax.jdo.annotations.{IdGeneratorStrategy, PrimaryKey, Persistent, PersistenceCapable, IdentityType}

@PersistenceCapable(identityType = IdentityType.APPLICATION)
class TestObject(@PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) val key : Long) {

}
#################

This results in the following compile-time error. Eclipse indicates:
#################
"annotation argument needs to be a constant; found: IdGeneratorStrategy{<null>}.IDENTITY{<null>}"
#################

Looking up the class I can see that it actually is a 'constant enum':
http://db.apache.org/jdo/api21/apidocs/javax/jdo/annotations/IdGeneratorStrategy.html
#################
IDENTITY
public static final IdGeneratorStrategy IDENTITY
#################

So I wonder how to fix this or if there is a workaround know for these kind of issues.

Best Regards,
Nicolas

Nicolas Gramlich 2
Joined: 2010-02-02,
User offline. Last seen 42 years 45 weeks ago.
Re: 'Not-Constant' Annotation Parameters using JDO in Scala 2.8

From Miles Sabin To Me:
##############
Hi Nicolas,

This look like another instance of this compiler bug,

https://lampsvn.epfl.ch/trac/scala/ticket/2764

Cheers,
Miles
##############

--> Problem identified.

manojo
Joined: 2008-12-22,
User offline. Last seen 3 years 3 weeks ago.
Re: 'Not-Constant' Annotation Parameters using JDO in Scala 2.
Is there any workaround to this at the moment (apart from working with 2.7 or having Java files for entity declarations) ?

Cheers,
Manohar

On Tue, Feb 2, 2010 at 6:56 PM, Nicolas Gramlich <plusminus [at] anddev [dot] org> wrote:

From Miles Sabin To Me:
##############
Hi Nicolas,

This look like another instance of this compiler bug,

 https://lampsvn.epfl.ch/trac/scala/ticket/2764

Cheers,
Miles
##############

--> Problem identified.
--
View this message in context: http://old.nabble.com/%27Not-Constant%27-Annotation-Parameters-using-JDO-in-Scala-2.8-tp27382440p27423690.html
Sent from the Scala - User mailing list archive at Nabble.com.


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