Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] fault injection in byte code:

Thanks wes,
You have given very useful information. I will try out that way.
-Kanthi.


From: Wes Isberg <wes@xxxxxxxxxxxxxx>
Reply-To: aspectj-users@xxxxxxxxxxx
To: aspectj-users@xxxxxxxxxxx
CC: pallavimh@xxxxxxxxx, vravikir@xxxxxxxxx
Subject: Re: [aspectj-users] fault injection in byte code:
Date: Mon, 30 Jun 2003 19:03:52 -0700

vegiraju kanthirekha wrote:
> Hi,
> I was wondering whether I can inject a fault using AspectJ into byte
> code ? I want to inject an exception into a class file. Is that possible
> with AspectJ.

Yes.

Exceptions can be thrown when code runs. If you can specify the target code as a join point using AspectJ pointcuts, then you can throw an exception before or after the join point runs. For example, you can compile your classes with this aspect:

----
aspect A {
  before() : target(MyClass) && call(void doSomething()) {
      throw new Error("Error before MyClass.doSomething runs");
  }
}
----

and when run, any call to an instance of MyClass method
doSomething() will throw an Error before the method executes.

The exception thrown must comply with the exceptions throwable by the join point. In this case, because Error is unchecked, it can be thrown from advice on any join point.

Wes

(btw, It's most helpful if you read the AspectJ documentation
and frame questions in similar terms.)


_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users

_________________________________________________________________
Watch Hallmark. Enjoy cool movies. http://server1.msn.co.in/sp03/hallmark/index.asp Win hot prizes!



Back to the top