/*
* Copyright 2009 Goldman Sachs International. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
/*
* @test
* @bug 6865031
* @summary Application gives bad result (throws bad exception) with compressed oops
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:HeapBaseMinAddress=32g -XX:-LoopUnswitching -XX:CompileCommand=inline,AbstractMemoryEfficientList.equals Test hello goodbye
*/
interface MyList {
public int size();
}
abstract public int size();
if (o == this) {
return true;
}
if (!(o instanceof MyList)) {
return false;
}
return false;
}
for (int i = 0; i < this.size(); i++) {
try {
return false;
}
} catch (IndexOutOfBoundsException e) {
System.out.println("concurrent modification of this:" + this.getClass() + ":" + System.identityHashCode(this) + "; that:" + that.getClass() + ":" + System.identityHashCode(that) + "; i:" + i);
e.printStackTrace();
throw new RuntimeException("concurrent modification of this:" + this.getClass() + ":" + System.identityHashCode(this) + "; that:" + that.getClass() + ":" + System.identityHashCode(that) + "; i:" + i, e);
}
}
return true;
}
public int hashCode() {
int hashCode = 1;
for (int i = 0; i < this.size(); i++) {
}
return hashCode;
}
}
super();
}
public int size() {
return 1;
}
if (index == 0) {
return this.element1;
} else {
}
}
if (index == 0) {
return previousElement;
} else {
}
}
}
}
public int size() {
return 2;
}
switch (index) {
case 0 : return this.element1;
case 1 : return this.element2;
}
}
switch (index) {
case 0 :
{
return previousElement;
}
case 1 :
{
return previousElement;
}
}
}
}
class WeakPool<V> {
private int size;
protected int threshold;
private final float loadFactor;
public WeakPool()
{
this.loadFactor = DEFAULT_LOAD_FACTOR;
}
/**
* Check for equality of non-null reference x and possibly-null y. By
* default uses Object.equals.
*/
{
return x == y || x.equals(y);
}
/**
* Return index for hash code h.
*/
{
return h & length - 1;
}
/**
* Expunge stale entries from the table.
*/
private void expungeStaleEntries()
{
Object r;
{
int h = e.hash;
// System.out.println("EXPUNGING " + h);
while (p != null)
{
if (p == e)
{
if (prev == e)
{
}
else
{
}
size--;
break;
}
prev = p;
p = next;
}
}
}
/**
* Return the table after first expunging stale entries
*/
{
return table;
}
/**
* Returns the number of key-value mappings in this map.
* This result is a snapshot, and may not reflect unprocessed
* entries that will be removed before next attempted access
* because they are no longer referenced.
*/
public int size()
{
if (size == 0)
{
return 0;
}
return size;
}
/**
* Returns <tt>true</tt> if this map contains no key-value mappings.
* This result is a snapshot, and may not reflect unprocessed
* entries that will be removed before next attempted access
* because they are no longer referenced.
*/
public boolean isEmpty()
{
return size() == 0;
}
/**
* Returns the value stored in the pool that equals the requested key
* or <tt>null</tt> if the map contains no mapping for
* this key (or the key is null)
*
* @param key the key whose equals value is to be returned.
* @return the object that is equal the specified key, or
* <tt>null</tt> if key is null or no object in the pool equals the key.
*/
{
{
return null;
}
while (e != null)
{
{
return candidate;
}
e = e.next;
}
return null;
}
/**
* Returns the entry associated with the specified key in the HashMap.
* Returns null if the HashMap contains no mapping for this key.
*/
{
{
e = e.next;
}
return e;
}
/**
* Places the object into the pool. If the object is null, nothing happens.
* If an equal object already exists, it is not replaced.
*
* @param key the object to put into the pool. key may be null.
* @return the object in the pool that is equal to the key, or the newly placed key if no such object existed when put was called
*/
{
{
return null;
}
{
{
return candidate;
}
}
{
}
// System.out.println("Added " + key + " to pool");
return key;
}
/**
* Rehashes the contents of this map into a new array with a
* larger capacity. This method is called automatically when the
* number of keys in this map reaches its threshold.
* <p/>
* If current capacity is MAXIMUM_CAPACITY, this method does not
* resize the map, but but sets threshold to Integer.MAX_VALUE.
* This has the effect of preventing future calls.
*
* @param newCapacity the new capacity, MUST be a power of two;
* must be greater than current capacity unless current
* capacity is MAXIMUM_CAPACITY (in which case value
* is irrelevant).
*/
{
if (oldCapacity == MAXIMUM_CAPACITY)
{
return;
}
/*
* If ignoring null elements and processing ref queue caused massive
* shrinkage, then restore old table. This should be rare, but avoids
* unbounded expansion of garbage-filled tables.
*/
{
}
else
{
}
}
/**
* Transfer all entries from src to dest tables
*/
{
{
while (e != null)
{
{
size--;
}
else
{
dest[i] = e;
}
e = next;
}
}
}
/**
* Removes the object in the pool that equals the key.
*
* @param key
* @return previous value associated with specified key, or <tt>null</tt>
* if there was no mapping for key or the key is null.
*/
{
{
return null;
}
while (e != null)
{
{
size--;
if (prev == e)
{
}
else
{
}
return candidate;
}
prev = e;
e = next;
}
return null;
}
/**
* Removes all mappings from this map.
*/
public void clear()
{
// clear out ref queue. We don't need to expunge entries
// since table is getting cleared.
{
// nop
}
size = 0;
// Allocation of array may have caused GC, which may have caused
// additional entries to go stale. Removing these entries from the
// reference queue will make them eligible for reclamation.
{
// nop
}
}
/**
* The entries in this hash table extend WeakReference, using its main ref
* field as the key.
*/
protected static class Entry<V>
extends WeakReference<V>
{
private final int hash;
/**
* Create new entry.
*/
{
}
public V getKey()
{
return super.get();
}
{
{
return false;
}
}
public int hashCode()
{
return this.hash;
}
{
}
}
}
final class MultiSynonymKey {
public MultiSynonymKey() {
}
}
return keys;
}
public int hashCode() {
}
if (this == obj) {
return true;
}
if (!(obj instanceof MultiSynonymKey)) {
return false;
}
}
}
}
static private byte[] arg1;
static private byte[] arg2;
public void run() {
int count=0;
while (true) {
try {
} catch (Exception e) {}
synchronized (wp) {
}
try {
} catch (Exception e) {}
synchronized (wp) {
}
if (count++==100)
}
}
int counter = 0;
while (true) {
synchronized (wp) {
// System.out.println("foo " + counter);
// System.out.println(foo);
}
}
counter++;
}
}
return x == y || x.equals(y);
}
}