Integrated: 8277501: Revisit PathFileObject.getCharContent and friends

Archie L. Cobbs duke at openjdk.org
Fri Mar 31 23:21:17 UTC 2023


On Sun, 26 Feb 2023 00:16:43 GMT, Archie L. Cobbs <duke at openjdk.org> wrote:

> The method `BaseFileManager.makeByteBuffer()` assumes that the result from`InputStream.available()` is always accurate, but this is not guaranteed.
> 
> This patch cleans up this logic by piggybacking on a similar cleanup that was recently done for [JDK-8302514](https://bugs.openjdk.org/browse/JDK-8302514).
> 
> This change also makes a couple of other changes:
> 
> (1) Adjust the sematics of `ByteBuffer.appendStream()` so that it doesn't also close the input, which is abnormal for a method like this.
> 
> (2) Add synchronization to the buffer caching in `BaseFileManager.makeByteBuffer()` because, according to the API documentation for `JavaFileManager`:
>> An object of this interface is not required to support multi-threaded access, that is, be synchronized. However, it must support concurrent access to different file objects created by this object. 
> 
> `BaseFileManager.makeByteBuffer()` is invoked from `PathFileObject` and so the per-file object thread-safety requirement would apply here.

This pull request has now been integrated.

Changeset: 8eb4e7e0
Author:    Archie L. Cobbs <archie.cobbs at gmail.com>
Committer: Vicente Romero <vromero at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/8eb4e7e07e9211aabcb0f22696e9c572dac7a59f
Stats:     93 lines in 3 files changed: 27 ins; 34 del; 32 mod

8277501: Revisit PathFileObject.getCharContent and friends

Reviewed-by: vromero, jjg

-------------

PR: https://git.openjdk.org/jdk/pull/12755


More information about the compiler-dev mailing list