Marius Danciu | 5 Oct 11:25
Gravatar

annotations again

Hi,

Maybe this topic has been discussed quite a few time by now but I have a few question. Is is so that Scala annotations are not translated to Java annotations to be accessible at runtime using Java reflection?

if I have

class MyField extends scala.Annotation

class A {

<at> MyField
var a: Strimg = _

}

compiles just fine but of course at runtime if I obtain the the field's annotations java.lang.reflect.Field#getDeclaredAnnotations I get nothing.

Br's,
Marius
Alex Boisvert | 5 Oct 14:34
Favicon

Re: annotations again

Scala doesn't support defining runtime annotations at the moment.  You must define the annotation using a Java class if you want runtime retention.

(There's an example in Chapter 29 of the Scala book if you happen to have it)

alex


On Sun, Oct 5, 2008 at 2:26 AM, Marius Danciu <marius.danciu <at> gmail.com> wrote:
Hi,

Maybe this topic has been discussed quite a few time by now but I have a few question. Is is so that Scala annotations are not translated to Java annotations to be accessible at runtime using Java reflection?

if I have

class MyField extends scala.Annotation

class A {

<at> MyField
var a: Strimg = _

}

compiles just fine but of course at runtime if I obtain the the field's annotations java.lang.reflect.Field#getDeclaredAnnotations I get nothing.

Br's,
Marius


Gmane