Context
As discussed in PR #2439, JBang now honors more JAR manifest attributes like Enable-Native-Access, Add-Opens, and Add-Exports. This brings JBang closer to java -jar behavior, but also means that broken or incompatible manifest attributes could prevent JARs from running.
Use Case
Users may encounter third-party JARs with:
- Malformed manifest attributes they cannot fix (closed-source JARs)
- Attributes that fail validation on newer Java versions but would work on older versions
- Experimental or non-standard attributes that cause issues
Currently, users have limited workarounds and may be blocked from running otherwise functional JARs.
Proposed Solution
Add a --ignore-manifest flag that allows users to skip specific manifest attributes:
# Ignore a single attribute
jbang --ignore-manifest=Enable-Native-Access run broken.jar
# Ignore multiple attributes
jbang --ignore-manifest=Enable-Native-Access,Add-Opens run broken.jar
Implementation Notes
- Should work as an escape hatch for any manifest attribute JBang reads
- Could accept comma-separated list of attribute names
- Attributes that are ignored should be completely skipped (not passed to JVM)
- Could potentially add a warning when attributes are ignored
Alternatives Considered
- Always validate strictly: too restrictive, goes against "make Java easy" philosophy
- Always pass through without validation: current approach, but no escape hatch for broken JARs
This flag provides the best of both worlds: honor manifest attributes by default, but give users control when needed.
Related
Context
As discussed in PR #2439, JBang now honors more JAR manifest attributes like
Enable-Native-Access,Add-Opens, andAdd-Exports. This brings JBang closer tojava -jarbehavior, but also means that broken or incompatible manifest attributes could prevent JARs from running.Use Case
Users may encounter third-party JARs with:
Currently, users have limited workarounds and may be blocked from running otherwise functional JARs.
Proposed Solution
Add a
--ignore-manifestflag that allows users to skip specific manifest attributes:Implementation Notes
Alternatives Considered
This flag provides the best of both worlds: honor manifest attributes by default, but give users control when needed.
Related
Enable-Native-Access,Add-Opens,Add-Exportsjbang run <jarFile>ignoresEnable-Native-Accessproperty in the manifest.mf file #2366, jbang run <jarFile> ignores Add-Opens property in the MANIFEST.MF file #2438 - original issues about manifest handling