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

compile time annotation processing tool for Scala?

3 replies
Daniel Mahler
Joined: 2009-05-25,
User offline. Last seen 1 year 24 weeks ago.

I need to interface to a Java library that provides custom annotations
and AnnotationProcessor & AnnotationProcessorFactory
implementations to process them.
If you interface to it from java you run apt or "javac -processor".
How would you process such annotations in scala code.
It seems that this would be a recurring problem.
I would do this by writing a compiler plugin that can
apply a AnnotationProcessor & AnnotationProcessorFactory
to annotations in Scala sources.
Has anybody done this? Or is there a better way?

thanks
Daniel

rytz
Joined: 2008-07-01,
User offline. Last seen 45 weeks 5 days ago.
Re: compile time annotation processing tool for Scala?
The Scala compiler does not support java Annotation Processors.It would need to map scala declarations to the interfaces incom.sun.mirror.declarations somehow,http://java.sun.com/j2se/1.5.0/docs/guide/apt/mirror/com/sun/mirror/declaration/package-summary.html
I don't think anybody is working on that.
Lukas

On Tue, Jan 5, 2010 at 23:48, Daniel Mahler <dmahler [at] gmail [dot] com> wrote:
I need to interface to a Java library that provides custom annotations
and AnnotationProcessor & AnnotationProcessorFactory
implementations to process them.
If you interface to it from java you run apt or "javac -processor".
How would you process such annotations in scala code.
It seems that this would be a recurring problem.
I would do this by writing a compiler plugin that can
apply a AnnotationProcessor & AnnotationProcessorFactory
to annotations in Scala sources.
Has anybody done this? Or is there a better way?

thanks
Daniel

Daniel Mahler
Joined: 2009-05-25,
User offline. Last seen 1 year 24 weeks ago.
Re: compile time annotation processing tool for Scala?

Hi Lukas,

Is this also true of javax.annotation.processing.Processor?

thanks
Daniel

On 1/6/10, Lukas Rytz wrote:
> The Scala compiler does not support java Annotation Processors.
> It would need to map scala declarations to the interfaces in
> com.sun.mirror.declarations somehow,
> http://java.sun.com/j2se/1.5.0/docs/guide/apt/mirror/com/sun/mirror/decl...
>
> I don't think anybody is working on that.
>
> Lukas
>
>
> On Tue, Jan 5, 2010 at 23:48, Daniel Mahler wrote:
>
>> I need to interface to a Java library that provides custom annotations
>> and AnnotationProcessor & AnnotationProcessorFactory
>> implementations to process them.
>> If you interface to it from java you run apt or "javac -processor".
>> How would you process such annotations in scala code.
>> It seems that this would be a recurring problem.
>> I would do this by writing a compiler plugin that can
>> apply a AnnotationProcessor & AnnotationProcessorFactory
>> to annotations in Scala sources.
>> Has anybody done this? Or is there a better way?
>>
>> thanks
>> Daniel
>>
>

rytz
Joined: 2008-07-01,
User offline. Last seen 45 weeks 5 days ago.
Re: compile time annotation processing tool for Scala?
I don't know, I'm actually completely unfamiliar with Java'sannotation processors..
Cheers: Lukas

On Wed, Jan 6, 2010 at 17:50, Daniel Mahler <dmahler [at] gmail [dot] com> wrote:
Hi Lukas,

Is this also true of javax.annotation.processing.Processor?

thanks
Daniel

On 1/6/10, Lukas Rytz <lukas [dot] rytz [at] epfl [dot] ch> wrote:
> The Scala compiler does not support java Annotation Processors.
> It would need to map scala declarations to the interfaces in
> com.sun.mirror.declarations somehow,
> http://java.sun.com/j2se/1.5.0/docs/guide/apt/mirror/com/sun/mirror/declaration/package-summary.html
>
> I don't think anybody is working on that.
>
> Lukas
>
>
> On Tue, Jan 5, 2010 at 23:48, Daniel Mahler <dmahler [at] gmail [dot] com> wrote:
>
>> I need to interface to a Java library that provides custom annotations
>> and AnnotationProcessor & AnnotationProcessorFactory
>> implementations to process them.
>> If you interface to it from java you run apt or "javac -processor".
>> How would you process such annotations in scala code.
>> It seems that this would be a recurring problem.
>> I would do this by writing a compiler plugin that can
>> apply a AnnotationProcessor & AnnotationProcessorFactory
>> to annotations in Scala sources.
>> Has anybody done this? Or is there a better way?
>>
>> thanks
>> Daniel
>>
>

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