On Mon, 11 Nov 2024 17:28:34 GMT, Maurizio Cimadamore <mcimadam...@openjdk.org> wrote:
> > Maybe we should also check that padding layouts have natural alignment? The > > alignment of padding layouts can affect the alignment of the enclosing > > container. > > This makes sense, but I wonder if that would require a change in the javadoc? Also, we should decide if we want to include this or not. I think this can help prevent silly things like: MemoryLayout.unionLayout( ValueLayout.JAVA_INT, MemoryLayout.paddingLayout(8).withByteAlignment(8)): from being accepted by the check in `checkGroup`. A single bullet in the criteria for well-formed layouts stating that padding layouts must be naturally aligned seems enough? (And the check in the implementation should be simple as well). Though, I'm still wondering if we don't want to reject that at the layout API level instead. i.e. have `withByteAlignment` throw an exception for `PaddingLayout`. ------------- PR Comment: https://git.openjdk.org/jdk/pull/21041#issuecomment-2489360595