Skip to main content

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

I can only assume it is the way you are building it.  I took your
pieces and did as follows and it worked for me:

javac CallJava.java -d output

scalac CallScala.scala -d output

ajc -inpath output TestAspect.aj -showWeaveInfo
Join point 'method-execution(void CallScala.call())' in Type
'CallScala' (CallScala.scala:3) advised by before advice from
'TestAspect' (TestAspect.aj:2)
Join point 'method-execution(void CallJava.call())' in Type 'CallJava'
(CallJava.java:3) advised by before advice from
'TestAspect'(TestAspect.aj:2)

scalac Test.scala

java -classpath
"\scala-2.8.0.final\lib\scala-library.jar;..\lib\aspectjrt.jar;." Test
Start application
Before call aspect !!
Scala called
Before call aspect !!
Java called

Andy

On 26 October 2010 06:57, Romain <romain.reuillon@xxxxxxxxx> wrote:
> (...I figured this message was posted to the wrong list [ajdt-dev] so I
> repost it here, sorry if you receive that multiple times....)
>
> Hi all,
>
> I am having a problem using scala and aspectj together with static
> weaving (compile time weaving).
>
> You will find a test project illustrating my point in attachment. To
> execute it:
>
> mvn install
> cd scala
> mvn assembly:assembly
> java -jar target/scala-1.0-SNAPSHOT-jar-with-dependencies.jar
>
> Result is:
>
> Start application
> Scala called
> Before call aspect !!
> Java called
>
> The "Before call aspect !!" is not executed before the call of the scala
> method.
>
> The aspect is very simple:
>
> public aspect TestAspect {
>        before() : execution(* *(..)) {
>                System.out.println("Before call aspect !!");
>        }
> }
>
> And the java class and scala class too:
> public class CallJava {
>    public void call() {
>        System.out.println("Java called");
>    }
> }
>
> class CallScala {
>  def call() = {
>    println("Scala called")
>  }
> }
>
>
> And last, the main:
>
> object Test {
>  def main(args: Array[String]): Unit = {
>    println("Start application")
>
>    val call = new CallScala
>    call.call
>
>    val callJ = new CallJava
>    callJ.call
>  }
> }
>
> Do you have any idea why my aspect works with fine with java, but don't
> with scala?
>
> cheers,
> Romain
>
>
>
> _______________________________________________
> ajdt-dev mailing list
> ajdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/ajdt-dev
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>


Back to the top