Closed Su5eD closed 1 year ago
Commit 147a04d introduced an update to JarMapping#parseCsrgLine that would remove the / suffix from old package names in CSRG mappings in order to comply with the mapped package names on bukkit, which did not have a trailing slash. https://github.com/md-5/SpecialSource/blob/a33eacd99e9cf20a19121838c8e5afd18e197304/src/main/java/net/md_5/specialsource/JarMapping.java#L458-L462 However, this causes an inconsistency in names that breaks renaming packages.
JarMapping#parseCsrgLine
/
Normally, both old and new SRG package names are expected to have trailing slashes. This should apply to other SRG-based formats as well. https://github.com/md-5/SpecialSource/blob/a33eacd99e9cf20a19121838c8e5afd18e197304/src/main/java/net/md_5/specialsource/JarMapping.java#L567
Remaping the class name com/example/foo/Main with any of the following TSRG lines will result in invalid class names:
com/example/foo/Main
com/example/foo/ com/example/bar/
com/example/bar//Main
com/example/bar/Main
com/example/foo/ .
/Main
Main
SpecialSource should be able to properly handle package names' trailing slashes for all SRG-based formats.
Adding the existing trailing slash handler code from parseSrgLine to parseCsrgLine as well solves the issue. It's a simple and backwards-compatible solution. https://github.com/md-5/SpecialSource/blob/a33eacd99e9cf20a19121838c8e5afd18e197304/src/main/java/net/md_5/specialsource/JarMapping.java#L568-L574
parseSrgLine
parseCsrgLine
Please open a PR?
The Issue
Commit 147a04d introduced an update to
JarMapping#parseCsrgLine
that would remove the/
suffix from old package names in CSRG mappings in order to comply with the mapped package names on bukkit, which did not have a trailing slash.https://github.com/md-5/SpecialSource/blob/a33eacd99e9cf20a19121838c8e5afd18e197304/src/main/java/net/md_5/specialsource/JarMapping.java#L458-L462 However, this causes an inconsistency in names that breaks renaming packages.
Normally, both old and new SRG package names are expected to have trailing slashes. This should apply to other SRG-based formats as well. https://github.com/md-5/SpecialSource/blob/a33eacd99e9cf20a19121838c8e5afd18e197304/src/main/java/net/md_5/specialsource/JarMapping.java#L567
Reproduction
Remaping the class name
com/example/foo/Main
with any of the following TSRG lines will result in invalid class names:com/example/foo/ com/example/bar/
->com/example/bar//Main
, expected:com/example/bar/Main
com/example/foo/ .
->/Main
, expected:Main
Expected behavior
SpecialSource should be able to properly handle package names' trailing slashes for all SRG-based formats.
Proposed solution
Adding the existing trailing slash handler code from
parseSrgLine
toparseCsrgLine
as well solves the issue. It's a simple and backwards-compatible solution. https://github.com/md-5/SpecialSource/blob/a33eacd99e9cf20a19121838c8e5afd18e197304/src/main/java/net/md_5/specialsource/JarMapping.java#L568-L574