Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[ajdt-dev] AspectJ + Scala

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

Attachment: testAspect.tar.gz
Description: application/compressed-tar


Back to the top