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

Unboxing in return from lambda miscompiled to throw ClassCastException

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 9, 10, 10.0.1, 11
    • Fix Version/s: 11
    • Component/s: tools
    • Subcomponent:
    • Resolved In Build:
      b19
    • CPU:
      generic
    • OS:
      generic

      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:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: