aboutsummaryrefslogtreecommitdiffstats
path: root/sample/reflect/VerboseMetaobj.java
blob: cc47999ce73c3a36a4e6c01ce8971a9ee2a6cd7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package sample.reflect;

import javassist.tools.reflect.*;

public class VerboseMetaobj extends Metaobject {
    public VerboseMetaobj(Object self, Object[] args) {
        super(self, args);
        System.out.println("** constructed: " + self.getClass().getName());
    }

    public Object trapFieldRead(String name) {
        System.out.println("** field read: " + name);
        return super.trapFieldRead(name);
    }

    public void trapFieldWrite(String name, Object value) {
        System.out.println("** field write: " + name);
        super.trapFieldWrite(name, value);
    }

    public Object trapMethodcall(int identifier, Object[] args)
            throws Throwable {
        System.out.println("** trap: " + getMethodName(identifier) + "() in "
                + getClassMetaobject().getName());
        return super.trapMethodcall(identifier, args);
    }
}