Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • asm asm
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 4
    • Issues 4
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 1
    • Merge requests 1
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • asm
  • asmasm
  • Issues
  • #317929
Closed
Open
Created Jan 02, 2021 by Aura Lee@graxcode

ClassRemapper doesn't remap annotation values

I am remapping method names using a custom remapper class like this:

  ClassNode updated = new ClassNode();
  node.accept(new ClassRemapper(updated, new MyRemapper(...)));

MyRemapper overrides mapMethodName and therefore should update all references to a certain method. My sample class which is run through the ClassRemapper:

public class AnnotationRemapTest {
  @Retention(RetentionPolicy.RUNTIME)
  @Target(ElementType.METHOD)
  public static @interface Description {
    String desc() default "an unknown method";
  }

  @Description(desc = "the entry point method")
  public static void main(String[] args) throws Exception {
    Description d = (Description) AnnotationRemapTest.class.getDeclaredMethod("main", String[].class).getAnnotations()[0];
    System.out.println("this method is: " + d.desc());
  }
}

Everything works great, except that @Description(desc = "the entry point method") is not updated. In my eyes it is missing a call to mapMethodName to update the annotation value name, which corresponds to its method name inside the annotation class.

Output after remapping:

public class AnnotationRemapTest {
  @Retention(value = RetentionPolicy.RUNTIME)
  @Target(value = { ElementType.METHOD })
  public static @interface A {
    public String n() default "an unknown method";
  }

  @A(desc = "the entry point method") // "desc" is left as "desc", while it should be updated to "n"
  public static void main(String[] args) throws Exception {
    A d = (A) AnnotationRemapTest.class.getDeclaredMethod("main", String[].class).getAnnotations()[0];
    System.out.println("this method is: " + d.n());
  }
}

In short: AnnotationRemapper is missing calls to mapMethodName to update annotation value names.

Edited Jan 02, 2021 by Aura Lee
Assignee
Assign to
Time tracking