jakarta-bcel-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin von Gagern <Martin.vGag...@gmx.net>
Subject Re: How to intercept field access using BCEL
Date Wed, 08 Jun 2011 09:04:21 GMT
Am 06.06.11 20:06, schrieb Ganesh Kumar Choudhary:
> I have tried to intercept method calls by enhancing method body. Now I want
> to intercept field access. I don't know how to do this. Can anyone help me
> in this regard.

You'll have to modify all classes that do access the field. You can
first examine the constant pool of every class, see if it refers to the
field (i.e. has a matching ConstantFieldref). If that is the case,
you'll have to process the bytecode for each method and insert
appropriate function calls before and/or after the field reference. Or,
as an alternative, replace the field load with a method call using some
BCEL-generated method to wrap the field access.

View raw message