Skip to content

Annotations

Lenni0451 edited this page Mar 17, 2024 · 3 revisions

Annotations

ClassTransform has two types of annotations:

  • Annotations that are used to give information about the injection (e.g. CInject)
  • Annotations that are used to give hints to ClassTransform (e.g. CTarget)

Injection annotations

Annotation Description
CASM Manually inject into a class/method using direct ASM
CInject Inject a method call into a method
CModifyConstant Modify a constant value in a method (e.g. int, String, float, ...)
COverride Override a method in a class
CRecordComponent Add a new field to a record class
CRedirect Redirect a method call/field access
CWrapCatch Wrap a try-catch around a method/method call
CWrapCondition Wrap an if statement around a method call/field put

Hint annotations

Annotation Description
CInline Mark a method to be inlined by ClassTransform
CLocalVariable Capture a local variable in a method and pass it to the transformer method (also allows modifying the value)
CShadow Shadow a field/method in a transformer to make it accessible
CShared Share a field between multiple transformer methods inside the same target method
CSlice Specify a slice of a method for easier targeting of method calls and field accesses
CTarget Specify a target for an injection annotation
CTransformer Specify a target class for a transformer
CUpgrade Upgrade a class to a newer version (Only sets the version number, no actual upgrading)