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

EnumSet.range does not throw expected IllegalArgumentException

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 5.0
    • Fix Version/s: None
    • Component/s: core-libs

      Description



      Name: skR10005 Date: 11/26/2003


      The following new api test fails on JDK1.5.0-b29:
      api/java_util/EnumSet/index.html#range[range001]

      The API specification of the method EnumSet.range reads:
        "IllegalArgumentException - if first.compareTo(last) > 0"
        
      However RI does not throw an exception.

      The following simple test can be used to reproduce the failure:
      ===============================test.java=======================
      import java.util.EnumSet;

      public class test {
          public static void main(String[] argv) {
              EnumSet.range(simpleEnum.LAST, simpleEnum.FIRST);
              System.out.println("COMPARE:" +
                  simpleEnum.LAST.compareTo(simpleEnum.FIRST));
          }
      }
      ===========================simpleEnum.java=====================
      public enum simpleEnum { FIRST, LAST }
      ===============================================================
      $ javac -d . -source 1.5 test.java simpleEnum.java
      $ java -version
      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b29)
      Java HotSpot(TM) Server VM (build 1.5.0-beta-b29, mixed mode)
      $ java -cp . test
      COMPARE:1
      $

      As we see no exception is thrown.

      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jjb Josh Bloch
              Reporter:
              serjsunw Serj Serj (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: