CReplaceCallback - Lenni0451/ClassTransform GitHub Wiki
The CReplaceCallback annotation can be used to replace all InjectionCallbacks used for the CInject annotation in the target class.
All checks implemented in the InjectionCallback class are reimplemented in plain ASM code resulting in no drawbacks when using this annotation.
This is useful when the InjectionCallback class is not available in the target environment.
For example:
- Injecting into Java internals which can't access library classes
- Transforming an external jar file that doesn't include the library
Internal behavior
All InjectionCallbacks are replaced with an Object array with a length of 4.
The elements are:
| index | description |
|---|---|
| 0 | If the callback can be cancelled (cancellable = true in the CInject annotation) |
| 1 | If the callback is currently cancelled |
| 2 | The new return value if the target method returns a value |
| 3 | If a return value is set |
After applying all other transformers, the InjectionCallbackReplacer#replaceCallback(ClassNode) method is called with the target class node.
This method can also be called manually to achieve the same effect without requiring the CReplaceCallback annotation.
Example
@CReplaceCallback
@CTransformer(TestClass.class)
public class Transformer {