Skip to content

Commit

Permalink
Add support for remapping annotation attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
coehlrich committed Nov 7, 2024
1 parent b85e4e6 commit f1a7572
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public EnhancedRemapper(ClassProvider classProvider, IMappingFile map, Consumer<
}

@Override public String mapModuleName(final String name) { return name; } // TODO? None of the mapping formats support this.
@Override public String mapAnnotationAttributeName(final String descriptor, final String name) { return name; } // TODO: Is this just methods?
@Override public String mapInvokeDynamicMethodName(final String name, final String descriptor) { return name; } // TODO: Lookup how the JVM resolves this and attempt to resolve it to get the owner?

@Override
Expand Down Expand Up @@ -115,6 +114,13 @@ public Object mapValue(final Object value) {
}
}

@Override
public String mapAnnotationAttributeName(String descriptor, String name) {
return findMethod(Type.getType(descriptor).getClassName(), name, 0)
.map(MClass.MMethod::getMapped)
.orElse(name);
}

private Optional<MClass> getClass(String cls) {
if (cls == null || cls.charAt(0) == '[') // Enums values() function invokes 'clone' on the array type.
return Optional.empty(); // I'm pretty sure that i'd require stupid hacky JVM to allow native array methods to be remapped.
Expand Down

0 comments on commit f1a7572

Please sign in to comment.