AdviceAdapter extends LocalVariablesSorter
Eirik Bjørsnøs (via asm Mailing List) <[email protected]> Thu, 18 Feb 2021 14:20:55 +0100
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <CA+pBWhvopkBR3-U3Qc+so6+EEWxxwZmFPDSNg4ZzQJ7-dvM1Wg@mail.gmail.com> |
This is a multi-part message in MIME format... ------------=_1613654469-2761-0 Content-Type: multipart/alternative; boundary="000000000000442ea105bb9c35b6" --000000000000442ea105bb9c35b6 Content-Type: text/plain; charset="UTF-8" Hi, As mentioned previously, I'm in the process of replacing LocalVariablesSorter with a custom LocalVariablesPrepender which does not require expanding frames. This works nicely and speeds up class transformation significantly, but I'm now faced with another problem: For constructors, I need to make sure I'm not injecting anything until the super constructor has been called and the object is properly initialized. AdviceAdapter has the perfect solution for this problem. However, AdviceAdapter extends GeneralAdapter which extends LocalVariablesSorter which requires expanded frames! This leads to the rather unfortunate situation where if I want to instrument constructors, I must expand frames for all methods. (There's no way to specify EXPAND_FRAMES per method). I tried simply copying AdviceAdapter and tweaking it to extend MethodVisitor directly. This works like a charm. So why does AdviceAdapter extend GeneralAdapter? Is this just feature envy? Would it be possible to replace this inheritance with delegation somehow, (akin to how LVS can be chained instead of subclassed?) Alternatively, could the bulk of the AdviceAdapter logic be extracted into a reusable class which could be reused from alternative adapter classes which do not extend LVS? Thanks, Eirik. --000000000000442ea105bb9c35b6 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div>Hi,<br></div><div><br></div><div>As mentioned previou= sly, I'm in the process of replacing LocalVariablesSorter with a custom= LocalVariablesPrepender which does not require expanding frames.</div><div= ><br></div><div>This works nicely and speeds up class transformation signif= icantly, but I'm now faced with another problem:</div><div><br></div><d= iv>For constructors, I need to make sure I'm not injecting anything unt= il the super constructor has been called and the object is properly initial= ized.</div><div><br></div><div>AdviceAdapter has the perfect solution for t= his problem.</div><div><br></div><div>However, AdviceAdapter extends Genera= lAdapter which extends LocalVariablesSorter which requires expanded frames!= </div><div><br></div><div>This leads to the rather unfortunate situation wh= ere if I want to instrument constructors, I must expand frames for all meth= ods. (There's no way to specify EXPAND_FRAMES per method).</div><div><b= r></div><div>I tried simply copying AdviceAdapter and tweaking=C2=A0it to e= xtend MethodVisitor directly. This works like a charm.</div><div><br></div>= <div>So why does AdviceAdapter extend GeneralAdapter? Is this just feature = envy?=C2=A0=C2=A0</div><div><br></div><div>Would it be possible to replace = this inheritance with delegation somehow, (akin to how LVS can be chained i= nstead of subclassed?)</div><div><br></div><div>Alternatively, could the bu= lk of the AdviceAdapter logic be extracted into a reusable class which coul= d be reused from alternative adapter classes which do not extend LVS?</div>= <div><br></div><div>Thanks,</div><div>Eirik.</div><div><br></div><div><br><= /div><div><br></div><div><br></div><div><br></div></div> --000000000000442ea105bb9c35b6-- ------------=_1613654469-2761-0 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit -- You receive this message as a subscriber of the [email protected] mailing list. To unsubscribe: mailto:[email protected] For general help: mailto:[email protected]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws ------------=_1613654469-2761-0--