[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] AspectJ + Scala

hi daniel,

> Does anyone have any experience using AspectJ in conjuction with Scala,
> particularly for writing Eclipse plugins?
> 
> I am doing some EMF extension development;
> I have already found AspectJ to be more or less essential for this
> There are, however, things that would be more natural in something like
> Scala.
> I would like to use both, but I am concerned how they will play together.
> Clearly AspectJ can't compile Scala source,
> but it should be possible to use the generated class files.
> Has anyone actually done this?

as aspectj supports bytecode weaving you could do this.
alas there is a big hurdle when doing the same with scala.

aspectj works very closely on the semantics of the java
language. the java language and the bytecode representation
are very much aligned.

as scala is conceptually far richer than java,
the scala compiler must jump thru quite some loops
to represent those concepts on a bytecode level.

for example scala knows closures and compiles those
closures to inner classes on the bytecode level, also scala
creates multiple bytecode classes for one "scala class".
just call javap on some scalac generated classes and you
will see.

so in the end if you wanted to use aspectj in conjunction with
scala you would have to mentally transform
scala -> bytecode -> java in order to know how to
write your pointcuts and advices for your scala code.

additionally you would have to hope that the
scala-compiler-team does not change the compiler in
such a way that the generated bytecode differs between
2 scalac releases.

in the end what you want is possible but i would strongly
advise against it. a better way would certainly be to subscribe
onto the scala mailing lists and convince the powers there
to offer some AOP hooks into scala.

ciao robertj

> Are there any known issues with this?
> I am also interested in people's experiences
> using AspectJ with other non-java JVM languages.
> 
> thanks
> Daniel
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>