Skip to content

Commit 6feb90e

Browse files
CopilotGoooler
andauthored
Fix field access flags preservation and module exports/opens relocation in RelocatorRemapper
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Goooler <10363352+Goooler@users.noreply.github.com>
1 parent 51e6816 commit 6feb90e

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

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

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import java.lang.classfile.attribute.ExceptionsAttribute
2424
import java.lang.classfile.attribute.InnerClassInfo
2525
import java.lang.classfile.attribute.InnerClassesAttribute
2626
import java.lang.classfile.attribute.ModuleAttribute
27+
import java.lang.classfile.attribute.ModuleExportInfo
28+
import java.lang.classfile.attribute.ModuleOpenInfo
2729
import java.lang.classfile.attribute.ModuleProvideInfo
2830
import java.lang.classfile.attribute.NestHostAttribute
2931
import java.lang.classfile.attribute.NestMembersAttribute
@@ -55,6 +57,7 @@ import java.lang.constant.DynamicCallSiteDesc
5557
import java.lang.constant.DynamicConstantDesc
5658
import java.lang.constant.MethodHandleDesc
5759
import java.lang.constant.MethodTypeDesc
60+
import java.lang.constant.PackageDesc
5861
import java.util.regex.Pattern
5962

6063
/**
@@ -75,7 +78,7 @@ internal class RelocatorRemapper(
7578
cle.fieldName().stringValue(),
7679
mapClassDesc(ClassDesc.ofDescriptor(cle.fieldType().stringValue())),
7780
) { fb ->
78-
fb.transform(cle, asFieldTransform())
81+
fb.withFlags(cle.flags().flagsMask()).transform(cle, asFieldTransform())
7982
}
8083
is MethodModel ->
8184
clb.withMethod(
@@ -123,8 +126,28 @@ internal class RelocatorRemapper(
123126
cle.moduleFlagsMask(),
124127
cle.moduleVersion().orElse(null),
125128
cle.requires(),
126-
cle.exports(),
127-
cle.opens(),
129+
cle.exports().map { mei ->
130+
ModuleExportInfo.of(
131+
clb
132+
.constantPool()
133+
.packageEntry(
134+
PackageDesc.ofInternalName(map(mei.exportedPackage().asSymbol().internalName()))
135+
),
136+
mei.exportsFlagsMask(),
137+
mei.exportsTo(),
138+
)
139+
},
140+
cle.opens().map { moi ->
141+
ModuleOpenInfo.of(
142+
clb
143+
.constantPool()
144+
.packageEntry(
145+
PackageDesc.ofInternalName(map(moi.openedPackage().asSymbol().internalName()))
146+
),
147+
moi.opensFlagsMask(),
148+
moi.opensTo(),
149+
)
150+
},
128151
cle.uses().map { clb.constantPool().classEntry(mapClassDesc(it.asSymbol())!!) },
129152
cle.provides().map { mp ->
130153
ModuleProvideInfo.of(

0 commit comments

Comments
 (0)