< prev index next >

src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/GroupLayout.java

Print this page
@@ -23,26 +23,24 @@
   *  questions.
   *
   */
  package jdk.incubator.foreign;
  
- import java.lang.constant.Constable;
  import java.lang.constant.ConstantDesc;
  import java.lang.constant.ConstantDescs;
  import java.lang.constant.DynamicConstantDesc;
  import java.lang.constant.MethodHandleDesc;
  import java.util.Collections;
  import java.util.List;
- import java.util.Map;
  import java.util.Objects;
  import java.util.Optional;
  import java.util.OptionalLong;
  import java.util.function.LongBinaryOperator;
  import java.util.stream.Collectors;
  
  /**
-  * A group layout is used to combine together multiple <em>member layouts</em>. There are two ways in which member layouts
+  * A group layout is used to combine multiple <em>member layouts</em>. There are two ways in which member layouts
   * can be combined: if member layouts are laid out one after the other, the resulting group layout is said to be a <em>struct</em>
   * (see {@link MemoryLayout#structLayout(MemoryLayout...)}); conversely, if all member layouts are laid out at the same starting offset,
   * the resulting group layout is said to be a <em>union</em> (see {@link MemoryLayout#unionLayout(MemoryLayout...)}).
   * <p>
   * This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>

@@ -103,15 +101,15 @@
  
      private final Kind kind;
      private final List<MemoryLayout> elements;
  
      GroupLayout(Kind kind, List<MemoryLayout> elements) {
-         this(kind, elements, kind.alignof(elements), Map.of());
+         this(kind, elements, kind.alignof(elements), Optional.empty());
      }
  
-     GroupLayout(Kind kind, List<MemoryLayout> elements, long alignment, Map<String, Constable> attributes) {
-         super(kind.sizeof(elements), alignment, attributes);
+     GroupLayout(Kind kind, List<MemoryLayout> elements, long alignment, Optional<String> name) {
+         super(kind.sizeof(elements), alignment, name);
          this.kind = kind;
          this.elements = elements;
      }
  
      /**

@@ -158,25 +156,24 @@
              return true;
          }
          if (!super.equals(other)) {
              return false;
          }
-         if (!(other instanceof GroupLayout)) {
+         if (!(other instanceof GroupLayout g)) {
              return false;
          }
-         GroupLayout g = (GroupLayout)other;
          return kind.equals(g.kind) && elements.equals(g.elements);
      }
  
      @Override
      public int hashCode() {
          return Objects.hash(super.hashCode(), kind, elements);
      }
  
      @Override
-     GroupLayout dup(long alignment, Map<String, Constable> attributes) {
-         return new GroupLayout(kind, elements, alignment, attributes);
+     GroupLayout dup(long alignment, Optional<String> name) {
+         return new GroupLayout(kind, elements, alignment, name);
      }
  
      @Override
      boolean hasNaturalAlignment() {
          return alignment == kind.alignof(elements);

@@ -210,14 +207,6 @@
       */
      @Override
      public GroupLayout withBitAlignment(long alignmentBits) {
          return (GroupLayout)super.withBitAlignment(alignmentBits);
      }
- 
-     /**
-      * {@inheritDoc}
-      */
-     @Override
-     public GroupLayout withAttribute(String name, Constable value) {
-         return (GroupLayout)super.withAttribute(name, value);
-     }
  }
< prev index next >