All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mockit.asm.constantPool.Item Maven / Gradle / Ivy

Go to download

JMockit is a Java toolkit for automated developer testing. It contains APIs for the creation of the objects to be tested, for mocking dependencies, and for faking external APIs; JUnit (4 & 5) and TestNG test runners are supported. It also contains an advanced code coverage tool.

The newest version!
package mockit.asm.constantPool;

import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;

import mockit.asm.jvmConstants.ConstantPoolTypes;

import org.checkerframework.checker.index.qual.NonNegative;

/**
 * A constant pool item of a given {@linkplain ConstantPoolTypes type}.
 */
public abstract class Item {
    /**
     * Index of this item in the constant pool.
     */
    @NonNegative
    public final int index;

    /**
     * {@link ConstantPoolTypes Type} of this constant pool item.
     * 

* MethodHandle variations are stored using a range of 9 values from {@link ConstantPoolTypes#HANDLE_BASE * HANDLE_BASE} + 1 to {@link ConstantPoolTypes#HANDLE_BASE HANDLE_BASE} + 9. *

* Special Item types are used for items that are stored in the {@link ConstantPoolGeneration#typeTable}, instead of * the constant pool, in order to avoid clashes with normal constant pool items in the constant pool's hash table. * These special item types are defined in {@link TypeTableItem.SpecialType}. */ @NonNegative int type; /** * The hash code value of this constant pool item. */ @NonNegative private int hashCode; /** * Link to another constant pool item, used for collision lists in the constant pool's hash table. */ @Nullable private Item next; /** * Initializes an Item for a constant pool element at the given position. * * @param index * index of the item */ Item(@NonNegative int index) { this.index = index; } /** * Initializes this item as a copy of a given item. * * @param index * index of the new item * @param item * the item to be copied into this item */ Item(@NonNegative int index, @NonNull Item item) { this.index = index; type = item.type; hashCode = item.hashCode; } /** * Returns the {@link #type} of this item. */ @NonNegative public int getType() { return type; } /** * Returns the {@link #hashCode} value. */ @NonNegative public final int getHashCode() { return hashCode; } final void setHashCode(int valuesHashCode) { hashCode = 0x7FFFFFFF & type + valuesHashCode; } /** * Returns the {@link #next} item, if any. */ @Nullable public Item getNext() { return next; } public final void setNext(@NonNull Item[] items) { int indexOfNextItem = hashCode % items.length; next = items[indexOfNextItem]; items[indexOfNextItem] = this; } /** * Indicates if the given item is equal to this one, assuming that the two items have the same * {@link #type}. * * @param item * the item to be compared to this one (both items must have the same {@link #type}) * * @return true if the given item is equal to this one, false otherwise */ abstract boolean isEqualTo(@NonNull Item item); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy