Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Modified classes of the Jar files in Inpath (which shouldn't be modified)


I'd like to comment on the first part of your post while Andy deals with the second

>Firstly, what I am doing is to modify some of the classes in a 3rd party
>framework using AspectJ. I am using Eclipse AspectJ plugin and so on. So I
>add the 3rd party library in the Inpath of AspectJ and apply my advices, and.
>some of the classes from the framework get modified by AspectJ. This is the
>main work flow. By the way, as a side question I'd like to ask this: AspectJ
>extracts _all_ the class files from the 3rd party Jar file into the bin
>directory, even if 99% percent of them never gets modified. I think this is
>the expected behaviour, but is it possible to have AspectJ extract only
>those files which gets indeed advised/modified?

What you are trying to do can be achieved with Ant and the iajc task. We didn't want to bloat ajc with capability that was already available elsewhere. While it might seem attractive to be selective with the classes you weave it could be problematic in the long run. The only advantage is performance and probably only with large JARs e.g. 1000+ classes. The best model is to weave the entire JAR, give it a slightly different name and replace the original one in you runtime. One approach would be to produce a small JAR containing just woven classes, and any generated by the weaving process, and place it on the CLASSPATH ahead of the original. However, this can be confusing because there will be 2 versions of some classes in the system. Furthermore if any classes in the JAR are changed which means they are now matched by an existing aspect, an aspect is modified so that it matches different classes or new aspects are added you will have to change your build process. This is fragile. In short unless you have a very large JAR it's best to let AspectJ decide which classes are woven.

Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM United Kingdom Limited
Hursley Park, Winchester,  SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)



"bora.erbas" <bora.erbas@xxxxxxxxx>
Sent by: aspectj-users-bounces@xxxxxxxxxxx

27/02/2007 08:36

Please respond to
aspectj-users@xxxxxxxxxxx

To
aspectj-users@xxxxxxxxxxx
cc
Subject
[aspectj-users] Modified classes of the Jar files in Inpath (which shouldn't be modified)






Hi all,

This problem seems to be most interesting one I ever had with AspectJ. It
has multiple sub-problems some of which may not directly be related to
AspectJ.

Firstly, what I am doing is to modify some of the classes in a 3rd party
framework using AspectJ. I am using Eclipse AspectJ plugin and so on. So I
add the 3rd party library in the Inpath of AspectJ and apply my advices, and
some of the classes from the framework get modified by AspectJ. This is the
main work flow. By the way, as a side question I'd like to ask this: AspectJ
extracts _all_ the class files from the 3rd party Jar file into the bin
directory, even if 99% percent of them never gets modified. I think this is
the expected behaviour, but is it possible to have AspectJ extract only
those files which gets indeed advised/modified?

And now the problem. I have a few aspects and due to the current
requirements each of them only affects one class from the framework; hence
no wildcards, just one method replaced with an around advice for example.
Hence I expect that only those class files which are advised should be
modified by AspectJ (correct?). This is true except for only 1 case and I
have been struggling to solve this issue. I compare the files and for one
aspect there is a side effect; one more modified class file.
And then it gets really more interesting; I decompile the "side-effect"
class file and the original class file from the library using Jad and
compare them. Guess what, they are the same!!! Then I use javap to
disassemble these two class files and again the same. However, one of the
files is 15kB and the other is 10kB, which means there is definitely a
difference right? So what could be the difference?

Any ideas on how to solve this puzzle?

Cheers.

--
View this message in context: http://www.nabble.com/Modified-classes-of-the-Jar-files-in-Inpath-%28which-shouldn%27t-be-modified%29-tf3299223.html#a9177518
Sent from the AspectJ - users mailing list archive at Nabble.com.

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







Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU







Back to the top