I am trying to modify a compiled class (source code is not available) which, for example, I want to change all references to java.lang.Object
to some.packageName.SomeClass
.
By references I mean:
- Field types
- Methods return types
- Methods argument types
- Supertype
- Variables types in method bodies
- Static class references (e.g.
java.lang.Object.class
) - Generic type parameters
- Etc.
Basically, by this example, the modified class should't be able to access the java.lang.Object
class directly, but only through some.packageName.SomeClass
. Please note that the example class may be any arbitrary class either from the jre or not. The supplied substitute will behave exactly as the original is expected.
Is this possible by using BCEL or Javassist? If not, is there any other library which provides functionality for accomplish this goal?