- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Is it possible to define CDI Stereotypes in Scala?
Tue, 2011-11-29, 20:21
To define a CDI stereotype, i would need to define a runtime
annotation. In scala, i tried this:
@Stereotype
@Target(Array(ElementType.METHOD))
@Retention(RetentionPolicy.RUNTIME)
//... my stereotype annotations
class MyStereotype extends ClassfileAnnotation{}
But got this problem:
" Implementation restriction: subclassing Classfile does not make your
annotation visible at runtime. If that is what you want, you must
write the annotation class in Java."
Is it possible, using scala 2.9.1, to define runtime annotations and,
as consequence, CDI Stereotypes?
Tue, 2011-11-29, 20:47
#2
Re: Is it possible to define CDI Stereotypes in Scala?
"Works well" is relative...
I took me a lot of time and configuration to have scala + jee6 working
(jboss as, maven, eclipse, jrebel, etc ...). Adding a second language
to the same project or splitting projects is something i would not
like to do. But that should be a different post...
And since user defined annotations are the primary form of metadata
definition in Java (specially in JEE 6), not supporting it is a very
questionable decision IMHO. I hope it is not final :)
Thanks for the important clarification, i would suggest adding it
explicitly in the scala annotations page in the tour (
http://www.scala-lang.org/node/106 )
Nope, you need to write your annotation interfaces in Java. Luckily mixed Scala/Java projects work really well, so you can have enums and @interfaces in Java, and everything else in Scala. :)
-0xe1a