Integrated: 8155259: Suspicious buffer allocation in com.sun.tools.javac.file.BaseFileManager

Archie L. Cobbs duke at openjdk.org
Wed Jan 4 16:05:00 UTC 2023


On Thu, 20 Oct 2022 20:15:12 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.

This pull request has now been integrated.

Changeset: 6a07fd0e
Author:    Archie L. Cobbs <archie.cobbs at gmail.com>
Committer: Vicente Romero <vromero at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/6a07fd0ec1e6b57ffff852bcdc4f3304ac828018
Stats:     1 line in 1 file changed: 0 ins; 0 del; 1 mod

8155259: Suspicious buffer allocation in com.sun.tools.javac.file.BaseFileManager
8172106: javac throws exception when compiling source file of size 1.5G

Reviewed-by: vromero

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

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


More information about the compiler-dev mailing list