Summary
Add a system property to get the filesystem path of the source file when the source launcher is being used.
Problem
There is currently no way to access the filesystem path of the source file containing the classes in source-launcher mode. It would be convenient to have access to that value in some cases, typically in order to access related resources. This is essentially the same problem that gives rise to the use of $0 for the name of the script file when using some shell-scripting languages.
Solution
Provide a system property whose value is the filesystem path for the source file.
JDK-8210274 suggests that the code source for any classes should be set to the source file, to enable security permissions to be granted in a policy file. However, using the code source is not as obvious or as convenient as a system property.
Specification
The name of the property is jdk.launcher.sourcefile
. It will only be set when source-launcher mode is being used: i.e. while the compiled classes are being executed.
The value is the absolute filesystem path of the file containing the source that was compiled and is being executed.
- csr of
-
JDK-8209963 source file mode for JVM should provide a hook to locate the source file
-
- Resolved
-
- relates to
-
JDK-8210274 Source Launcher should work with a security manager
-
- Resolved
-