RFR: 8277501: Revisit PathFileObject.getCharContent and friends [v2]
Jonathan Gibbons
jjg at openjdk.org
Fri Mar 31 23:12:37 UTC 2023
On Tue, 21 Mar 2023 23:06:51 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.
>
> Archie L. Cobbs has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains three commits:
>
> - Merge branch 'master' into JDK-8277501
> - Avoid over-reliance on InputStream.available() in BaseFileManager.makeByteBuffer().
> - Adjust the semantics of ByteBuffer.appendStream() to not close the stream.
Marked as reviewed by jjg (Reviewer).
-------------
PR Review: https://git.openjdk.org/jdk/pull/12755#pullrequestreview-1367732366
More information about the compiler-dev
mailing list