Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
asm
asm
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 4
    • Issues 4
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 1
    • Merge Requests 1
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • asm
  • asmasm
  • Issues
  • #317929

Closed
Open
Opened 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
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: asm/asm#317929