src/share/classes/java/lang/Enum.java

Print this page

        

@@ -171,12 +171,12 @@
      * Enum constants are only comparable to other enum constants of the
      * same enum type.  The natural order implemented by this
      * method is the order in which the constants are declared.
      */
     public final int compareTo(E o) {
-        Enum other = (Enum)o;
-        Enum self = this;
+        Enum<?> other = (Enum<?>)o;
+        Enum<E> self = this;
         if (self.getClass() != other.getClass() && // optimization
             self.getDeclaringClass() != other.getDeclaringClass())
             throw new ClassCastException();
         return self.ordinal - other.ordinal;
     }

@@ -191,14 +191,15 @@
      * constant-specific class bodies.)
      *
      * @return the Class object corresponding to this enum constant's
      *     enum type
      */
+    @SuppressWarnings("unchecked")
     public final Class<E> getDeclaringClass() {
-        Class clazz = getClass();
-        Class zuper = clazz.getSuperclass();
-        return (zuper == Enum.class) ? clazz : zuper;
+        Class<?> clazz = getClass();
+        Class<?> zuper = clazz.getSuperclass();
+        return (zuper == Enum.class) ? (Class<E>)clazz : (Class<E>)zuper;
     }
 
     /**
      * Returns the enum constant of the specified enum type with the
      * specified name.  The name must match exactly an identifier used