View Javadoc
1   package mockit.asm.constantPool;
2   
3   import static mockit.asm.jvmConstants.ConstantPoolTypes.HANDLE_BASE;
4   
5   import edu.umd.cs.findbugs.annotations.NonNull;
6   
7   import mockit.asm.util.MethodHandle;
8   
9   import org.checkerframework.checker.index.qual.NonNegative;
10  
11  public final class MethodHandleItem extends Item {
12      private MethodHandle methodHandle;
13  
14      public MethodHandleItem(@NonNegative int index) {
15          super(index);
16          type = HANDLE_BASE;
17      }
18  
19      MethodHandleItem(@NonNegative int index, @NonNull MethodHandleItem item) {
20          super(index, item);
21          methodHandle = item.methodHandle;
22      }
23  
24      /**
25       * Sets the type and hash code of this method handle item.
26       */
27      public void set(@NonNull MethodHandle methodHandle) {
28          this.methodHandle = methodHandle;
29          type = HANDLE_BASE;
30          setHashCode(methodHandle.hashCode());
31          type = HANDLE_BASE + methodHandle.tag;
32      }
33  
34      @Override
35      boolean isEqualTo(@NonNull Item item) {
36          return ((MethodHandleItem) item).methodHandle.equals(methodHandle);
37      }
38  }