< prev index next >

src/java.base/share/classes/jdk/internal/classfile/impl/FieldImpl.java

Print this page
@@ -1,7 +1,7 @@
  /*
-  * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
+  * Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.  Oracle designates this

@@ -36,26 +36,26 @@
  import java.util.Optional;
  import java.util.function.Consumer;
  
  public final class FieldImpl
          extends AbstractElement
-         implements FieldModel, Util.Writable {
+         implements FieldModel, WritableField {
  
-     private final ClassReader reader;
+     private final ClassReaderImpl reader;
      private final int startPos, endPos, attributesPos;
      private List<Attribute<?>> attributes;
  
-     public FieldImpl(ClassReader reader, int startPos, int endPos, int attributesPos) {
+     public FieldImpl(ClassReaderImpl reader, int startPos, int endPos, int attributesPos) {
          this.reader = reader;
          this.startPos = startPos;
          this.endPos = endPos;
          this.attributesPos = attributesPos;
      }
  
      @Override
      public AccessFlags flags() {
-         return new AccessFlagsImpl(AccessFlag.Location.FIELD, reader.readU2(startPos));
+         return new AccessFlagsImpl(AccessFlag.Location.FIELD, fieldFlags(), reader.classFileVersion());
      }
  
      @Override
      public Optional<ClassModel> parent() {
          if (reader instanceof ClassReaderImpl cri)

@@ -72,10 +72,15 @@
      @Override
      public Utf8Entry fieldType() {
          return reader.readEntry(startPos + 4, Utf8Entry.class);
      }
  
+     @Override
+     public int fieldFlags() {
+         return reader.readU2(startPos);
+     }
+ 
      @Override
      public List<Attribute<?>> attributes() {
          if (attributes == null) {
              attributes = BoundAttribute.readAttributes(this, reader, attributesPos, reader.customAttributes());
          }
< prev index next >