Skip to content

Commit 31aff58

Browse files
committed
Cleanups
1 parent 5095baa commit 31aff58

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

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

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,11 @@ internal fun FileCopyDetails.remapClass(
2929
var modified = false
3030
val remapper = RelocatorRemapper(relocators) { modified = true }
3131

32-
// We don't pass the ClassReader here. This forces the ClassWriter to rebuild the constant
33-
// pool.
34-
// Copying the original constant pool should be avoided because it would keep references
35-
// to the original class names. This is not a problem at runtime (because these entries in
36-
// the
37-
// constant pool are never used), but confuses some tools such as Felix's
38-
// maven-bundle-plugin
39-
// that use the constant pool to determine the dependencies of a class.
32+
// We don't pass the ClassReader here. This forces the ClassWriter to rebuild the constant pool.
33+
// Copying the original constant pool should be avoided because it would keep references to the
34+
// original class names. This is not a problem at runtime (because these entries in the constant
35+
// pool are never used), but confuses some tools such as Felix's maven-bundle-plugin that use
36+
// the constant pool to determine the dependencies of a class.
4037
val cw = ClassWriter(0)
4138
val cr = ClassReader(bytes)
4239
val cv = ClassRemapper(cw, remapper)
@@ -47,13 +44,8 @@ internal fun FileCopyDetails.remapClass(
4744
throw GradleException("Error in ASM processing class $path", t)
4845
}
4946

50-
val newBytes =
51-
if (modified) {
52-
cw.toByteArray()
53-
} else {
54-
// If we didn't need to change anything, keep the original bytes as-is
55-
bytes
56-
}
47+
// If we didn't need to change anything, keep the original bytes as-is.
48+
val newBytes = if (modified) cw.toByteArray() else bytes
5749

5850
// Temporarily remove the multi-release prefix.
5951
val multiReleasePrefix = "^META-INF/versions/\\d+/".toRegex().find(path)?.value.orEmpty()

0 commit comments

Comments
 (0)