-
Notifications
You must be signed in to change notification settings - Fork 63
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
Use java to detect standard JAR/JIMAGE paths #1022
Comments
This would be very nice. It means I could get rid of my It might also be useful to have a way to make |
Most of the action happens in: * The new `SAWScript.JavaTools` module, which exports functionality for locating a Java executable and finding its system properties. * `SAWScript.Options`, which now exposes a new `--java-bin-dirs` flag. (Alternatively, one can use the `PATH`.) The `processEnv` function now performs additional post-processing based on whether `--java-bin-dirs`/`PATH` are set. Fixes #1022, and paves the way to a better user experience for #861.
Most of the action happens in: * The new `SAWScript.JavaTools` module, which exports functionality for locating a Java executable and finding its system properties. * `SAWScript.Options`, which now exposes a new `--java-bin-dirs` flag. (Alternatively, one can use the `PATH`.) The `processEnv` function now performs additional post-processing based on whether `--java-bin-dirs`/`PATH` are set. Fixes #1022, and paves the way to a better user experience for #861.
Most of the action happens in: * The new `SAWScript.JavaTools` module, which exports functionality for locating a Java executable and finding its system properties. * `SAWScript.Options`, which now exposes a new `--java-bin-dirs` flag. (Alternatively, one can use the `PATH`.) The `processEnv` function now performs additional post-processing based on whether `--java-bin-dirs`/`PATH` are set. Fixes #1022, and paves the way to a better user experience for #861. Other things: * I ended up cargo-culting some `process`-related code from `SAWScript.Builtins` for use in `SAWScript.JavaTools`. To avoid blatant code duplication (and because I end up needing the exact same code later in another patch), I factored out this code into the new `SAWScript.ProcessUtils` module. I considered putting it in the existing `SAWScript.Utils` module, but that would have led to import cycles. Sigh.
Most of the action happens in: * The new `SAWScript.JavaTools` module, which exports functionality for locating a Java executable and finding its system properties. * `SAWScript.Options`, which now exposes a new `--java-bin-dirs` flag. (Alternatively, one can use the `PATH`.) The `processEnv` function now performs additional post-processing based on whether `--java-bin-dirs`/`PATH` are set. Fixes #1022, and paves the way to a better user experience for #861. Other things: * I ended up cargo-culting some `process`-related code from `SAWScript.Builtins` for use in `SAWScript.JavaTools`. To avoid blatant code duplication (and because I end up needing the exact same code later in another patch), I factored out this code into the new `SAWScript.ProcessUtils` module. I considered putting it in the existing `SAWScript.Utils` module, but that would have led to import cycles. Sigh.
Currently, using SAW to verify Java code requires manually specifying the path to where your JDK installation's
rt.jar
file lives with the-j
flag. This is rather cumbersome, and this will likely be even more cumbersome after #861 is fixed, since that will require knowing about even more standard paths:modules
file (a JIMAGE file), andbin
directory, which contains utilities such asjimage
.However, having to specify all of these paths is a bit redundant. If we specify the path to your JDK installation's
bin
directory, that gives SAW access tojava
, andjava
is well equipped to tell you where the other paths are. For example, here isjava
11 can tell you:In particular, this line:
Is the key piece of information needed to find everything else. Utilities like
jimage
, for instance, will be located at<java.home>/bin/jimage
. If using Java 9 or later, the standardmodules
file is located at<java.home>/lib/modules
, so SAW can automatically add this to the module path. If using Java 8 or earlier, the standardrt.jar
file is located at<java.home>/jre/lib/rt.jar
, so SAW can automatically add this to the class path.In fact, we can go one step further. The path to your JDK installation's
bin
directory is, in many cases, also on yourPATH
. We could take advantage of this in SAW by first consulting thePATH
to see ifjava
is found there. This would allow using SAW to verify Java code without having to manually specify any special paths, which would be a huge usability win.The text was updated successfully, but these errors were encountered: