Switch block for Class

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Won't Fix
    • Priority: P5
    • None
    • Affects Version/s: 7
    • Component/s: specification
    • x86
    • windows_7

      A DESCRIPTION OF THE REQUEST :
      A natural extension of multicatch added in Java7 is the ability to switch() on Class instances. For example:

      try
      {
        future.get();
      }
      catch (InterruptedException | ExecutionException e)
      {
        // Handle exception wrapped by ExecutionException
        switch (e.getCause().getClass())
        {
          case IOException.class:
          {
          }
          case IllegalArgumentException.class:
          {
          }
          // etc
        }
      }

      JUSTIFICATION :
      Improved readability. The alternative is a long list of if/else "instanceof" statements.

            Assignee:
            Joe Darcy
            Reporter:
            Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: