Bringing over minor edits and a thrown ClassCastException from enums.Enum

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@572929 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Henri Yandell 2007-09-05 10:06:41 +00:00
parent a991c10a18
commit 2ca0eff93c
1 changed files with 3 additions and 1 deletions

View File

@ -548,7 +548,7 @@ public abstract class Enum implements Comparable, Serializable {
// classes are in the same class loader. // classes are in the same class loader.
return iName.equals(((Enum) other).iName); return iName.equals(((Enum) other).iName);
} else { } else {
// This and other are in different class loaders, we must use reflection. // This and other are in different class loaders, we must check indirectly
if (other.getClass().getName().equals(this.getClass().getName()) == false) { if (other.getClass().getName().equals(this.getClass().getName()) == false) {
return false; return false;
} }
@ -589,6 +589,8 @@ public abstract class Enum implements Comparable, Serializable {
if (other.getClass().getName().equals(this.getClass().getName())) { if (other.getClass().getName().equals(this.getClass().getName())) {
return iName.compareTo( getNameInOtherClassLoader(other) ); return iName.compareTo( getNameInOtherClassLoader(other) );
} }
throw new ClassCastException(
"Different enum class '" + ClassUtils.getShortClassName(other.getClass()) + "'");
} }
return iName.compareTo(((Enum) other).iName); return iName.compareTo(((Enum) other).iName);
} }