0

I am building a profiler Using Java Instrumentation + Javaassit to intercept all the method, constructor calls. I would also like to intercept the Class Field access (Would like to monitor the static fields data to prevent misuse).

Class A { public static String data = "1"; public static void main(String[] s) { //I would like to intercept this field access System.out.println(data); //I would like to intercept this field data modification data ="2"; } } 

Is this possible to intercept them? Thanks in Advance

1 Answer 1

1

Javassist's FieldAccess has a method replace which replaces the field access with your own code. I suppose this could be used to achieve what you want.

See also http://www.javassist.org/html/javassist/expr/ExprEditor.html

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.