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

javac emits duplicate checkcast for first bound of intersection type in cast

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b26
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Description

      A DESCRIPTION OF THE PROBLEM :
      It appears `javac` emits a duplicate `checkcast` for the first bound of an intersection type as part of a cast expression.

      Possibly related to JDK-8011392

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Compile the class IntersectionTypeTest provided below
      2. Decompile the class file with `javap -v`
      3. Look at the byte code for method `test2`

      ACTUAL -
               1: checkcast #9 // class IntersectionTypeTest$C1
               4: checkcast #7 // class IntersectionTypeTest$I1
               7: checkcast #9 // class IntersectionTypeTest$C1

      ---------- BEGIN SOURCE ----------
      class IntersectionTypeTest {
          interface I1 { }
          static class C1 { }
          
          static Object test(Object o) {
              // As expected: Single checkcast I1
              return (I1) o;
          }
          
          static Object test2(Object o) {
              // Unexpected: Duplicate checkcast C1
              return (C1 & I1) o;
          }
      }
      ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              gli Guoxiong Li
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: