[jdk19] RFR: 8289558: Need spec clarification of j.l.foreign.*Layout

Maurizio Cimadamore mcimadamore at openjdk.org
Fri Jul 1 11:12:13 UTC 2022


On Fri, 1 Jul 2022 11:03:23 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> This patch fixes few javadoc issues in the memory layout API.
> The main issues are that `SequenceLayout::flatten` and `SequenceLayout::reshape` still mention failures caused by a lack of size. But that condition is no longer possible in the new API.
> 
> The javadoc of `ValueLayout::arrayElementVarHandle` is suboptimal and can be clarified - UOE is only thrown if the value layout alignment is bigger than its size.
> 
> Finally, the `MemoryLayout::equals` method does not mention value layout carriers.
> 
> The JBS issue associated with this PR mentions also other issues, mostly related to the overly broad visibility of some of the methods in the javadoc (e.g. isPadding). Unfortunately, given the presence of an intermediate, non-public, abstract class, this is what we get from javadoc. Fixing these issues would require a deeper restructuring of the implementation, which would be too riskt at this stage.

src/java.base/share/classes/java/lang/foreign/AbstractLayout.java line 162:

> 160: 
> 161:         return Objects.equals(name, ((AbstractLayout) that).name) &&
> 162:                 Objects.equals(size, ((AbstractLayout)that).size) &&

I've consolidated things a bit here - the superclass should check name, size and alignment - while subclasses should only check additional properties.

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

PR: https://git.openjdk.org/jdk19/pull/98


More information about the core-libs-dev mailing list