JDK-8210877 : source file mode for JVM should provide a hook to locate the source file
  • Type: CSR
  • Component: tools
  • Sub-Component: launcher
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 12
  • Submitted: 2018-09-18
  • Updated: 2018-09-21
  • Resolved: 2018-09-21
Related Reports
CSR :  
Relates :  
Description
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.


Comments
Moving to Approved.
21-09-2018