/** get returns the last value set or assigned */
 public void testGetSet() {
   AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer> a;
   try {
     a =
         AtomicReferenceFieldUpdater.newUpdater(
             AtomicReferenceFieldUpdaterTest.class, Integer.class, "x");
   } catch (RuntimeException ok) {
     return;
   }
   x = one;
   assertSame(one, a.get(this));
   a.set(this, two);
   assertSame(two, a.get(this));
   a.set(this, m3);
   assertSame(m3, a.get(this));
 }
 ConcreteResourceRegistration(
     final String valueString,
     final NodeSubregistry parent,
     final DescriptionProvider provider,
     final boolean runtimeOnly) {
   super(valueString, parent);
   childrenUpdater.clear(this);
   operationsUpdater.clear(this);
   attributesUpdater.clear(this);
   descriptionProviderUpdater.set(this, provider);
   this.runtimeOnly = runtimeOnly;
 }
Exemplo n.º 3
0
  /**
   * Construct a new instance.
   *
   * @param initialCapacity the initial capacity
   * @param loadFactor the load factor
   */
  public SecureHashMap(int initialCapacity, float loadFactor) {
    if (initialCapacity < 0) {
      throw new IllegalArgumentException("Initial capacity must be > 0");
    }
    if (initialCapacity > MAXIMUM_CAPACITY) {
      initialCapacity = MAXIMUM_CAPACITY;
    }
    if (loadFactor <= 0.0 || Float.isNaN(loadFactor) || loadFactor >= 1.0) {
      throw new IllegalArgumentException("Load factor must be between 0.0f and 1.0f");
    }

    int capacity = 1;

    while (capacity < initialCapacity) {
      capacity <<= 1;
    }

    this.loadFactor = loadFactor;
    this.initialCapacity = capacity;

    final Table<K, V> table = new Table<K, V>(capacity, loadFactor);
    tableUpdater.set(this, table);
  }