Re: Distinguishing between different access modifiers for a method in the MethodVisitor
Eugene Kuleshov <[email protected]> Mon, 26 Feb 2018 19:45:47 -0500
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <CADFjdoXBkc_v12cJAPjxb4H6s4SrXaB2vM5ODS+jY54YDuQk+A@mail.gmail.com> |
You can pass access flags from class visitor to method visitor when the latter is created. On Mon, Feb 26, 2018 at 7:43 PM, Aniket Panse <[email protected]> wrote: > Hello List! > > I'm trying to call a function before every "synchronized" method, but I'm > having trouble with it. > > Say I have a class like so: > > public class HelloWorld { > public static void main() { > myMethod(); > } > public synchronized myMethod() { > System.out.println("Hello World!"); > } > } > > I'd like to print something out every time a synchronized method is called. > So I write a MethodAdaptor: > > public class MethodAdapter extends MethodVisitor { > @Override > public void visitMethodInsn(int opcode, String owner, String name, String > desc, boolean itf) { > // I'll add a call to System.out.println() here > // but how do I know whether this method is synchronized?? > } > } > > I realize that the class visitor does have access to the method's modifiers, > but how do I make that information available to the MethodAdapter? > > Thanks! > -- Aniket > > > -- > 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 > -- 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