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 mocking/faking APIs and a code coverage tool, supporting both JUnit and TestNG. The mocking APIs allow all kinds of Java code, without testability restrictions, to be tested in isolation from selected dependencies.

There is a newer version: 1.49
Show newest version
package mockit.asm.constantPool;

import javax.annotation.*;

import mockit.asm.jvmConstants.*;

/**
 * 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 - 2024 Weber Informatics LLC | Privacy Policy