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.MERGED;
9   
10  import edu.umd.cs.findbugs.annotations.NonNull;
11  
12  import org.checkerframework.checker.index.qual.NonNegative;
13  
14  final class MergedTypeTableItem extends TypeTableItem {
15      private int type1;
16      private int type2;
17      @NonNegative
18      int commonSuperTypeIndex;
19  
20      MergedTypeTableItem() {
21          type = MERGED;
22      }
23  
24      MergedTypeTableItem(@NonNull MergedTypeTableItem item) {
25          super(0, item);
26          type1 = item.type1;
27          type2 = item.type2;
28          commonSuperTypeIndex = item.commonSuperTypeIndex;
29      }
30  
31      /**
32       * Sets the types of this merged type table item.
33       *
34       * @param type1
35       *            index of an internal name in the type table.
36       * @param type2
37       *            index of an internal name in the type table.
38       */
39      void set(@NonNegative int type1, @NonNegative int type2) {
40          this.type1 = type1;
41          this.type2 = type2;
42          setHashCode(type1 + type2);
43      }
44  
45      @Override
46      boolean isEqualTo(@NonNull Item item) {
47          MergedTypeTableItem other = (MergedTypeTableItem) item;
48          return other.type1 == type1 && other.type2 == type2;
49      }
50  }