Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Re: Extending standard java classes

In general, weaving the JDK is a difficult and risky process because
of the memory required to do it and because once it's woven anyone who
wants to run your program must run with the woven JDK.

So, if t all possible, I'd try to avoid it.  Without knowing what you
are trying to do it's hard to say how, but perhaps you can think of
advising method calls to the classes in java.lang and java.util.

But, if you must weave the JDK, then I'd go with Alex's suggestion and
weave outside of Eclipse using ajc or ant.

On Tue, Dec 2, 2008 at 6:49 AM, Tassilo Horn <tassilo@xxxxxxxxxxxxxx> wrote:
> Alex Villazon <alex.villazon@xxxxxxxxxxx> writes:
>
> Hi Alex,
>
>>> What I want to do is to add an interface to some classes.  From the
>>> documentation I can see how that's done, but unfortunately I want to
>>> add this interface to about 10 classes from java.lang and java.util.
>>>
>>> When I did that I got warnings that the affected types aren't exposed
>>> to the weaver.  So I added the JRE System Library to the *inpath*.
>>> But then I don't have enough memory to run the aspectj compiler.
>>
>>    You could simply edit ajc script and change the -Xmx param (e.g. -
>> Xmx1G)
>
> I use the eclipse plugin and have -Xmx1G in my eclipse.ini.  And that's
> not enough. ;-)
>
>>> So is there a way to pick only the 10 classes I need out of the
>>> library?
>>
>>   One way is to unjar the rt.jar on a directory, and then make your
>> own jar with the classes you need, and weave them.
>
> I thought that might be a solution.  But then I'd need to recreate that
> lib whenever I update the JDK and maybe it could lead into problems if
> developers use different JDK versions (1.6.0 vs. 1.6.10).
>
> Well, there are worse things, but when you say "one way" do you imagine
> another way, too?
>
>>  Something like
>>  mkdir JDK
>>  cd JDK
>>  jar xvf $JAVA_HOME/jre/lib/rt.jar
>>  jar cvf myrt.jar java/lang/... java/util/...
>>
>>  Then you weave myrt.jar and finally pass the woven myrt.jar to -
>> Xbootclasspath/p:
>
> I'll try that out anyway.
>
> Thanks a lot,
> Tassilo
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>


Back to the top