Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to only analyze a subset of standard lib from running JVM #1286

Merged
merged 34 commits into from
Jul 5, 2023

Conversation

msridhar
Copy link
Member

@msridhar msridhar commented Jul 5, 2023

Before, when performing Java bytecode analysis using the standard library from the running JVM, we would always include all the standard library jar / jmod files. Now that WALA only runs on JDK 11+, which has a modularized standard library, it makes sense to support strategies where only a subset of the modules are analyzed.

This PR adds support for such alternate strategies as follows. First, we add a base option for the stdlib line in scope files, such that when used, only the java.base module is added to the AnalysisScope. Additional JDK modules can be added via the scope file via a new jdkModule line and the module name. We also add corresponding APIs, AnalysisScopeReader.makeBasePrimordialScope and AnalysisScope.addJDKModuleToScope. By default, WALA client behavior remains the same; clients must make use of these new features / APIs to opt into new behavior.

The core module regression tests have been rewritten to minimize the number of modules included for the analyses; most tests can pass when just including java.base. Surprisingly, the tests still take significantly longer to run on JDK 17 than on JDK 11; we should investigate why in the future.

Some code only relevant when running on pre-JDK-11 JVMs has also been cleaned up / removed.

@msridhar msridhar marked this pull request as ready for review July 5, 2023 19:58
String javaVersion = System.getProperty("java.specification.version");
if (!javaVersion.equals("1.8")) {
// java11 support for jmod files
public static String[] getJDKModules(boolean justBase) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm all about that bass, 'bout that bass, no treble
I'm all about that bass, 'bout that bass, no treble
I'm all about that bass, 'bout that bass (bass, bass, bass, bass)

🎶

@msridhar msridhar merged commit 976bdbf into wala:master Jul 5, 2023
@msridhar msridhar deleted the tinker-with-jmod branch July 5, 2023 23:29
@liblit
Copy link
Contributor

liblit commented Jul 5, 2023

Nice work, @msridhar!

@msridhar
Copy link
Member Author

msridhar commented Jul 5, 2023

Thanks @liblit! At least for some clients this should give a nice perf win

msridhar added a commit to uber/NullAway that referenced this pull request Aug 11, 2023
We use a [new WALA feature](wala/WALA#1286) to
only include the `java.base` module in the `AnalysisScope` used for
JarInfer. JarInfer does not require all JDK standard library modules to
be part of the analysis scope, just enough to make a valid class
hierarchy, and `java.base` suffices. This should speed up runs of
JarInfer, and in particular it speeds up our JarInfer regression tests.
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.

2 participants