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

javac allows to use different types of 2nd and 3rd ops in Conditional Op. ?

XMLWordPrintable

    • ladybird
    • sparc
    • solaris_7
    • Verified

        The following code has been compiled with Kestrel's javac:

        class test {
            public static void main (String [] args) {
        System.out.println(true?0:false);
        if((true?false:0)==(true?false:0));
            }
        }

        According to JLS 15.24.2 "The conditional operator may be used to choose between second and third operands of numeric type, or second and third operands of type boolean, or second and
        third operands that are each of either reference type or the null type. All other cases
        result in a compile-time error."

        So, "Can't convert boolean to int" or something like that error message should appear.

        konstantin.boudnik@eng 2000-02-15

              gafter Neal Gafter (Inactive)
              kboudniksunw Konstantin Boudnik (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: