Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] add aspect without source

thanks!  that was it.

Wes Isberg wrote:
See "privileged" aspects in the programming guide.

Wes


Mike Liu wrote:

Thanks for your help.  I guess my problem is primary dealing with accessing variables and methods that are private to some existing classes.  I'll keep digging away on those manuals.

Jim Hugunin wrote:

Here's a very short tutorial on how to use ajc to weave into existing .class files.
===============================================================
Step 1. Make hello.jar

File Hello.java
--------------------
public class Hello {
    public static void main(String[] args) {
        System.out.println("hello world");
    }
}
--------------------
> javac Hello.java
> jar -cf hello.jar Hello.class
> java -classpath hello.jar Hello
hello world
===============================================================
Step 2. Weave in a simple tracing aspect

File Trace.aj
--------------------
public aspect Trace {
    before(): execution(* Hello.*(..)) {
        System.out.println("entering: " + thisJoinPoint.toString());
    }
}
--------------------
> ajc Trace.aj -injars hello.jar -outjar trace-hello.jar
> java -classpath trace-hello.jar;<path-to-lib>\aspectjrt.jar Hello
entering: execution(void Hello.main(String[]))
hello world
=================================================================

Does this help?  If you're still have problems please try to provide as concrete and detailed an example as possible to help us understand what you're trying to do.

-Jim


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

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

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

Back to the top