Skip to content

Fix field access flags preservation and module exports/opens relocation in RelocatorRemapper#1952

Merged
Goooler merged 3 commits intog/20260115/JEP-484from
copilot/sub-pr-1902
Mar 3, 2026
Merged

Fix field access flags preservation and module exports/opens relocation in RelocatorRemapper#1952
Goooler merged 3 commits intog/20260115/JEP-484from
copilot/sub-pr-1902

Conversation

Copy link
Contributor

Copilot AI commented Mar 3, 2026

Two correctness bugs in the Class-File API-based RelocatorRemapper:

  • Field flags preserved: withField(...) was not forwarding the original access flags (public, static, final, etc.), potentially emitting fields with incorrect modifiers. Fixed by using withField(String, ClassDesc, Consumer) and calling fb.withFlags(cle.flags().flagsMask()) inside the lambda — necessary because ClassBuilder.withField has no (String, ClassDesc, int, Consumer) overload unlike withMethod.

  • Module exports/opens relocated: ModuleAttribute handling passed exports() and opens() through unchanged. These carry package names in internal format; if packages are relocated, the module descriptor would still reference pre-relocation packages, breaking JPMS at runtime. Fixed by remapping each entry via PackageDesc.ofInternalName(map(...)) and reconstructing ModuleExportInfo/ModuleOpenInfo.


  • CHANGELOG's "Unreleased" section has been updated, if applicable.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: Goooler <10363352+Goooler@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 3, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-25-jdk-amd64/bin/java /usr/lib/jvm/temurin-25-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED --enable-native-access=ALL-UNNAMED -Xmx4g -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en (dns block)
  • scans-in.gradle.com
    • Triggering command: /usr/lib/jvm/temurin-25-jdk-amd64/bin/java /usr/lib/jvm/temurin-25-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED --enable-native-access=ALL-UNNAMED -Xmx4g -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Migrate from ASM to Class-File API Fix field access flags preservation and module exports/opens relocation in RelocatorRemapper Mar 3, 2026
@Goooler
Copy link
Member

Goooler commented Mar 3, 2026

@copilot Fix the issues

…pper

Co-authored-by: Goooler <10363352+Goooler@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 3, 2026

@copilot Fix the issues

Fixed in commit 5c2104c. Two CI failures:

  1. Compilation error: ClassBuilder.withField() has no (String, ClassDesc, int, Consumer) overload (unlike withMethod). Fixed by using withField(String, ClassDesc, Consumer) and calling fb.withFlags(cle.flags().flagsMask()) inside the lambda to preserve access flags.

  2. Spotless format violation: The long clb.constantPool().packageEntry(PackageDesc.ofInternalName(...)) lines exceeded the line length limit. Reformatted as chained method calls split across multiple lines.

@Goooler Goooler marked this pull request as ready for review March 3, 2026 10:59
@Goooler Goooler merged commit 6feb90e into g/20260115/JEP-484 Mar 3, 2026
6 checks passed
@Goooler Goooler deleted the copilot/sub-pr-1902 branch March 3, 2026 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants