Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 44540 invoked from network); 3 Aug 2009 02:51:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 3 Aug 2009 02:51:32 -0000 Received: (qmail 25644 invoked by uid 500); 3 Aug 2009 02:51:37 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 25590 invoked by uid 500); 3 Aug 2009 02:51:37 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 25497 invoked by uid 99); 3 Aug 2009 02:51:37 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Aug 2009 02:51:37 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Aug 2009 02:51:35 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 39098234C04C for ; Sun, 2 Aug 2009 19:51:15 -0700 (PDT) Message-ID: <1200396238.1249267875232.JavaMail.jira@brutus> Date: Sun, 2 Aug 2009 19:51:15 -0700 (PDT) From: "Nathan Beyer (JIRA)" To: commits@harmony.apache.org Subject: [jira] Commented: (HARMONY-6289) Inconsistent behaviour of ternary operator and types In-Reply-To: <458124373.1249222754796.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HARMONY-6289?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12738172#action_12738172 ] Nathan Beyer commented on HARMONY-6289: --------------------------------------- It's not a bug, this is actually the correct behavior, at least as I understand it. You can talk to the ECJ for Sun javac folks to get more information. This is just a quirk of the generics syntax. The correct syntax for the ternary operator in this case would be as follows. functions = funcs != null ? funcs : Collections.emptyMap(); > Inconsistent behaviour of ternary operator and types > ---------------------------------------------------- > > Key: HARMONY-6289 > URL: https://issues.apache.org/jira/browse/HARMONY-6289 > Project: Harmony > Issue Type: Bug > Components: JDK > Affects Versions: 5.0M10 > Environment: Eclipse Java Compiler 0.894_R34x, 3.4.2 release, Copyright IBM Corp 2000, 2008. All rights reserved. > WinXP/SP3 > Reporter: Sebb > > Compile the following class using: javac -5 TernaryType.java > ==== cut here ==== > import java.util.*; > class TernaryType { > > Map functions; > public void setFunctionsBug(Map funcs) { > functions = funcs != null ? funcs : Collections.emptyMap(); > } > public void setFunctionsOK(Map funcs) { > if (funcs != null) { > functions = funcs; > } else { > functions = Collections.emptyMap(); > } > } > } > === cut here === > Compiler output is: > 1. ERROR in TernaryType.java (at line 8) > functions = funcs != null ? funcs : Collections.emptyMap(); > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > Type mismatch: cannot convert from Map to Map > The two methods have exactly the same behaviour, yet only the ternary version generates an error. > Note that the Sun 1.5 and 1.6 compilers behave the same way, but it still seems like a bug to me. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.