Re: injecting code to exception handler
Bing Ran <[email protected]> Tue, 22 Apr 2014 21:54:50 +0800
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <CAPTRyncy3i9niDTyMaQRCvjTcBxGpSpvDGGvLmDhwdyES9yFvA@mail.gmail.com> |
Thanks for the info. I was thinking about the same approach too. Haven't implemented it yet, but I guess that's the best but not so straight-forward solution thus far. Bing 2014-04-22 21:51 GMT+08:00 Eliot Moss <[email protected]>: > On 4/17/2014 12:01 AM, Bing Ran wrote: > > Wondering how I can inject some code in the beginning of all the catch >> blocks. I don't seem to be >> able to find the proper method to override in a MethodVisitor. >> > > I don't recall what responses have been posed (maybe even by me), > but here are some quick thoughts: > > 1) You'll need to process the try-catch block information and > remember the labels of the starts of handlers -- perhaps in a > HashSet. > > 2) As you encounter Label's in the code (visitLabel) check to > see if the Label is one in your HashSet, which implies it is > at the start of a handler. *After* doing a super.visitLabel > call, do your calls to insert code. > > I have often found it to be the case that interesting transformations > require a certain amount of tracking/analysis of the stream of > instructions and other related info, and selective transformation > based on context. > > Regards -- Eliot Moss >
message-footer.txt
(text/plain, 238 B)
-- 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