Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8191801

Class.getEnumConstants() can return null if the class is a generic Enum

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
      The javadocs read: "Returns: ... null if this Class object does not represent an enum type" . This is not 100% correct. null is also returned if the class is the Enum.class which can happen with generics.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Maybe the javadocs should be updated to read:

      @return an array containing the values comprising the enum class represented by this Class object in the order they're declared, or null if this Class object does not represent a concrete enum type

      ACTUAL -
      @return an array containing the values comprising the enum class represented by this Class object in the order they're declared, or null if this Class object does not represent an enum type


      URL OF FAULTY DOCUMENTATION :
      https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getEnumConstants--

            darcy Joe Darcy
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: