From 9c0b051bdaad56824cae5d037f34588a2c2704db Mon Sep 17 00:00:00 2001 From: Him188 Date: Tue, 13 Sep 2022 15:23:30 +0800 Subject: [PATCH] Fix RelocatorRemapper: do not map inner class name if not changed --- .../shadow/impl/RelocatorRemapper.groovy | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/impl/RelocatorRemapper.groovy b/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/impl/RelocatorRemapper.groovy index b994463d1..29d590c49 100644 --- a/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/impl/RelocatorRemapper.groovy +++ b/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/impl/RelocatorRemapper.groovy @@ -115,4 +115,32 @@ class RelocatorRemapper extends Remapper { mapPath(path.pathString) } -} + @Override + String mapInnerClassName(String name, String ownerName, String innerName) { + final String remappedInnerName = this.mapType(name) + + if (remappedInnerName == name) { + return innerName + } else { + int originSplit = name.lastIndexOf('/') + int remappedSplit = remappedInnerName.lastIndexOf('/') + if (originSplit != -1 && remappedSplit != -1) { + if (name.substring(originSplit) == remappedInnerName.substring(remappedSplit)) { + // class name not changed + return innerName + } + } + } + + if (remappedInnerName.contains('$')) { + int index = remappedInnerName.lastIndexOf('$') + 1 + while (index < remappedInnerName.length() + && Character.isDigit(remappedInnerName.charAt(index))) { + index++ + } + return remappedInnerName.substring(index) + } else { + return innerName + } + } +} \ No newline at end of file