Skip to main content

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

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, 司徒诚颢 <situchenghao@xxxxxxxxxxxx> wrote:
> Hi,
>
> When my aspectj is weaving to a class which has 3200 advises, eclipse
> reporting Error "problem generating method packageXX.ClassXX.<clinit> : 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

Back to the top