From 2ca0eff93cff4f4897d9346fe52fa59961f73352 Mon Sep 17 00:00:00 2001 From: Henri Yandell Date: Wed, 5 Sep 2007 10:06:41 +0000 Subject: [PATCH] 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 --- src/java/org/apache/commons/lang/enum/Enum.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/java/org/apache/commons/lang/enum/Enum.java b/src/java/org/apache/commons/lang/enum/Enum.java index ea8883196..de57cc05c 100644 --- a/src/java/org/apache/commons/lang/enum/Enum.java +++ b/src/java/org/apache/commons/lang/enum/Enum.java @@ -548,7 +548,7 @@ public abstract class Enum implements Comparable, Serializable { // classes are in the same class loader. return iName.equals(((Enum) other).iName); } 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) { return false; } @@ -589,6 +589,8 @@ public abstract class Enum implements Comparable, Serializable { if (other.getClass().getName().equals(this.getClass().getName())) { return iName.compareTo( getNameInOtherClassLoader(other) ); } + throw new ClassCastException( + "Different enum class '" + ClassUtils.getShortClassName(other.getClass()) + "'"); } return iName.compareTo(((Enum) other).iName); }