Re: How to intercept field access using BCEL

Martin von Gagern <[email protected]> Wed, 08 Jun 2011 11:04:21 +0200
Newsgroups gmane.comp.jakarta.bcel.user
Message-ID <[email protected]>
--------------enigF10B695A607523B7FE89E697
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

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.


--------------enigF10B695A607523B7FE89E697
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.10 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk3vOxgACgkQRhp6o4m9dFuTGQCdEN+OyXdnn5/6RMW+Yhy5GHrh
ihEAnjSm2qGLP2F8lWK+8VgUNPQ9v+Zl
=iu54
-----END PGP SIGNATURE-----

--------------enigF10B695A607523B7FE89E697--