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

Unboxing in return from lambda miscompiled to throw ClassCastException

    Details

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

      Backports

        Description

        A DESCRIPTION OF THE PROBLEM :
        In this example a lambda Comparable (so with return type int) returns a Character. This should cause unboxing and then conversion to int. But javac generates code that instead tries to convert the Character to Integer before the unboxing, leading to an unexpected ClassCastException


        ---------- BEGIN SOURCE ----------
        List.of('x', 'y').stream()
          .max((a, b) -> {return List.of(a).get(0);});
        ---------- END SOURCE ----------

        FREQUENCY : always


          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  bsrbnd Bernard Blaser
                  Reporter:
                  webbuggrp Webbug Group
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: