Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-dev] Re: aspectj-dev Digest, Vol 48, Issue 3

Simone Gianne,
Thanks for the response.
My objective is to do weaving in asm (http://asm.objectweb.org/) runtime generated classes. I am using a class generation framework called classmock, it uses asm to generate classes at runtime. ClassMock (http://classmock.sourceforge.net/) creates a bytearray with the new class's bytecode and then uses it´s own ClassLoader to define the new class to the JVM, like follows :

package net.sf.classmock;

public class MockClassLoader extends ClassLoader {
   
    public Class defineClass(String name, byte[] b){
        // need to do the weaving here
        return defineClass(name, b, 0, b.length);
    }

}

I need to do the weaving before defining this class to the JVM. 
So I am trying to call the classes that perform the weaving before calling the defineClass Method.
I have already tried using the WeavingURLClassLoader and the org.aspectj.weaver.loadtime.Agent class, but till the current moment, have got no success.
If you have got any tips about how this can be achieved, I would be glad to know.
Thanks in advance.

Emmanuel Santana

2009/3/13 <aspectj-dev-request@xxxxxxxxxxx>
Send aspectj-dev mailing list submissions to
       aspectj-dev@xxxxxxxxxxx

To subscribe or unsubscribe via the World Wide Web, visit
       https://dev.eclipse.org/mailman/listinfo/aspectj-dev
or, via email, send a message with subject or body 'help' to
       aspectj-dev-request@xxxxxxxxxxx

You can reach the person managing the list at
       aspectj-dev-owner@xxxxxxxxxxx

When replying, please edit your Subject line so it is more specific
than "Re: Contents of aspectj-dev digest..."


Today's Topics:

  1. AspectJ load time weaving on runtime generated classes
     (Emmanuel Castro Santana)
  2. AspectJ load time weaving on runtime generated classes
     (Emmanuel Castro Santana)
  3. Re: AspectJ load time weaving on runtime generated        classes
     (Simone Gianni)


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

Message: 1
Date: Thu, 12 Mar 2009 21:52:33 -0300
From: Emmanuel Castro Santana <emmanuel.csantana@xxxxxxxxx>
Subject: [aspectj-dev] AspectJ load time weaving on runtime generated
       classes
To: aspectj-dev@xxxxxxxxxxx
Message-ID:
       <acf51e320903121752x27822787k222677ce052c7b7d@xxxxxxxxxxxxxx>
Content-Type: text/plain; charset="iso-8859-1"

Good evening,
I would like to know if it is possible to apply aspects on runtime created
classes.
I have been trying this days and still have got no luck.

Thanks in advance,
Emmanuel de Castro Santana
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://dev.eclipse.org/mailman/private/aspectj-dev/attachments/20090312/7db19224/attachment.html

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

Message: 2
Date: Thu, 12 Mar 2009 21:52:59 -0300
From: Emmanuel Castro Santana <emmanuel.csantana@xxxxxxxxx>
Subject: [aspectj-dev] AspectJ load time weaving on runtime generated
       classes
To: aspectj-dev@xxxxxxxxxxx
Message-ID:
       <acf51e320903121752oe3cd1daif033f1c0432c92fc@xxxxxxxxxxxxxx>
Content-Type: text/plain; charset="iso-8859-1"

Good evening,
I would like to know if it is possible to apply aspects on runtime created
classes.
I have been trying this days and still have got no luck.

Thanks in advance,
Emmanuel de Castro Santana
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://dev.eclipse.org/mailman/private/aspectj-dev/attachments/20090312/21450c4b/attachment.html

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

Message: 3
Date: Fri, 13 Mar 2009 03:47:50 +0100
From: Simone Gianni <simoneg@xxxxxxxxxx>
Subject: Re: [aspectj-dev] AspectJ load time weaving on runtime
       generated       classes
To: AspectJ developer discussions <aspectj-dev@xxxxxxxxxxx>
Message-ID: <49B9C956.1080002@xxxxxxxxxx>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Hi Emmanuel,
it is possible if using LTW and if the "byte code chain" is working
correctly. That means if the weaver gets a chance to weave the generated
classes while they are being loaded in the target classloader.

I run some experiments some time ago using cglib to generate runtime
method interceptors and seeing if they got weaved or not, and in my
situation it was working correctly.

Also, I currently have in my Magma Apache Lab, OpenJPA enhancing classes
after AspectJ weaved it, or the other way around (and when running tests
also Cobertura comes into play with its enhancer) but had to setup a
custom classloader and a quite a number of support classes to have this
double/triple enhancing process to work smoothly.

Can you elaborate on which kind of environment you are using? Are in in
LTW? Are you using the agent? Which library is generating classes at
runtime?

Simone

Emmanuel Castro Santana wrote:
> Good evening,
> I would like to know if it is possible to apply aspects on runtime
> created classes.
> I have been trying this days and still have got no luck.
>
> Thanks in advance,
> Emmanuel de Castro Santana
> ------------------------------------------------------------------------
>
> _______________________________________________
> aspectj-dev mailing list
> aspectj-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-dev
>


--
Simone Gianni            CEO Semeru s.r.l.           Apache Committer
http://www.simonegianni.it/



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

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


End of aspectj-dev Digest, Vol 48, Issue 3
******************************************



--
Emmanuel de Castro Santana

Back to the top