-
Notifications
You must be signed in to change notification settings - Fork 344
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
JavaExecCmdUtil: use Paths.get
to join file paths
#454
base: master
Are you sure you want to change the base?
Conversation
Hi @kennyballou, Thank you for taking the time to contribute to the EvoSuite project. If understood correctly, you're proposing final String JAVA_CMD = java.nio.file.Paths.get(System.getProperty("java.home"), "bin", "java").toString(); as an alternative to final String separator = System.getProperty("file.separator");
final String JAVA_CMD = System.getProperty("java.home") + separator + "bin" + separator + "java"; right? |
b5b5236
to
d35d4cc
Compare
That's correct. I didn't remove the |
final String separator = System.getProperty("file.separator"); | ||
final String JAVA_CMD = | ||
System.getProperty("java.home") + separator + "bin" + separator + "java"; | ||
final String JAVA_CMD = Paths.get(System.getProperty("java.home"), "bin", "java").toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jose: I have amended the commit to remove the unused separator
variable.
Instead of relying on the values of the retrieved variables correctly handling trailing slashes, simply use the `Paths` utility methods to combine directory/path objects. Signed-off-by: Kenny Ballou <[email protected]>
d35d4cc
to
2767a27
Compare
@jose: I think to further explain this change, sometimes the values returned by "java.home" or other environment variables have a trailing path separator, e.g., "/", included; as is the case for me while using Guix. Therefore, the manual separator interpolating version causes the test suite to fail while looking for the Java executable. The |
Instead of relying on the values of the retrieved variables correctly handling trailing slashes, simply use the
Paths
utility methods to combine directory/path objects.