Question 1: How would I change the signatures of entries within the ConstPool
? For example, lets say I had a methodref
to a method with a signature "()Ljava.util.Collection;
". How can I change that to say, "()I
"?
I want to do this because when a release comes out for an API, and a dependency on the updated API still uses the old method, I want to change the signature used, making sure that the dependent application implements this safely.
Question 2: How can I iterate through the LongVector
of constant pool entries, without having to use reflection every single step of the way? Since LongVector
is package private, ConstInfo
is package private, and I would have to use reflection to get all the method return types, in a loop too.
This will be used in tandem with problem number 1 to iterate through the constant pool and modify the signatures and store their information in a class lookup.
1) Use reflection - there's no other way to access the ConstInfo. The signatures can be found in the name and type index of the MethodRef.
2) Use reflection - there's also no other way to access the elements of the LongVector. Get the LongVector, get the elements at each index per size (both which can be accessed using reflection - LongVector simply had to also be package-local), and pass them to question 1.
Thanks for all the help!