Skip to content

[COMPRESS-634] Preserve module descriptors when packing modular JARs - #837

Open
Clickin wants to merge 2 commits into
apache:masterfrom
Clickin:COMPRESS-634-module-pack200
Open

Clickin wants to merge 2 commits into
apache:masterfrom
Clickin:COMPRESS-634-module-pack200

Conversation

@Clickin

@Clickin Clickin commented Nov 8, 2026

Copy link
Copy Markdown

JIRA: https://issues.apache.org/jira/browse/COMPRESS-634

Packing a JAR that contains module-info.class fails with UnsupportedOperationException: Module requires ASM6 from Segment.processClasses. Raising the ASM API level alone doesn't help, because Pack200 has no bands for Module attributes.

  • Archive.addJarEntry now registers a class with ACC_MODULE as a pass file, so the descriptor is stored byte for byte. Segment.processClasses already does this for a class with an attribute whose action is "pass".
  • PackingOptions.isPassFile returned the result for the first directory entry, so a configured pass directory hid every pass entry added after it, including the descriptor above. It now checks all entries.

There is no ASM upgrade and no public API change. Not addressed: on JDK 17, unpacking directly from a FileInputStream hits the reflection problem tracked in COMPRESS-721 (PR #764).

ArchiveTest.testModuleInfo packs and unpacks a JAR with a module descriptor and one ordinary class, then checks that the descriptor bytes are identical and the class is present. Its 8 cases vary the descriptor location (root, META-INF/versions/9/), the input (JarFile, JarInputStream), the segment limit (-1, 0) and an unrelated pass directory. On master, the four cases without a pass directory fail with "Module requires ASM6". The four with one still fail without the isPassFile fix.

The default mvn build passes on JDK 17, and mvn clean test passes on JDK 8.

  • Read the contribution guidelines for this project.
  • Read the ASF Generative Tooling Guidance if you use Artificial Intelligence (AI).
  • I used AI to create any part of, or all of, this pull request. Which AI tool was used to create this pull request, and to what extent did it contribute?
    OpenAI GPT-6 Astra wrote the change and the tests; Claude Opus 5.5 reviewed them and wrote this description. The commit carries Generated-by and Assisted-By trailers.
  • Run a successful build using the default Maven goal with mvn; that's mvn on the command line by itself.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. This may not always be possible, but it is a best practice.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body. Note that a maintainer may squash commits during the merge process.

🤖 Generated with Claude Code

Pack200 cannot represent module attributes, and passing a module-info
class to the ASM visitor fails with "Module requires ASM6". Treat class
files with ACC_MODULE as pass files so their bytes are stored unchanged,
as Segment already does for a class with an attribute whose action is
"pass".

PackingOptions.isPassFile() returned after checking the first directory
entry, so a configured pass directory hid any pass file added after it.
Keep checking the remaining entries.

Generated-by: OpenAI GPT-6 Astra
Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
Bring the branch up to date with master before review.

Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
@Clickin
Clickin marked this pull request as ready for review November 8, 2026 11:37
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.

1 participant