3737 * <em>integral</em> values (either signed or unsigned), <em>floating-point</em> values and
3838 * <em>address</em> values.
3939 * <p>
40- * Each value layout has a size, an alignment (in bits ),
40+ * Each value layout has a size, an alignment (both expressed in bytes ),
4141 * a {@linkplain ByteOrder byte order}, and a <em>carrier</em>, that is, the Java type that should be used when
4242 * {@linkplain MemorySegment#get(OfInt, long) accessing} a region of memory using the value layout.
4343 * <p>
@@ -129,7 +129,7 @@ public sealed interface ValueLayout extends MemoryLayout permits
129129 * featuring {@code shape.length + 1}
130130 * {@code long} coordinates.
131131 * @throws IllegalArgumentException if {@code shape[i] < 0}, for at least one index {@code i}.
132- * @throws UnsupportedOperationException if {@code bitAlignment () > bitSize ()}.
132+ * @throws UnsupportedOperationException if {@code byteAlignment () > byteSize ()}.
133133 * @see MethodHandles#memorySegmentViewVarHandle
134134 * @see MemoryLayout#varHandle(PathElement...)
135135 * @see SequenceLayout
@@ -152,7 +152,7 @@ public sealed interface ValueLayout extends MemoryLayout permits
152152 * @throws IllegalArgumentException {@inheritDoc}
153153 */
154154 @ Override
155- ValueLayout withBitAlignment (long bitAlignment );
155+ ValueLayout withByteAlignment (long byteAlignment );
156156
157157 /**
158158 * A value layout whose carrier is {@code boolean.class}.
@@ -180,7 +180,7 @@ sealed interface OfBoolean extends ValueLayout permits ValueLayouts.OfBooleanImp
180180 * @throws IllegalArgumentException {@inheritDoc}
181181 */
182182 @ Override
183- OfBoolean withBitAlignment (long bitAlignment );
183+ OfBoolean withByteAlignment (long byteAlignment );
184184
185185 /**
186186 * {@inheritDoc}
@@ -216,7 +216,7 @@ sealed interface OfByte extends ValueLayout permits ValueLayouts.OfByteImpl {
216216 * @throws IllegalArgumentException {@inheritDoc}
217217 */
218218 @ Override
219- OfByte withBitAlignment (long bitAlignment );
219+ OfByte withByteAlignment (long byteAlignment );
220220
221221 /**
222222 * {@inheritDoc}
@@ -253,7 +253,7 @@ sealed interface OfChar extends ValueLayout permits ValueLayouts.OfCharImpl {
253253 * @throws IllegalArgumentException {@inheritDoc}
254254 */
255255 @ Override
256- OfChar withBitAlignment (long bitAlignment );
256+ OfChar withByteAlignment (long byteAlignment );
257257
258258 /**
259259 * {@inheritDoc}
@@ -290,7 +290,7 @@ sealed interface OfShort extends ValueLayout permits ValueLayouts.OfShortImpl {
290290 * @throws IllegalArgumentException {@inheritDoc}
291291 */
292292 @ Override
293- OfShort withBitAlignment (long bitAlignment );
293+ OfShort withByteAlignment (long byteAlignment );
294294
295295 /**
296296 * {@inheritDoc}
@@ -327,7 +327,7 @@ sealed interface OfInt extends ValueLayout permits ValueLayouts.OfIntImpl {
327327 * @throws IllegalArgumentException {@inheritDoc}
328328 */
329329 @ Override
330- OfInt withBitAlignment (long bitAlignment );
330+ OfInt withByteAlignment (long byteAlignment );
331331
332332 /**
333333 * {@inheritDoc}
@@ -363,7 +363,7 @@ sealed interface OfFloat extends ValueLayout permits ValueLayouts.OfFloatImpl {
363363 * {@inheritDoc}
364364 */
365365 @ Override
366- OfFloat withBitAlignment (long bitAlignment );
366+ OfFloat withByteAlignment (long byteAlignment );
367367
368368 /**
369369 * {@inheritDoc}
@@ -400,7 +400,7 @@ sealed interface OfLong extends ValueLayout permits ValueLayouts.OfLongImpl {
400400 * @throws IllegalArgumentException {@inheritDoc}
401401 */
402402 @ Override
403- OfLong withBitAlignment (long bitAlignment );
403+ OfLong withByteAlignment (long byteAlignment );
404404
405405 /**
406406 * {@inheritDoc}
@@ -437,7 +437,7 @@ sealed interface OfDouble extends ValueLayout permits ValueLayouts.OfDoubleImpl
437437 * @throws IllegalArgumentException {@inheritDoc}
438438 */
439439 @ Override
440- OfDouble withBitAlignment (long bitAlignment );
440+ OfDouble withByteAlignment (long byteAlignment );
441441
442442 /**
443443 * {@inheritDoc}
@@ -449,56 +449,56 @@ sealed interface OfDouble extends ValueLayout permits ValueLayouts.OfDoubleImpl
449449
450450 /**
451451 * A value layout constant whose size is the same as that of a machine address ({@code size_t}),
452- * bit alignment set to {@code sizeof(size_t) * 8 }, byte order set to {@link ByteOrder#nativeOrder()}.
452+ * byte alignment set to {@code sizeof(size_t)}, byte order set to {@link ByteOrder#nativeOrder()}.
453453 */
454454 AddressLayout ADDRESS = ValueLayouts .OfAddressImpl .of (ByteOrder .nativeOrder ());
455455
456456 /**
457457 * A value layout constant whose size is the same as that of a Java {@code byte},
458- * bit alignment set to 8 , and byte order set to {@link ByteOrder#nativeOrder()}.
458+ * byte alignment set to 1 , and byte order set to {@link ByteOrder#nativeOrder()}.
459459 */
460460 OfByte JAVA_BYTE = ValueLayouts .OfByteImpl .of (ByteOrder .nativeOrder ());
461461
462462 /**
463463 * A value layout constant whose size is the same as that of a Java {@code boolean},
464- * bit alignment set to 8 , and byte order set to {@link ByteOrder#nativeOrder()}.
464+ * byte alignment set to 1 , and byte order set to {@link ByteOrder#nativeOrder()}.
465465 */
466466 OfBoolean JAVA_BOOLEAN = ValueLayouts .OfBooleanImpl .of (ByteOrder .nativeOrder ());
467467
468468 /**
469469 * A value layout constant whose size is the same as that of a Java {@code char},
470- * bit alignment set to 16 , and byte order set to {@link ByteOrder#nativeOrder()}.
470+ * byte alignment set to 2 , and byte order set to {@link ByteOrder#nativeOrder()}.
471471 */
472472 OfChar JAVA_CHAR = ValueLayouts .OfCharImpl .of (ByteOrder .nativeOrder ());
473473
474474 /**
475475 * A value layout constant whose size is the same as that of a Java {@code short},
476- * bit alignment set to 16 , and byte order set to {@link ByteOrder#nativeOrder()}.
476+ * byte alignment set to 2 , and byte order set to {@link ByteOrder#nativeOrder()}.
477477 */
478478 OfShort JAVA_SHORT = ValueLayouts .OfShortImpl .of (ByteOrder .nativeOrder ());
479479
480480 /**
481481 * A value layout constant whose size is the same as that of a Java {@code int},
482- * bit alignment set to 32 , and byte order set to {@link ByteOrder#nativeOrder()}.
482+ * byte alignment set to 4 , and byte order set to {@link ByteOrder#nativeOrder()}.
483483 */
484484 OfInt JAVA_INT = ValueLayouts .OfIntImpl .of (ByteOrder .nativeOrder ());
485485
486486 /**
487487 * A value layout constant whose size is the same as that of a Java {@code long},
488- * (platform-dependent) bit alignment set to {@code ADDRESS.bitSize ()},
488+ * (platform-dependent) byte alignment set to {@code ADDRESS.byteSize ()},
489489 * and byte order set to {@link ByteOrder#nativeOrder()}.
490490 */
491491 OfLong JAVA_LONG = ValueLayouts .OfLongImpl .of (ByteOrder .nativeOrder ());
492492
493493 /**
494494 * A value layout constant whose size is the same as that of a Java {@code float},
495- * bit alignment set to 32 , and byte order set to {@link ByteOrder#nativeOrder()}.
495+ * byte alignment set to 4 , and byte order set to {@link ByteOrder#nativeOrder()}.
496496 */
497497 OfFloat JAVA_FLOAT = ValueLayouts .OfFloatImpl .of (ByteOrder .nativeOrder ());
498498
499499 /**
500500 * A value layout constant whose size is the same as that of a Java {@code double},
501- * (platform-dependent) bit alignment set to {@code ADDRESS.bitSize ()},
501+ * (platform-dependent) byte alignment set to {@code ADDRESS.byteSize ()},
502502 * and byte order set to {@link ByteOrder#nativeOrder()}.
503503 */
504504 OfDouble JAVA_DOUBLE = ValueLayouts .OfDoubleImpl .of (ByteOrder .nativeOrder ());
@@ -508,83 +508,83 @@ sealed interface OfDouble extends ValueLayout permits ValueLayouts.OfDoubleImpl
508508 * and byte order set to {@link ByteOrder#nativeOrder()}.
509509 * Equivalent to the following code:
510510 * {@snippet lang=java :
511- * ADDRESS.withBitAlignment(8 );
511+ * ADDRESS.withByteAlignment(1 );
512512 * }
513513 * @apiNote Care should be taken when using unaligned value layouts as they may induce
514514 * performance and portability issues.
515515 */
516- AddressLayout ADDRESS_UNALIGNED = ADDRESS .withBitAlignment ( 8 );
516+ AddressLayout ADDRESS_UNALIGNED = ADDRESS .withByteAlignment ( 1 );
517517
518518 /**
519519 * An unaligned value layout constant whose size is the same as that of a Java {@code char}
520520 * and byte order set to {@link ByteOrder#nativeOrder()}.
521521 * Equivalent to the following code:
522522 * {@snippet lang=java :
523- * JAVA_CHAR.withBitAlignment(8 );
523+ * JAVA_CHAR.withByteAlignment(1 );
524524 * }
525525 * @apiNote Care should be taken when using unaligned value layouts as they may induce
526526 * performance and portability issues.
527527 */
528- OfChar JAVA_CHAR_UNALIGNED = JAVA_CHAR .withBitAlignment ( 8 );
528+ OfChar JAVA_CHAR_UNALIGNED = JAVA_CHAR .withByteAlignment ( 1 );
529529
530530 /**
531531 * An unaligned value layout constant whose size is the same as that of a Java {@code short}
532532 * and byte order set to {@link ByteOrder#nativeOrder()}.
533533 * Equivalent to the following code:
534534 * {@snippet lang=java :
535- * JAVA_SHORT.withBitAlignment(8 );
535+ * JAVA_SHORT.withByteAlignment(1 );
536536 * }
537537 * @apiNote Care should be taken when using unaligned value layouts as they may induce
538538 * performance and portability issues.
539539 */
540- OfShort JAVA_SHORT_UNALIGNED = JAVA_SHORT .withBitAlignment ( 8 );
540+ OfShort JAVA_SHORT_UNALIGNED = JAVA_SHORT .withByteAlignment ( 1 );
541541
542542 /**
543543 * An unaligned value layout constant whose size is the same as that of a Java {@code int}
544544 * and byte order set to {@link ByteOrder#nativeOrder()}.
545545 * Equivalent to the following code:
546546 * {@snippet lang=java :
547- * JAVA_INT.withBitAlignment(8 );
547+ * JAVA_INT.withByteAlignment(1 );
548548 * }
549549 * @apiNote Care should be taken when using unaligned value layouts as they may induce
550550 * performance and portability issues.
551551 */
552- OfInt JAVA_INT_UNALIGNED = JAVA_INT .withBitAlignment ( 8 );
552+ OfInt JAVA_INT_UNALIGNED = JAVA_INT .withByteAlignment ( 1 );
553553
554554 /**
555555 * An unaligned value layout constant whose size is the same as that of a Java {@code long}
556556 * and byte order set to {@link ByteOrder#nativeOrder()}.
557557 * Equivalent to the following code:
558558 * {@snippet lang=java :
559- * JAVA_LONG.withBitAlignment(8 );
559+ * JAVA_LONG.withByteAlignment(1 );
560560 * }
561561 * @apiNote Care should be taken when using unaligned value layouts as they may induce
562562 * performance and portability issues.
563563 */
564- OfLong JAVA_LONG_UNALIGNED = JAVA_LONG .withBitAlignment ( 8 );
564+ OfLong JAVA_LONG_UNALIGNED = JAVA_LONG .withByteAlignment ( 1 );
565565
566566 /**
567567 * An unaligned value layout constant whose size is the same as that of a Java {@code float}
568568 * and byte order set to {@link ByteOrder#nativeOrder()}.
569569 * Equivalent to the following code:
570570 * {@snippet lang=java :
571- * JAVA_FLOAT.withBitAlignment(8 );
571+ * JAVA_FLOAT.withByteAlignment(1 );
572572 * }
573573 * @apiNote Care should be taken when using unaligned value layouts as they may induce
574574 * performance and portability issues.
575575 */
576- OfFloat JAVA_FLOAT_UNALIGNED = JAVA_FLOAT .withBitAlignment ( 8 );
576+ OfFloat JAVA_FLOAT_UNALIGNED = JAVA_FLOAT .withByteAlignment ( 1 );
577577
578578 /**
579579 * An unaligned value layout constant whose size is the same as that of a Java {@code double}
580580 * and byte order set to {@link ByteOrder#nativeOrder()}.
581581 * Equivalent to the following code:
582582 * {@snippet lang=java :
583- * JAVA_DOUBLE.withBitAlignment(8 );
583+ * JAVA_DOUBLE.withByteAlignment(1 );
584584 * }
585585 * @apiNote Care should be taken when using unaligned value layouts as they may induce
586586 * performance and portability issues.
587587 */
588- OfDouble JAVA_DOUBLE_UNALIGNED = JAVA_DOUBLE .withBitAlignment ( 8 );
588+ OfDouble JAVA_DOUBLE_UNALIGNED = JAVA_DOUBLE .withByteAlignment ( 1 );
589589
590590}
0 commit comments