Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Weaving into Java System Libs

In case of a "normale" return there should be no difference between "after" and "after return". In fact, in my example there is no difference, thisJoinPoint.getTarget() is still null! Andy ideas?

Best Nikolas

Andrew Eisenberg schrieb:
Have you tried using after returning advice?  That should be able to
capture the result of a 'new' call.

On Thu, Jul 30, 2009 at 4:20 AM, Nikolas
Nehmer<nnehmer@xxxxxxxxxxxxxxxxxxxx> wrote:
Hi,

1st problem solved. There was a little error in the pointcut! Sorry for
that.

But there still is an open question. Why is the thisJoinPoint.getTarget in
the following example always null? And yes, I double checked...it's not only
the toString() method that delivers null results ;-)

pointcut init() : call(new()) && !within(TestAspect) && !within(setup..*);
after(): init() {
  System.out.println(thisJoinPoint.getTarget());
}
    Cheers,
Nikolas

Nikolas Nehmer schrieb:
Hi,

I'm wondering if it is possible to monitor every constructor call in my
application e.g. including calls to java.lang.*. In my understanding, this
would only imply weaving code into "my" application and not into java system
libs.

But if I use something like:
pointcut init() : call(new())...;
constructor calls within myApp are aspectized but constructor calls to
system libs are not. I understand that an initialization advice only works
in myApp but using call-advice should also work for system lib calls? Am I
wrong?

Best Nikolas

Alex Villazon schrieb:
Hi,
 In fact ajc does not restrict weaving into the class library, but the
resulting code may break the VM bootstrapping or crash the VM...

For LTW, you could implement your own weaving agent using the
WeavingAdaptor, and use


 bcelWorld.performExtraConfiguration("weaveJavaPackages=true,weaveJavaxPackages=true");

However, this solution does not apply if you need to weave classes loaded
during VM bootstrapping.... and before the agent starts instrumentation.

Be aware that you could easily have problems of infinite recursions if
your advices use woven classes of the Java class library.

These problems are discussed in pdf
<http://www.inf.unisi.ch/projects/ferrari/Publications_files/pppj08.pdf>

Hope that helps.

Cheers,

Alex


On Jul 27, 2009, at 11:58 AM, Nikolas Nehmer wrote:

Even LTW seems to stop at the boundary to the java system libs. How
exactly did you solve that problem?

cheers Nikolas

FraGMenT schrieb:
As far as I know you are looking for the Load-Time Weaving. I had more
or less the same problem and solved it with LTW. I'm afraid you cannot
weave system libraries at compile time.

Hope this helped you.

2009/7/22 Nikolas Nehmer <nnehmer@xxxxxxxxxxxxxxxxxxxx
<mailto:nnehmer@xxxxxxxxxxxxxxxxxxxx>
<mailto:nnehmer@xxxxxxxxxxxxxxxxxxxx>>

  Hi there,

  I'm new to AOP and AspectJ in particular. Today I started
  exploring some simple HelloWorld style example aspects. As far as
  I can tell, everything seems to work smoothly. But currently I
  have one issue. Is there any chance of weaving bytecode into the
  java systems libraries (e.g. java.lang.System,…) by “exploiting”
  AspectJ? I’m trying to circumvent writing my own bytecode
  instrumentation component. Any ideas?

  Best regards,

  Nick

  _______________________________________________
  aspectj-users mailing list
  aspectj-users@xxxxxxxxxxx <mailto:aspectj-users@xxxxxxxxxxx>
  https://dev.eclipse.org/mailman/listinfo/aspectj-users



------------------------------------------------------------------------

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx <mailto:aspectj-users@xxxxxxxxxxx>
https://dev.eclipse.org/mailman/listinfo/aspectj-users

--
Dipl.-Inf. Nikolas Nehmer,
Dept. of Computer Science. University of Kaiserslautern
P.O. Box 3049, 67653 Kaiserslautern, Germany.
room 36/308, phone: +49 (0) 631 - 205 2644, fax: +49 (0) 631 - 205 3299
mail: nnehmer@xxxxxxxxxxxxxxxxxxxx <mailto:nnehmer@xxxxxxxxxxxxxxxxxxxx>

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx <mailto:aspectj-users@xxxxxxxxxxx>
https://dev.eclipse.org/mailman/listinfo/aspectj-users
------------------------------------------------------------------------

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

--
Dipl.-Inf. Nikolas Nehmer,
Dept. of Computer Science. University of Kaiserslautern P.O. Box 3049, 67653
Kaiserslautern, Germany.
room 36/308, phone: +49 (0) 631 - 205 2644, fax: +49 (0) 631 - 205 3299
mail: nnehmer@xxxxxxxxxxxxxxxxxxxx

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

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


--
Dipl.-Inf. Nikolas Nehmer,
Dept. of Computer Science. University of Kaiserslautern P.O. Box 3049, 67653 Kaiserslautern, Germany.
room 36/308, phone: +49 (0) 631 - 205 2644, fax: +49 (0) 631 - 205 3299
mail: nnehmer@xxxxxxxxxxxxxxxxxxxx



Back to the top