Skip to content

Commit 37cc2f0

Browse files
CopilotGoooler
andcommitted
Add comment explaining Kotlin split() preserves trailing empty segments unlike Java
Co-authored-by: Goooler <10363352+Goooler@users.noreply.github.com>
1 parent 25ce73a commit 37cc2f0

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

  • src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/internal

src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/internal/Relocators.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ internal fun Set<Relocator>.mapName(
1313
mapLiterals: Boolean = false,
1414
onModified: () -> Unit,
1515
): String {
16-
// Maybe a list of types.
16+
// Maybe a list of types. Unlike Java's String.split(), Kotlin's split() with the default
17+
// limit = 0 preserves trailing empty segments, so descriptor strings ending with ';'
18+
// (e.g. "Lorg/package/ClassA;") round-trip correctly.
1719
val newName = name.split(';').joinToString(";") { realMap(it, mapLiterals) }
1820
if (newName != name) {
1921
onModified()

0 commit comments

Comments
 (0)