JDK-8033917 : Keep track of file paths in file streams and channels for instrumentation purposes
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 8u20,9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2014-02-07
  • Updated: 2014-10-02
  • Resolved: 2014-02-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
8u20Fixed 9 b04Fixed
Related Reports
Relates :  
Instrumentation agents that want to instrument FileInputStream/FileOutputStream to see which files are being accessed do not currently have access to the file system path of the stream. This is because the path is never stored in the stream class, only the file descriptor is. (This is also true for RandomAccessFile and FileChannel).

An agent could instrument the respective constructors to store the path. The problem is where to store it. To add a field, the instrumentation agent needs to change the schema of the class. This is not possible at runtime but can be done at class-loading time. However for a j.l.instrument agent these classes are already defined when the agent is first called. For a native JVMTI agent the problem becomes parsing and modifying byte codes in a native agent which is error prone and requires a lot of code to maintain.

If instead the stream classes were modified to store a reference to the path, it would be readily available for agents at a minimum of cost to the libraries.

A consumer of this feature will be Java Flight Recorder, but the implementation is usable by other agents as well.