Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: ظ Re: [aspectj-users] method <clinit>code size too big problem when weaving

Hi,
Thanks for your explanation.
I'm using reflection to get the variable name instead of using getLine(), and it works fine now.
But one thing I noticed is even using non statically determinable information like invoke thisJoinPoint.getTarget(), the aspectj will still generate class initializer (clinit).However, this uasge can be avoided by using target() in the definition of the pointcut.
The another problem is the OutOfMemoryError when I'm using LTW, this is because the weaved java file is too big. Increase JVM heap size will solve this problem.
Thanks.

Andy Clement <andrew.clement@xxxxxxxxx> wrote:
If you use thisJoinPoint in your advice and then only access
statically determinable information then the compiler will
intelligently switch to using the static form of thisJoinPoint (which
you could have specified as thisJoinPointStaticPart). So in your case
using either

thisJoinPoint.getSourceLocation().getLine()

or using

thisJoinPointStaticPart.getSourceLocation().getLine()

will produce the same output.

The static objects representing the join points are then constructed
in the class initializer (clinit) in the class.

I am not really clear on what you want your advice to do, so I can't
say if there is a better way....

Andy.

On 14/01/2008, Chenghao Situ wrote:
> Hi,
>
> Sorry, I mean 3200 joinpoint shadows.
> So you mean JoinPointStaticParts will generate static initial method, right?
> I checked my aspect and found I'm using
> thisJoinPoint.getSourceLocation().getLine();
> in the code. I compare the recompiled weavened code between before and after
> commenting this code, and confirm that this code will generate static
> initial method.Then I checked the API doc, I guess it should actually using
> JoinPointStaticParts, which cause the error.
>
> But the problem is I really need to use getLine() method.Because the code
> I'm weavening is like:
> SomeInterface ImplementClassName;
> public method{
> ImplementClassName.get(args);
> }
> The ImplementClass is name of a very complex class ImplementClass and in my
> context it is null, now I want to get "ImplementClassName". What I'm doing
> now is to get "ImplementClassName.get(args);" in the sourcecode by using
> getLine() then get "ImplementClassName".In my program, what will returned is
> decided by ImplementClassName and args, but I can only get SomeInterface
> information using ApsectJ Runtime API.
>
> Is there some substitutionary method to implement this function?
> Thank you very much.
>
> Eric Bodden дµÀ£º
> You mean you have 3200 pieces of advice? Or 3200 joinpoint shadows? In
> the former case, your code is wrong, I suppose, and in the latter
> case, it seems strange that 3200 JoinPointStaticParts are being
> created.
>
> Eric
>
> On 14/01/2008, ˾ͽ³Ïò« wrote:
> > Hi,
> >
> > When my aspectj is weaving to a class which has 3200 advises, eclipse
> > reporting Error "problem generating method packageXX.ClassXX. : Code
>
> > size too big: 78716".
> > I know this is caused by the limitation of the length of java method can
> not
> > longer than 64kb.
> > I modify this class and reduce the number of advises to only 3 and
> recompile
> > it, and find it will generate a static initial method like below:
> > static
> > {
> > Factory factory = new Factory("StubClass.java",
> > Class.forName("StubClass"));
> > ajc$tjp_0 = factory.makeSJP("method-call",
> > factory.makeMethodSig("1", "get", "pachageX.ClassX", "java.lang.String:",
> > "string:", "", "java.lang.String"), 13);
> > ajc$tjp_1 = factory.makeSJP("method-call",
> > factory.makeMethodSig("1", "get", "pachageX.ClassX", "java.lang.String:",
> > "string:", "", "java.lang.String"), 15);
> > ajc$tjp_2 = factory.makeSJP("method-call",
> > factory.makeMethodSig("1", "get", "pachageX.ClassX", "java.lang.String:",
> > "string:", "", "java.lang.String"), 18);
> > }
> > That means if there are 3200 advises, there will be 3200 statements in the
> > static initial method, which may cause the error.
> > And below is my around method:
> > Object around(String var) : aroundGet(var)
> > {
> > //proceed(value);
> > String key = var;
> > int line = thisJoinPoint.getSourceLocation().getLine();
> > Object value = findProperties(line, key);
> > return value;
> > }
> > private Object findProperties(int line, String key)
> > {
> > Object result = null;
> > TestData testData = BaseTestCase.getTestData();
> > result = testData.getValue(line, key);
> > return result;
> > }
> >
> > And another thing is I find that the logic in the around() method will
> > determine the weaved code, if I just return a random number in the
> around(),
> > Aspectj will not generate static initial method, under this scenario, the
> > weaving can success is there are 3200 advises.If I change the around() to
> :
> > Object around(String var) : aroundGet(var)
> > {
> > return new java.util.Random().nextInt(10000);
> > }
> > It will generate code like below:
> > private static final String get_aroundBody4(StubClass stubclass, SomeClass
> > someclass, String s)
> > {
> > return someclass.get(s);
> > }
> > private static final Object
> > get_aroundBody5$advice(AroundGetMethods this, String var,
> > AroundClosure ajc_aroundClosure, AroundGetMethods aroundgetmethods, String
> > s, AroundClosure aroundclosure)
> > {
> > return Integer.valueOf((new Random()).nextInt(10000));
> > }
> >
> > By the way, when I use LTW to weaving this class, aspects generating
> > OutOfMemoryError.
> > But I think if the problem of static way is solved, the LTW should be OK
> > too.
> >
> > So how could I solve this problem? Is there some good suggestions?
> > Thanks for the help.
> >
> > ________________________________
> > ÑÅ»¢ÓÊÏä´«µÝÐÂÄê×£¸££¬¸öÐԺؿ¨ËÍÇ×Åó£¡
> >
> >
> > _______________________________________________
> > 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
>
>
>
> ________________________________
> ÑÅ»¢ÓÊÏä´«µÝÐÂÄê×£¸££¬¸öÐԺؿ¨ËÍÇ×Åó£¡
>
>
> _______________________________________________
> 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


Looking for last minute shopping deals? Find them fast with Yahoo! Search.

Back to the top