[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] ajc - how to compile only .aj files but avoid weaving (for load time weaving)

Thanks Andy,

Your suggestion worked.

When I do javac on java files, club the class files in to a jar and put
that jar in classpath for ajc, it fails (i.e. it generates woven classes
for my java files)

But when I do javac on java files, and provide just the "classes" folder
in classpath for ajc, it works (i.e. it does not modify my original class
files generated by javac)

- Jayesh


Andy Clement wrote:
> 
> classes on the classpath are only used for resolving references in the
> aspects, they will not be woven - you must be picking them up via
> another route.
> 
> src1/A.java:
> public class A {
>   public static void main(String []argv) {}
> }
> 
> src2/X.aj:
> public aspect X {
>   before():staticinitialization(A) { }
> }
> 
> javac src1\A.java -d classes
> 
> ajc src2\X.aj -cp classes;aspectjrt.jar -d aspects
> 
> the aspects directory only contains X.class at the end of this.
> 
> 
> On 09/08/07, Jayesh Vora <jayeshjvora@xxxxxxxxx> wrote:
>>
>> Hi Andy,
>>
>> I tried this. It doesn't work.
>> What I did was:
>> - separate out .java files and .aj files into separate folder structure.
>> Say, .java files in to src1 folder and .aj files in to src2.
>> - javac on src1; create a jar file and put it in CLASSPATH environment
>> variable.
>> - ajc on src2
>> Still it creates woven class files for the java files.
>>
>> - Jayesh
>>
>>
>> Andy Clement wrote:
>> >
>> > If you put the .class files for your javac compiled code on your
>> > CLASSPATH and then run ajc against the .aj files, then it will not
>> > produce woven classes for anything other than the aspects.
>> >
>> > On 09/08/07, Jayesh Vora <jayeshjvora@xxxxxxxxx> wrote:
>> >>
>> >> I tried both ways:
>> >> - to start with, I had all my .java and .aj files at one
>> >> particular folder, which I provided in -sourceroots option
>> >> and I didn't specify -inpath option, it didn't work
>> >>
>> >> - then I first did 'javac' and compiled all my java files,
>> >> put all generated class files into a jar and specified
>> >> that jar in -inpath option, still it didn't work
>> >>
>> >> Both the times it generated woven class files for
>> >> java files.
>> >>
>> >> - Jayesh
>> >>
>> >>
>> >> Eric Bodden-2 wrote:
>> >> >
>> >> > I think you can just keep your -inpath empty.
>> >> >
>> >> > Eric
>> >> >
>> >> > On 09/08/07, Jayesh Vora <jayeshjvora@xxxxxxxxx> wrote:
>> >> >>
>> >> >> Hi,
>> >> >>
>> >> >> I want to use Load Time Weaving and thus want
>> >> >> ajc to compile only .aj files containing my advices,
>> >> >> but do not generate woven class files for the
>> >> >> Java files.
>> >> >>
>> >> >> I tried going thru' all command line options of ajc
>> >> >> but couldn't find any.
>> >> >>
>> >> >> Please help.
>> >> >>
>> >> >> Thanks,
>> >> >> Jayesh
>> >> >> --
>> >> >> View this message in context:
>> >> >>
>> >>
>> http://www.nabble.com/ajc---how-to-compile-only-.aj-files-but-avoid-weaving-%28for-load-time-weaving%29-tf4242454.html#a12071901
>> >> >> 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
>> >> >>
>> >> >
>> >> >
>> >> > --
>> >> > Eric Bodden
>> >> > Sable Research Group
>> >> > McGill University, MontrÃal, Canada
>> >> > _______________________________________________
>> >> > aspectj-users mailing list
>> >> > aspectj-users@xxxxxxxxxxx
>> >> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/ajc---how-to-compile-only-.aj-files-but-avoid-weaving-%28for-load-time-weaving%29-tf4242454.html#a12072723
>> >> 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
>> >>
>> > _______________________________________________
>> > aspectj-users mailing list
>> > aspectj-users@xxxxxxxxxxx
>> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/ajc---how-to-compile-only-.aj-files-but-avoid-weaving-%28for-load-time-weaving%29-tf4242454.html#a12073569
>> 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
>>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
> 
> 

-- 
View this message in context: http://www.nabble.com/ajc---how-to-compile-only-.aj-files-but-avoid-weaving-%28for-load-time-weaving%29-tf4242454.html#a12086741
Sent from the AspectJ - users mailing list archive at Nabble.com.