Skip to content

Field Redirects

Tom Martin edited this page Jul 9, 2025 · 1 revision

In transformed methods @FieldRedirect replaces usages of one field with another

More information is available in the javadoc for @FieldRedirect

  • Only field names may be changed by a field redirect. To change its type see type redirects
  • Fields are matched by their name and descriptor

A method redirect that changes calls to Foo#fooField to Bar#barField.

The field redirect renames the field accessed, the type redirect changes the owning class.

@TypeRedirect(from = @Ref(Foo.class), to = @Ref(Bar.class))
abstract class Foo_to_Bar {
    @FieldRedirect("foo:I")
    private int barField;
}
``
Clone this wiki locally