Fix Version/s: 12
Compatibility Risk Description:new system property, for use with source launcher (only)
Interface Kind:System or security property
Add a system property to get the filesystem path of the source file when the source launcher is being used.
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.
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.
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.