Re: AdviceAdapter extends LocalVariablesSorter
Eirik Bjørsnøs (via asm Mailing List) <[email protected]> Thu, 18 Feb 2021 15:56:55 +0100
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <CA+pBWht9-ZiR54yS-cR_MHZJq6sDjSP7B2Eno+ZqdXsnk6=C9Q@mail.gmail.com> |
This is a multi-part message in MIME format... ------------=_1613660228-2761-6 Content-Type: multipart/alternative; boundary="00000000000097a62805bb9d8cfd" --00000000000097a62805bb9d8cfd Content-Type: text/plain; charset="UTF-8" > > 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? > I did an experiment to see if I could untangle the goodness of AdviceAdapter from GeneralAdapter/LVS inheritance chain: https://gitlab.ow2.org/eirbjo/asm/-/commit/8c5f53e3ac321b24c8c5d401fa7468826b380808 The main idea is to do the following: 1) Copy AdviceAdapter to a new class AdviceVisitor 2) Update AdviceVisitor to extend MethodVisitor (instead of GeneralAdapter) 3) Remove all existing methods from AdviceAdapter (except the abstract onMethodEnter/onMethodExit) 4) In the AdviceAdapter constructor, inject an AdviceBridge into the delegation chain. 5) Let the AdviceBrige chain forward onMethodEnter/onMethodExit calls from AdviceVisitor -> AdviceAdapter. This has the effect of introducing a compressed-frame compatible AdviceVisitor while keeping the AdviceAdapter class binary compatible. All ASM tests pass, so existing AdviceAdapter behaviour seems to be preserved. Here's the updated AdviceAdapter class: https://gitlab.ow2.org/eirbjo/asm/-/blob/8c5f53e3ac321b24c8c5d401fa7468826b380808/asm-commons/src/main/java/org/objectweb/asm/commons/AdviceAdapter.java And here's the new AdviceVisitor class: https://gitlab.ow2.org/eirbjo/asm/-/blob/8c5f53e3ac321b24c8c5d401fa7468826b380808/asm-commons/src/main/java/org/objectweb/asm/commons/AdviceVisitor.java Eirik. --00000000000097a62805bb9d8cfd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div class=3D"gmail_quote"><blockquote class=3D"gmail_quot= e" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204)= ;padding-left:1ex"><div dir=3D"ltr"><div>Alternatively, could the bulk of t= he AdviceAdapter logic be extracted into a reusable class which could be re= used from alternative adapter classes which do not extend LVS?</div></div><= /blockquote><div><br></div><div>I did an experiment to see if I could untan= gle the goodness of AdviceAdapter from GeneralAdapter/LVS inheritance chain= :</div><div><br></div><div><a href=3D"https://gitlab.ow2.org/eirbjo/asm/-/c= ommit/8c5f53e3ac321b24c8c5d401fa7468826b380808">https://gitlab.ow2.org/eirb= jo/asm/-/commit/8c5f53e3ac321b24c8c5d401fa7468826b380808</a></div><div><br>= </div><div>The main idea is to do the following:</div><div><br></div><div>1= ) Copy AdviceAdapter to a new class AdviceVisitor</div><div>2) Update Advic= eVisitor to extend MethodVisitor (instead of GeneralAdapter)</div><div>3) R= emove all existing methods from AdviceAdapter (except the abstract onMethod= Enter/onMethodExit)</div><div>4) In the AdviceAdapter constructor, inject a= n AdviceBridge into the delegation chain.</div><div>5) Let the AdviceBrige = chain forward onMethodEnter/onMethodExit calls from AdviceVisitor -> Adv= iceAdapter.</div><div><br></div><div>This has the effect of introducing a c= ompressed-frame compatible AdviceVisitor while keeping the AdviceAdapter cl= ass binary compatible.=C2=A0=C2=A0</div><div><br></div><div>All ASM tests p= ass, so existing AdviceAdapter behaviour seems to be preserved.</div><div><= br></div><div>Here's the updated AdviceAdapter class:</div><div><br></d= iv><div><a href=3D"https://gitlab.ow2.org/eirbjo/asm/-/blob/8c5f53e3ac321b2= 4c8c5d401fa7468826b380808/asm-commons/src/main/java/org/objectweb/asm/commo= ns/AdviceAdapter.java">https://gitlab.ow2.org/eirbjo/asm/-/blob/8c5f53e3ac3= 21b24c8c5d401fa7468826b380808/asm-commons/src/main/java/org/objectweb/asm/c= ommons/AdviceAdapter.java</a><br></div><div><br></div><div>And here's t= he new AdviceVisitor class:</div><div><br></div><div><a href=3D"https://git= lab.ow2.org/eirbjo/asm/-/blob/8c5f53e3ac321b24c8c5d401fa7468826b380808/asm-= commons/src/main/java/org/objectweb/asm/commons/AdviceVisitor.java">https:/= /gitlab.ow2.org/eirbjo/asm/-/blob/8c5f53e3ac321b24c8c5d401fa7468826b380808/= asm-commons/src/main/java/org/objectweb/asm/commons/AdviceVisitor.java</a><= br></div><div><br></div><div>Eirik.</div><div>=C2=A0</div></div></div> --00000000000097a62805bb9d8cfd-- ------------=_1613660228-2761-6 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 ------------=_1613660228-2761-6--