>>>>> "Huw" == Huw Evans <[EMAIL PROTECTED]> writes:
>> For my purposes, I only need to know if a value is the this >> pointer, a field of an object or an argument. In fact I want to >> detect which methods are getters, setters, adders or >> removers. And a few other things, such as replacing java.util.* >> collections with my own versions that I can modify at load time. Huw> Hello, I've noticed the above on the bcel mailing list. Huw> In the general case, how are you going to notice a method goes Huw> a get, set, add or remove? Huw> If a programmer has written good OO code, you could possibly Huw> spot this, but in less well written code this would be hard. Huw> For example a method may do a combination of set and get, for Huw> example, e.g., hashtables put method that puts a value under Huw> the specific key, returning the old value (if any). I do not have a proof that my system work on 100% of the cases. My technique is to simulate bytecode execution and build a pseudo stack which only contains the information that I need. For instance, when I see aload_0, I know there's the this pointer pushed on the stack. And if I encounter a getfield while this on the top of the stack, the method is considered a getter for that field. In order to detect adders, I also need to know a value on the stack is the value of field. Everytime I see a getfield, I know it pushes the value of a field on the stack. Then when I find an invokevirtual of java.util.Vector.add() (for instance) on the a value, it's an adder. I've commited my stuff into JAC's cvs, so you can have a look at it if you like: http://jac.aopsys.com/cgi-bin/viewcvs.cgi/jac/src/jac/core/translators/ See the VMStack class, and WrappeeTranslator_BCEL.fillRTTI() Regards, Laurent -- Laurent Martelli http://jac.aopsys.com/ [EMAIL PROTECTED] http://www.bearteam.org/~laurent/ -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
