1 Reply Latest reply on May 5, 2011 10:34 PM by EJP

    finding all instances of a specific method invocation or class construction

      hello all,

      i wish to find out where a specific method in a specific class is called from one of the classes visible to the classloader. that is, given a specific object instance analyse it, all methods it has and check if a specific method call exists in there anywhere. or alternatively if a specific class is created. is there any way to do this in a simple way? i would also like to be able to traverse from the given class a few levels further to referenced classes to check those as well.

      using the reflection api i can get the list of methods, their annotations, etc. but not the methods called (or constructed). i tried looking at asm/bcel but the bytecode analysis is a bit too much for me. i pretty much gave up after building a visitor for the classes and their methods in asm and noting that i would probably need to check something like invokevirtual opcodes and their references to the constant pool and all sorts of morbid things like that.

      basically what i am looking for is a way to mark specific spots in code and have another piece of code find those marked spots without having to execute everything. much like annotations but at the line of code level. any ideas?