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

Unboxing in return from lambda miscompiled to throw ClassCastException

    XMLWordPrintable

Details

    • b19
    • generic
    • generic
    • 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

                bsrbnd Bernard Blaser
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: