Skip to content

Resolve parsing issue for module-info classes with multiple exports#4962

Merged
johannescoetzee merged 2 commits into
javaparser:masterfrom
mrjameshamilton:jhamilton/module-info-parsing-fix
Jan 28, 2026
Merged

Resolve parsing issue for module-info classes with multiple exports#4962
johannescoetzee merged 2 commits into
javaparser:masterfrom
mrjameshamilton:jhamilton/module-info-parsing-fix

Conversation

@mrjameshamilton

Copy link
Copy Markdown
Contributor

When using version 3.28.0, I encountered the following exception when parsing the module-info.class from a jar (junit-jupiter-api-5.11.4.jar):

java.lang.NullPointerException: Cannot read field "name" because "mi" is null
        at javassist.bytecode.ConstPool.getPackageInfo(ConstPool.java:842)
        at com.github.javaparser.symbolsolver.utils.JavassistModuleHelper.getModuleWithExportedPackages(JavassistModuleHelper.java:79)
        at com.github.javaparser.symbolsolver.resolution.typesolvers.JarTypeSolver.registerModuleInfo(JarTypeSolver.java:206)
        at com.github.javaparser.symbolsolver.resolution.typesolvers.JarTypeSolver.addPathToJar(JarTypeSolver.java:193)
        at com.github.javaparser.symbolsolver.resolution.typesolvers.JarTypeSolver.<init>(JarTypeSolver.java:138)
        at com.github.javaparser.symbolsolver.resolution.typesolvers.JarTypeSolver.<init>(JarTypeSolver.java:127)
        at com.github.javaparser.symbolsolver.resolution.typesolvers.JarTypeSolver.<init>(JarTypeSolver.java:116)

The cause of the issue is the parsing of the module file in the JavassistModuleHelper class. This PR fixes the parsing issue and updates the example in test resources to include multiple exports, exportsTo and an opens entry (the updated sample would trigger the same NPE).

@jlerbsc

jlerbsc commented Jan 27, 2026

Copy link
Copy Markdown
Collaborator

@johannescoetzee Can you approve this PR?

@johannescoetzee johannescoetzee left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrjameshamilton Good catch! This looks good to me, so can be merged once the PR tests have passed. Thanks for the contribution :)

@codecov

codecov Bot commented Jan 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.659%. Comparing base (2146cfc) to head (11e85eb).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff               @@
##              master     #4962       +/-   ##
===============================================
+ Coverage     58.657%   58.659%   +0.001%     
  Complexity      2564      2564               
===============================================
  Files            699       699               
  Lines          40121     40120        -1     
  Branches        7314      7314               
===============================================
  Hits           23534     23534               
  Misses         13620     13620               
+ Partials        2967      2966        -1     
Flag Coverage Δ
AlsoSlowTests 58.659% <100.000%> (+0.001%) ⬆️
javaparser-core 58.659% <100.000%> (+0.001%) ⬆️
javaparser-symbol-solver 58.659% <100.000%> (+0.001%) ⬆️
jdk-10 58.230% <100.000%> (+0.003%) ⬆️
jdk-11 58.229% <100.000%> (+0.001%) ⬆️
jdk-12 58.229% <100.000%> (+0.001%) ⬆️
jdk-13 58.227% <100.000%> (-0.002%) ⬇️
jdk-14 58.461% <100.000%> (+0.001%) ⬆️
jdk-15 58.461% <100.000%> (+0.001%) ⬆️
jdk-16 58.436% <100.000%> (+0.001%) ⬆️
jdk-17 58.583% <100.000%> (-0.002%) ⬇️
jdk-18 58.586% <100.000%> (+0.001%) ⬆️
jdk-8 58.066% <45.000%> (+0.003%) ⬆️
jdk-9 58.228% <100.000%> (+0.003%) ⬆️
macos-latest 58.634% <100.000%> (+0.001%) ⬆️
ubuntu-latest 58.629% <100.000%> (+0.001%) ⬆️
windows-latest 58.641% <100.000%> (+0.001%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...parser/printer/lexicalpreservation/Difference.java 80.353% <ø> (ø)
...ter/lexicalpreservation/IndentationCalculator.java 91.780% <100.000%> (ø)
...nter/lexicalpreservation/IndentationConstants.java 0.000% <ø> (ø)
...rinter/lexicalpreservation/IndentationContext.java 100.000% <ø> (ø)
...ter/lexicalpreservation/IndexTrackingIterator.java 72.000% <100.000%> (ø)
.../lexicalpreservation/LexicalPreservingPrinter.java 74.788% <100.000%> (ø)
...vaparser/printer/lexicalpreservation/NodeText.java 50.909% <ø> (ø)
...inter/lexicalpreservation/TextElementIterator.java 100.000% <100.000%> (ø)
...r/printer/lexicalpreservation/TextElementList.java 96.250% <ø> (ø)
...inter/lexicalpreservation/TextElementSequence.java 100.000% <ø> (ø)
... and 3 more

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 981bf54...11e85eb. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mrjameshamilton

Copy link
Copy Markdown
Contributor Author

@mrjameshamilton Good catch! This looks good to me, so can be merged once the PR tests have passed. Thanks for the contribution :)

Great, thanks! There were unrelated formatting issues, I've run ./run_core_metamodel_generator.sh && ./run_core_generators.sh and pushed a new commit with the formatting changes

@johannescoetzee johannescoetzee added the PR: Fixed A PR that offers a fix or correction label Jan 28, 2026
@johannescoetzee johannescoetzee added this to the next release milestone Jan 28, 2026
@johannescoetzee johannescoetzee merged commit e42de1a into javaparser:master Jan 28, 2026
35 checks passed
@jlerbsc

jlerbsc commented Jan 28, 2026

Copy link
Copy Markdown
Collaborator

Apologies for the formatting issues. It was my fault for not doing what was necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Fixed A PR that offers a fix or correction

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants