RFR: 8277501: Revisit PathFileObject.getCharContent and friends [v2]
Jonathan Gibbons
jjg at openjdk.org
Wed Mar 29 21:53:22 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.
Is it worth renaming the internal `ByteBuffer` class to avoid the name clash?
Just asking.
The counter-argument is that we already deal with `javac.util.List` and `java.util.List`
src/jdk.compiler/share/classes/com/sun/tools/javac/util/ByteBuffer.java line 62:
> 60: }
> 61:
> 62: /** Create a new byte buffer using the given array for storage.
Generally, the style for doc comments is either a single line, or for a newline after the initial `/**`
-------------
PR Review: https://git.openjdk.org/jdk/pull/12755#pullrequestreview-1363956884
PR Review Comment: https://git.openjdk.org/jdk/pull/12755#discussion_r1152482126
More information about the compiler-dev
mailing list