JDK-8289570 : SegmentAllocator:allocateUtf8String(String str) default behavior mismatch to spec
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang.foreign
  • Affected Version: 19
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-07-01
  • Updated: 2022-07-27
  • Resolved: 2022-07-01
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 19 JDK 20
19 b30Fixed 20Fixed
Related Reports
Cloners :  
Description
As per the spec of 
https://download.java.net/java/early_access/jdk19/docs/api/java.base/java/lang/foreign/SegmentAllocator.html#allocateUtf8String(java.lang.String)

the default implementation for this method copies the contents of the provided Java string into a new memory segment obtained by calling this.allocate(str.length() + 1).

Expectations :

invoking allocateUtf8String(String str) shall delegate a call to allocate(long)

Actual :

The method allocate(long) not invoked, instead allocate(long, long) is invoked.

Comments
Changeset: 8e01ffb3 Author: Maurizio Cimadamore <mcimadamore@openjdk.org> Date: 2022-07-01 21:46:07 +0000 URL: https://git.openjdk.org/jdk19/commit/8e01ffb3a7914a67a66ce284029f19cdf845b626
01-07-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk19/pull/99 Date: 2022-07-01 11:28:10 +0000
01-07-2022