Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8330333

Wrong javadoc for ValueLayout.JAVA_LONG/JAVA_DOUBLE on x86 32bit

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 23
    • core-libs
    • None
    • behavioral
    • minimal
    • Hide
      On 64-bit systems, there is no change as the alignment there was specified to be 8 bytes. It is only in 32-bit systems, the alignment is now specified to be increased from 4 bytes to 8 bytes. Increasing alignment is not expected to cause any adverse impact (going in the other direction would have though).
      Show
      On 64-bit systems, there is no change as the alignment there was specified to be 8 bytes. It is only in 32-bit systems, the alignment is now specified to be increased from 4 bytes to 8 bytes. Increasing alignment is not expected to cause any adverse impact (going in the other direction would have though).
    • Java API
    • SE

      Summary

      Correct the JavaDocs for MemoryLayout.JAVA_LONG and MemoryLayout.JAVA_DOUBLE to reflect the fact they always have an alignment of 8 bytes regardless if running on a 32-bit or a 64-bit system.

      Problem

      Previously, the alignment for these value layouts was specified to be the same as for the ADDRESS (which is different in 32-bit (4) and 64-bit systems (8)). A fix (https://bugs.openjdk.org/browse/JDK-8326172) was made that changed the alignment of these value layouts but, unfortunately, the API documentation was not updated to reflect these changes.

      Solution

      Correct the JavaDocs for said fields.

      Specification

      diff --git a/src/java.base/share/classes/java/lang/foreign/ValueLayout.java b/src/java.base/share/classes/java/lang/foreign/ValueLayout.java
      index 77bfe0e0209b..d4e396534911 100644
      --- a/src/java.base/share/classes/java/lang/foreign/ValueLayout.java
      +++ b/src/java.base/share/classes/java/lang/foreign/ValueLayout.java
      @@ -446,8 +446,7 @@ sealed interface OfDouble extends ValueLayout permits ValueLayouts.OfDoubleImpl
      
           /**
            * A value layout constant whose size is the same as that of a Java {@code long},
      -     * (platform-dependent) byte alignment set to {@code ADDRESS.byteSize()},
      -     * and byte order set to {@link ByteOrder#nativeOrder()}.
      +     * byte alignment set to 8, and byte order set to {@link ByteOrder#nativeOrder()}.
            */
           OfLong JAVA_LONG = ValueLayouts.OfLongImpl.of(ByteOrder.nativeOrder());
      
      @@ -459,8 +458,7 @@ sealed interface OfDouble extends ValueLayout permits ValueLayouts.OfDoubleImpl
      
           /**
            * A value layout constant whose size is the same as that of a Java {@code double},
      -     * (platform-dependent) byte alignment set to {@code ADDRESS.byteSize()},
      -     * and byte order set to {@link ByteOrder#nativeOrder()}.
      +     * byte alignment set to 8, and byte order set to {@link ByteOrder#nativeOrder()}.
            */
           OfDouble JAVA_DOUBLE = ValueLayouts.OfDoubleImpl.of(ByteOrder.nativeOrder());

            pminborg Per-Ake Minborg
            jvernee Jorn Vernee
            Maurizio Cimadamore
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: