Remapper removes leading $ from class name
When using ASM's Remapper
, the default implementation of mapInnerClassName
removes leading dollar signs from the class name. However, Java allows a class name with $
at the beginning, which is what, e.g., Kotlin's serialization plugin generates. I've encountered this issue in ASM with that serialization framework here.
Expected Behavior
ASM should keep the original names to ensure other tooling doesn't fail to look it up.
Current Behavior
Currently leading $
s are stripped.
To work around the issue, users of Remapper
can override mapInnerClassName
:
@Override
public String mapInnerClassName(String name, String ownerName, String innerName) {
final String result = super.mapInnerClassName(name, ownerName, innerName);
if (innerName.startsWith("$") && !result.startsWith("$")) {
return "$" + result;
}
return result;
}
This workaround doesn't solve the problem if the original class name started with more than one $
. As explained in the linked issue in kotlinx.serialization, they actually generate a nested class with a name that starts with a $
. So ASM will initially see $$
.
My assumption is that ASM should only remove a single $
if it's a nested class. All other dollar signs should remain.
Am I wrong anywhere? Thanks in advance for everything - from ASM in the first place all the way to reading this issue