Skip to content

Simplify manifest name extraction and constant-pool name lookup - #252

Merged
slachiewicz merged 2 commits into
masterfrom
agent/sweep-jpms-ternary
Nov 18, 2026
Merged

slachiewicz merged 2 commits into
masterfrom
agent/sweep-jpms-ternary

Conversation

@slachiewicz

@slachiewicz slachiewicz commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Why

automaticModuleName was a single-use local, and packageName was a verbatim copy of className. Both add noise without changing behaviour.

A third cleanup (collapsing LocationManager.getBinaryModuleInfoParser to a ternary) was reverted in a follow-up commit: javac 25 emits a StackMapTable frame typed as ModuleInfoClassParser for that merge, but the multi-release Java 9 BinaryModuleInfoParser does not extend ModuleInfoClassParser, so failsafe ITs fail with VerifyError on JDK 9+. The original ModuleInfoParser-typed local keeps the frame at the interface type.

Area

plexus-java JPMS module-name resolution — main source only.

Changes

  • ManifestModuleNameExtractor.extract: return Automatic-Module-Name with a ternary, null when no manifest is present.
  • ModuleInfoClassParser.ConstantPool.packageName: delegate to className, whose body is identical.

No behaviour change: the same names are returned.

Verification

With JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-21.jdk/Contents/Home:

  • mvn -B -o spotless:apply — BUILD SUCCESS (0 files changed).
  • mvn -B -o spotless:check — BUILD SUCCESS.
  • mvn -B -o verify — BUILD SUCCESS; 94 unit tests + 4 LocationManagerIT tests, 0 failures, 0 errors, 0 skipped.

The single-assignment binaryParser and automaticModuleName locals existed only to return one of two values, and packageName was a verbatim copy of className. Return the chosen value directly and delegate the duplicate. No behaviour change.
The ternary merged two constructor calls whose compile-time types differ: BinaryModuleInfoParser extends ModuleInfoClassParser in the Java 8 sources, but the Java 9 multi-release variant extends AbstractBinaryModuleInfoParser. javac 25 emitted a StackMapTable frame typed as ModuleInfoClassParser at the merge, which fails verification once the MR-jar substitutes the Java 9 class. The declared ModuleInfoParser local keeps the frame at the interface type, as on green master.
@slachiewicz slachiewicz changed the title Simplify JPMS parser selection and constant-pool name lookup Simplify manifest name extraction and constant-pool name lookup Nov 18, 2026
@slachiewicz slachiewicz added the maintenance Cleanup, refactoring or other internal change label Nov 18, 2026
@slachiewicz
slachiewicz merged commit f1c05dd into master Nov 18, 2026
14 checks passed
@slachiewicz
slachiewicz deleted the agent/sweep-jpms-ternary branch November 18, 2026 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Cleanup, refactoring or other internal change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant