Skip to content

Method Redirects

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

In transformed methods @MethodRedirect replaces usages of one method with another

More information is available in the javadoc for method redirect

  • Only method names may be changed by a method redirect. To change its parameter or return types see type redirects
  • Methods are matched by their name and descriptor
  • Method Redirects must occur within a container in which they are valid (See the Valid Redirects section of the javadoc on TypeRedirect, InterOwnerContainer, and IntraOwnerContainer

Example:

A method redirect that changes calls to Foo#foo() to Bar#bar().

The method redirect renames the method invoked, the type redirect changes the owning class.

@TypeRedirect(from = @Ref(Foo.class), to = @Ref(Bar.class))
abstract class Foo_to_Bar {
    @MethodRedirect("foo()V")
    private native void bar();
}
Clone this wiki locally