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

Generics bug with Enum<?> instanceof

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 6
    • Fix Version/s: None
    • Component/s: tools
    • Subcomponent:
    • CPU:
      x86
    • OS:
      linux

      Description

      FULL PRODUCT VERSION :
      java version "1.6.0"
      Java(TM) SE Runtime Environment (build 1.6.0-b105)
      Java HotSpot(TM) Server VM (build 1.6.0-b105, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux XXX 2.6.17-10-generic #2 SMP Fri Oct 13 18:45:35 UTC 2006 i686 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      The code snippet given below does not compile

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the given code

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      It should compile
      ACTUAL -
      It does not

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      X.java:5: inconvertible types
      found : java.lang.Enum<capture#262 of ?>
      required: E
            if (o instanceof E) {
                ^
      1 error


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      enum E { }

      class X {
          void f(Enum<?> o) {
            if (o instanceof E) {
              return;
            }
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      use E.class.isInstance(o)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mcimadamore Maurizio Cimadamore
                Reporter:
                ryeung Roger Yeung (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: