lundi 20 février 2017

Making use of getParameterTypes of javassist.CtMethod

I am making use of bytecode instrumentation for a project related to debugging. I will have a JSON file with name of class, some of its method, and their corresponding parameters. So I compare the class name(with the parameter of transform method), and for each of its method(using a for loop and CtMethod), I am comparing if that method needs to be inspected(is in JSON file). If it does, I need to take care of overriding cases, for which I have to take parameters under consideration.

So, I have a list of parameters(as strings) from JSON file and another set of parameters from CtMethod.getParameterTypes.

However the issue is, CtMethod.getParameterTypes returns the types of parameters as CtClass like these:

javassist.CtPrimitiveType@2d8e6db6[int] javassist.CtPrimitiveType@23ab930d[double] javassist.CtPrimitiveType@4534b60d[boolean]

and gets complex for String and maybe other object references.

My question is, how can I compare the two set of parameters? java.lang.reflect.Methodcan also be used, but I have to make use of addCatch method of CtMethod class, hence I am not using java.lang.reflect.Method to get parameter type names.

What would you suggest to get done with this problem?





Aucun commentaire:

Enregistrer un commentaire