Hi,

> What exactly is happening here, can you share more details on how to
avoid this.

The instructions are being reorganized now that new code has been inserted
by AspectJ.  Destinations for branch targets that moved (probably due to
the insertion of advice) are being recomputed.  If the jump destination is
a long way away for some instructions it is possible to switch to a 'wide'
version of the instruction to encode the 'further' destination (so use
4bytes instead of 2bytes).  If the instruction was a GOTO we could use a
GOTO_W instead. In your case it isn't a goto, it is IFLE (if less than or
equal) and we can't fit the expected destination into the space we have
available to encode the target.

The 'fix' in AspectJ is to dynamically adjust the IFLE to a nearby branch
destination and then use a GOTO_W to get to the real target, but we haven't
had time to implement that.  Basically you have a big method and you are
weaving stuff into it and just pushing the branches too far apart. Do you
need to weave so much into the method in question? Does any extra exception
info tell you the method in question? I can't recall.

cheers,
Andy



On 11 September 2013 01:36, Krishna Jasty <[email protected]> wrote:

> Hi,
>
> When i use the aspectj in our application, i am facing the following
> exception.
> Caused by: java.lang.IllegalStateException: Unable to pack method, jump
> (with opcode=158) is too far: 32089
>         at
> org.aspectj.apache.bcel.generic.InstructionBranch.updatePosition(InstructionBranch.java:176)
>         at
> org.aspectj.apache.bcel.generic.BranchHandle.updatePosition(BranchHandle.java:101)
>         at
> org.aspectj.apache.bcel.generic.InstructionList.setPositions(InstructionList.java:919)
>         at
> org.aspectj.apache.bcel.generic.InstructionList.setPositions(InstructionList.java:863)
>         at
> org.aspectj.apache.bcel.generic.InstructionList.getByteCode(InstructionList.java:981)
>         at
> org.aspectj.apache.bcel.generic.MethodGen.getMethod(MethodGen.java:697)
>         ... 68 more
>
> When i check the aspectj source code, it looks as follows.
>  protected int updatePosition(int offset, int max_offset)
>   {
>     int i = getTargetOffset();
>
>     this.positionOfThisInstruction += offset;
>
>     if ((Math.abs(i) >= 32767 - max_offset) && (this.opcode != 201) &&
> (this.opcode != 200))
>     {
>       if ((this.opcode == 168) || (this.opcode == 167)) {
>         if (this.opcode == 168)
>           this.opcode = 201;
>         else {
>           this.opcode = 200;
>         }
>         return 2;
>       }
>       throw new IllegalStateException("Unable to pack method, jump (with
> opcode=" + this.opcode + ") is too far: " +
>         Math.abs(i));
>     }
>
>     return 0;
>   }
>
>
> Hi Andy,
> What exactly is happening here, can you share more details on how to avoid
> this.
> Thanks,
> Krishna
>
> =====-----=====-----=====
> Notice: The information contained in this e-mail
> message and/or attachments to it may contain
> confidential or privileged information. If you are
> not the intended recipient, any dissemination, use,
> review, distribution, printing or copying of the
> information contained in this e-mail message
> and/or attachments to it are strictly prohibited. If
> you have received this communication in error,
> please notify us by reply e-mail or telephone and
> immediately and permanently delete the message
> and any attachments. Thank you
>
>
> _______________________________________________
> aspectj-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to