Commit 4e3243bc authored by Lubomir Bulej's avatar Lubomir Bulej

ShadowClass, ShadowThread: use super.hashCode() so that the classes can be used as hash keys.

parent bb99ca9c
......@@ -57,28 +57,31 @@ public abstract class ShadowClass extends ShadowObject {
public abstract ShadowClass getSuperclass();
//
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ShadowClass)) {
return false;
}
ShadowClass sClass = (ShadowClass) obj;
if (getName().equals(sClass.getName())
&& getShadowClassLoader().equals(sClass.getShadowClassLoader())) {
return true;
public boolean equals (final Object object) {
if (object instanceof ShadowClass) {
final ShadowClass that = (ShadowClass) object;
if (this.getName ().equals (that.getName ())) {
return this.getShadowClassLoader ().equals (that.getShadowClassLoader ());
}
}
return false;
}
@Override
public int hashCode() {
throw new UnsupportedOperationException("overriden equals, not overriden hashCode");
//
// TODO LB: Check ShadowClass.hashCode() -- it's needed.
//
return super.hashCode ();
}
//
public abstract FieldInfo[] getFields();
public abstract FieldInfo getField(String fieldName)
......
......@@ -38,18 +38,17 @@ public class ShadowThread extends ShadowObject implements Formattable {
this.isDaemon = isDaemon;
}
@Override
public boolean equals(Object obj) {
if (super.equals(obj)) {
if (obj instanceof ShadowThread) {
ShadowThread t = (ShadowThread) obj;
if (name != null && name.equals(t.name)
&& (isDaemon == t.isDaemon)) {
return true;
@Override
public boolean equals (final Object object) {
//
// TODO LB: Why do we need to check thread name or other fields?
//
if (super.equals (object)) {
if (object instanceof ShadowThread) {
final ShadowThread that = (ShadowThread) object;
if (this.name != null && this.name.equals (that.name)) {
return this.isDaemon == that.isDaemon;
}
}
}
......@@ -57,9 +56,21 @@ public class ShadowThread extends ShadowObject implements Formattable {
return false;
}
@Override
public int hashCode() {
throw new UnsupportedOperationException("overriden equals, not overriden hashCode");
//
// TODO LB: Check ShadowThread.hashCode() -- it's needed.
//
// If two shadow threads are considered equal by the above equals()
// method, then they certainly have the same hash code, because it
// is derived from objectId (which in turn is derived from object tag,
// a.k.a. net reference) that is ensured to be equal by the call to
// super.equals().
//
// If they are not equal, nobody cares about the hash code.
//
return super.hashCode ();
}
//
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment