You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bcel-user@jakarta.apache.org by Ganesh Kumar Choudhary <ga...@gmail.com> on 2011/06/06 20:06:31 UTC

How to intercept field access using BCEL

Hi,

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.

Thanks,
Ganesh

-- 
Man cannot discover new oceans unless he has the courage to lose sight of
the shore.

Re: How to intercept field access using BCEL

Posted by Martin von Gagern <Ma...@gmx.net>.
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.