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

(inference) Autoboxing not working for conditional operator ?:

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      libs/src/java_lang/autoboxing/Phase2/ConditionalOperatorTest

      According to the spec for Autoboxing and Unboxing
      http://ccc.sfbay.sun.com/4989021/attachment/autoboxing.html

      JLS 15.25 Conditional Operator ?:

      According to one of the rules:-

      If one of the operands is of type T where T is byte, short, or char and the other operand is a constant expression of type int whose value is representable in type T, then the type of the conditional expression is T.

      the piece of code mention below does not compile:-
      Boolean t_ref = true;
      Character ch_ref = t_ref ? 65 : 'A'

      Compilation Error is:-
      found : int
      required: java.lang.Character
                 Character ch_ref1 = BasicData.t_ref ? 65 : 'A';

      Where as the piece of code mention below compiles:-

      Character ch_ref = new Character(t_ref ? 65 : 'A');

      JDK Build :- Tiger-beta2 build 39
      OS:- Tried on Solsparc-9

        Attachments

          Activity

            People

            Assignee:
            ahe Peter Ahe
            Reporter:
            jsinghsunw Jit Singh (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: