Skip to content

Use JrtModule consistently to handle standard library on modern JDKs#1879

Merged
msridhar merged 24 commits intowala:masterfrom
msridhar:issue-1876
Apr 19, 2026
Merged

Use JrtModule consistently to handle standard library on modern JDKs#1879
msridhar merged 24 commits intowala:masterfrom
msridhar:issue-1876

Conversation

@msridhar
Copy link
Copy Markdown
Member

@msridhar msridhar commented Apr 13, 2026

Fixes #1876

Before this change, we would load standard library jmod files for recent JDKs from a well-known place in the filesystem. But, certain JDK distributions like Temurin no longer distribute such files directly. This change allows WALA to run on such JDKs, by loading the standard library files via the pre-existing JrtModule support, which loads the files via a special virtual filesystem. This will be a nice benefit for WALA users, since WALA will be able to load the running JVM's standard libraries out of the box on recent versions of JDKs like Temurin that don't package jmod files. To ensure this support doesn't regress, we now install Temurin JDKs by default on CI, and we no longer specifically request Zulu JDKs (which include jmod files) in our Java toolchain configuration.

There are some API-incompatible changes in this PR. In particular, WalaProperties.getJ2SEJarFiles now can throw a NoJDKLibraryFilesFoundException if there are no standard library files distributed with the JDK, in which case client code should fall back on calling PlatformUtil.getJDKModuleNames and then loading the modules via JrtModule. It would be nice to have a single clean code path for handling all these cases, but it's not straightforward, given we still want to support loading standard libraries specified in scope files.

There are a couple of cases where tests passed without even loading the standard library; so for now, I just left TODO comments on those to do more detailed handling in the future.

Other related changes:

  • Moved the functionality from Java9AnalysisScopeReader into AnalysisScopeReader, and deprecated the former.
  • This PR exposed another bug which is that Shrike did not yet support CONSTANT_Dynamic constant pool entries (exposed since these changes caused all library modules to be loaded on modern JDKs for the first time); add basic support for those.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 13, 2026

Test Results

  979 files  ±0    979 suites  ±0   6h 19m 37s ⏱️ - 13m 23s
  803 tests ±0    784 ✅ ±0   19 💤 ±0  0 ❌ ±0 
6 308 runs  ±0  6 154 ✅ ±0  154 💤 ±0  0 ❌ ±0 

Results for commit 2ba0afd. ± Comparison against base commit 63103de.

♻️ This comment has been updated with latest results.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.43%. Comparing base (63103de) to head (2ba0afd).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
.../src/main/java/com/ibm/wala/util/PlatformUtil.java 55.55% 8 Missing ⚠️
...java/com/ibm/wala/ipa/callgraph/AnalysisScope.java 70.00% 3 Missing ⚠️
.../main/java/com/ibm/wala/core/java11/JrtModule.java 33.33% 1 Missing and 1 partial ⚠️
...bm/wala/cast/java/ecj/util/SourceDirCallGraph.java 0.00% 1 Missing ⚠️
...in/java/com/ibm/wala/core/java11/LibraryStuff.java 0.00% 1 Missing ⚠️
...ibm/wala/core/util/config/AnalysisScopeReader.java 66.66% 0 Missing and 1 partial ⚠️
...n/java/com/ibm/wala/properties/WalaProperties.java 66.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1879      +/-   ##
============================================
- Coverage     50.47%   50.43%   -0.04%     
+ Complexity    12680    12668      -12     
============================================
  Files          1366     1366              
  Lines         84890    84889       -1     
  Branches      14484    14484              
============================================
- Hits          42847    42815      -32     
- Misses        37317    37345      +28     
- Partials       4726     4729       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@msridhar msridhar marked this pull request as ready for review April 17, 2026 02:32
@msridhar msridhar requested review from juliandolby and liblit April 17, 2026 02:42
@msridhar
Copy link
Copy Markdown
Member Author

@julian-certora @juliandolby FYI in case you see any issues

@msridhar
Copy link
Copy Markdown
Member Author

Also, reported test coverage of this patch is misleadingly low. The issue is that some code paths are only exercised on JDK 25, but we don't upload coverage results from JDK 25 CI jobs to codecov (we only upload from JDK 17). I wonder if we could upload coverage files from multiple CI jobs and it would work? But I think we should explore that separately.

@msridhar msridhar changed the title [draft] Use Jrt support consistently Use JrtModule consistently to handle standard library on modern JDKs Apr 17, 2026
@msridhar msridhar enabled auto-merge April 17, 2026 02:44
@msridhar msridhar disabled auto-merge April 17, 2026 02:44
Comment thread core/src/main/java/com/ibm/wala/core/util/config/AnalysisScopeReader.java Outdated
Comment on lines +77 to +78
if (jar.endsWith(File.separator + "rt.jar")
|| jar.endsWith(File.separator + "classes.jar")) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These checks make it clear that the value returned by WalaProperties.getJ2SEJarFIles is semantically a Path, not just an arbitrary String. Should we make that official by changing the return types of WalaProperties.getJ2SEJarFIles and WalaProperties.getJDKLibraryFiles? That's a non-backward-compatible change, but this PR are already proposes non-backward-compatible changes to those two methods by changing their throws declarations.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Is it ok to address this one also in a follow-up? I think it's a good cleanup and I'm fine with breaking backward compatibility, but it's going to involve a bunch of code churn in tests and I'd rather do it in a separate PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it ok to address this one also in a follow-up?

Certainly!

Comment thread shrike/src/main/java/com/ibm/wala/shrike/shrikeBT/Constants.java
Comment thread util/src/main/java/com/ibm/wala/util/PlatformUtil.java Outdated
Comment thread util/src/main/java/com/ibm/wala/util/PlatformUtil.java Outdated
Comment thread util/src/main/java/com/ibm/wala/util/PlatformUtil.java
@msridhar
Copy link
Copy Markdown
Member Author

@liblit thanks for the careful review! I think this is ready for another look. Note that I deleted the PlatformUtil.getJDKModules method, so now we only support reading JDK library modules via the jrt filesystem support, to limit the number of code paths we need to maintain.

@julian-certora
Copy link
Copy Markdown
Contributor

@julian-certora @juliandolby FYI in case you see any issues

Quite the opposite; i like the idea of using jrt systematically, and Solidity support currently doesn't use Java stdlibs.

juliandolby
juliandolby previously approved these changes Apr 18, 2026
Copy link
Copy Markdown
Contributor

@juliandolby juliandolby left a comment

Choose a reason for hiding this comment

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

I vaguely recall once trying to make the Java source front end work with JRT, but I never managed it. Maybe that was an older version of Eclipse... I like this change.

@msridhar
Copy link
Copy Markdown
Member Author

I vaguely recall once trying to make the Java source front end work with JRT, but I never managed it. Maybe that was an older version of Eclipse... I like this change.

Yeah, it seems to work now, at least the regression tests pass 🙂 Codex was helpful for figuring out that one.

Copy link
Copy Markdown
Contributor

@liblit liblit left a comment

Choose a reason for hiding this comment

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

Just one remaining nit: a static block that could probably be a simple field initialization expression as part of the field declaration.

Comment on lines +77 to +78
if (jar.endsWith(File.separator + "rt.jar")
|| jar.endsWith(File.separator + "classes.jar")) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it ok to address this one also in a follow-up?

Certainly!

Comment thread cast/java/src/testFixtures/java/com/ibm/wala/cast/java/test/IRTests.java Outdated
@msridhar msridhar added this pull request to the merge queue Apr 19, 2026
Merged via the queue into wala:master with commit aef680a Apr 19, 2026
13 of 14 checks passed
@msridhar msridhar deleted the issue-1876 branch April 19, 2026 14:39
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.

Remove redundancy between JrtModule and JDK module support

4 participants