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

Replace javasrc2cpg ReflectionTypeSolver with JdkJarTypeSolver at java home #3006

Merged
merged 10 commits into from
Jul 20, 2023

Conversation

johannescoetzee
Copy link
Contributor

Using the ReflectionTypeSolver and the JdkJarTypeSolver with jars from the current runtime java home give similar, but not identical results. This is problematic for getting consistent results, particularly when updating expectations for SP tests. This PR switches to the JdkJarTypeSolver as the single "java stdlib" type solver for the sake of consistency.

@johannescoetzee johannescoetzee requested a review from ml86 July 4, 2023 17:08
combinedTypeSolver.add(new CachingReflectionTypeSolver())
val jdkPath = config.jdkPath.getOrElse {
val javaHome = System.getProperty("java.home")
logger.debug("No explicit jdkPath set in config, so using system java.home at $javaHome")
Copy link
Contributor

Choose a reason for hiding this comment

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

That is definitely worth logging as INFO

}
}

enum JavaSrcEnvVar(val name: String, val description: String) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is perhaps excessive for a single environment variabl, but I also think that, if environment variables are going to be used for configuration, they should be documented somehow and easily discoverable. I plan to extend this idea to the rest of joern (I know at least php2cpg uses some environment variables as well), but put this here since it's currently limited to javasrc.

@johannescoetzee johannescoetzee requested a review from ml86 July 7, 2023 09:26
@johannescoetzee
Copy link
Contributor Author

Unit tests are running into OutOfMemory errors, so that's something to investigate before merging.

// This should really be a print-and-exit but, with the current scopt setup, input paths
// are still required, so for now `javasrc2cpg --show-env <inputs>` is less confusing
// than `javasrc2cpg --show-env <dummy input to keep scopt happy>`
.text("print information about environment variables used by javasrc2cpg prior to analysis")
Copy link
Contributor

Choose a reason for hiding this comment

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

Add to the comment that this prevents the frontend from doing its actual task.

@johannescoetzee
Copy link
Contributor Author

Running just the javasrc2cpg test suite locally doesn't seem to be using much heap memory at all (less than 160M), so I suspect we're very close to the limit and slightly increased memory use from this was just enough to push us over. This theory is still to be confirmed.

@johannescoetzee johannescoetzee force-pushed the johannes/jdk-type-solver-by-default branch 2 times, most recently from 76cadb7 to 700fe37 Compare July 11, 2023 14:09
@johannescoetzee johannescoetzee force-pushed the johannes/jdk-type-solver-by-default branch from 3bb01e4 to cacd5cf Compare July 19, 2023 08:59
@johannescoetzee johannescoetzee merged commit 336739c into master Jul 20, 2023
5 checks passed
@johannescoetzee johannescoetzee deleted the johannes/jdk-type-solver-by-default branch July 20, 2023 13:33
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.

3 participants