View Javadoc
1   /*
2    * MIT License
3    * Copyright (c) 2006-2025 JMockit developers
4    * See LICENSE file for full license text.
5    */
6   package mockit.asm.constantPool;
7   
8   import static mockit.asm.constantPool.TypeTableItem.SpecialType.UNINIT;
9   
10  import edu.umd.cs.findbugs.annotations.NonNull;
11  
12  import org.checkerframework.checker.index.qual.NonNegative;
13  
14  public final class UninitializedTypeTableItem extends TypeTableItem {
15      @NonNegative
16      int offset;
17  
18      UninitializedTypeTableItem() {
19          type = UNINIT;
20      }
21  
22      UninitializedTypeTableItem(@NonNegative int index, @NonNull UninitializedTypeTableItem item) {
23          super(index, item);
24          offset = item.offset;
25      }
26  
27      @NonNegative
28      public int getOffset() {
29          return offset;
30      }
31  
32      /**
33       * Sets the type and bytecode offset of this uninitialized type table item.
34       *
35       * @param type
36       *            the internal name to be added to the type table.
37       * @param offset
38       *            the bytecode offset of the NEW instruction that created the UNINITIALIZED type value.
39       */
40      void set(@NonNull String type, @NonNegative int offset) {
41          typeDesc = type;
42          this.offset = offset;
43          setHashCode(type.hashCode() + offset);
44      }
45  
46      @Override
47      boolean isEqualTo(@NonNull Item item) {
48          UninitializedTypeTableItem other = (UninitializedTypeTableItem) item;
49          return other.offset == offset && other.typeDesc.equals(typeDesc);
50      }
51  }