RFR: 8155259: Suspicious buffer allocation in com.sun.tools.javac.file.BaseFileManager [v3]
Vicente Romero
vromero at openjdk.org
Wed Jan 4 03:24:52 UTC 2023
On Mon, 19 Dec 2022 15:44:53 GMT, Archie L. Cobbs <duke at openjdk.org> wrote:
>> JDK-8155259 notes that in `BaseFileManager` this code:
>>
>> ByteBuffer.allocate(capacity + capacity>>1)
>>
>> is actually equivalent (assuming no overflow) to:
>>
>> ByteBuffer.allocate(capacity)
>>
>> because in Java the `+` operator has higher precedence than the `>>` operator.
>>
>> In the bug it is suggested that this be changed to reflect the presumed original intent to over-allocate by 50%, i.e.:
>>
>> ByteBuffer.allocate(capacity + (capacity>>1))
>>
>> however, this patch is more conservative in that it leaves the existing behavior alone and instead just simplifies it to:
>>
>> ByteBuffer.allocate(capacity)
>>
>> allowing us to at least resolve JDK-8155259.
>
> Archie L. Cobbs has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision:
>
> - Merge branch 'master' into JDK-8155259
> - Merge branch 'master' into JDK-8155259
> - 8155259: Suspicious buffer allocation in com.sun.tools.javac.file.BaseFileManager
looks good
-------------
Marked as reviewed by vromero (Reviewer).
PR: https://git.openjdk.org/jdk/pull/10803
More information about the compiler-dev
mailing list