Ganesh Kumar Choudhary | 6 Jun 2011 20:06
Picon

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.
Martin von Gagern | 8 Jun 2011 11:04
Picon

Re: How to intercept field access using BCEL

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.


Gmane