From dev-return-51697-archive-asf-public=cust-asf.ponee.io@thrift.apache.org Sat Mar 10 00:37:04 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 1A570180676 for ; Sat, 10 Mar 2018 00:37:03 +0100 (CET) Received: (qmail 43471 invoked by uid 500); 9 Mar 2018 23:37:03 -0000 Mailing-List: contact dev-help@thrift.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@thrift.apache.org Delivered-To: mailing list dev@thrift.apache.org Received: (qmail 43458 invoked by uid 99); 9 Mar 2018 23:37:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Mar 2018 23:37:02 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 909E2C005C for ; Fri, 9 Mar 2018 23:37:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -110.311 X-Spam-Level: X-Spam-Status: No, score=-110.311 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id BzH31H8EPHtw for ; Fri, 9 Mar 2018 23:37:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 062585F11F for ; Fri, 9 Mar 2018 23:37:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 6A0F7E0112 for ; Fri, 9 Mar 2018 23:37:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 248E221444 for ; Fri, 9 Mar 2018 23:37:00 +0000 (UTC) Date: Fri, 9 Mar 2018 23:37:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: dev@thrift.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (THRIFT-4476) Typecasting problem on list items MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/THRIFT-4476?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D163= 93803#comment-16393803 ]=20 ASF GitHub Bot commented on THRIFT-4476: ---------------------------------------- Github user jeking3 commented on the issue: https://github.com/apache/thrift/pull/1496 =20 The current master is fairly clean except for a recurring dlang issue. = Squash and rebase on master. Squash to one commit please. > Typecasting problem on list items > --------------------------------- > > Key: THRIFT-4476 > URL: https://issues.apache.org/jira/browse/THRIFT-4476 > Project: Thrift > Issue Type: Bug > Components: Java - Compiler > Affects Versions: 0.11.0 > Reporter: Ozan Can Altiok > Priority: Major > > I was trying to add the following into=C2=A0a thrift interface file. > {{const list timeCoefficients =3D=C2=A0[24, 60, 60, 1000, 1000, 1= 000]}} > With the definition given above the {{.thrift}} file compiled properly. H= owever, I noticed that in Python, the items in=C2=A0{{timeCoefficients}}=C2= =A0are considered to be integer although the list has been defined to inclu= de items of {{double}} type. Then I modified the definition as given below = to make sure all the items are of type {{double}}.=C2=A0 > {{const list timeCoefficients =3D=C2=A0[24.0, 60.0, 60.0, 1000.0,= 1000.0, 1000.0]}} > After the change, I ran into the following error during compilation. > {{[ERROR]=C2=A0.../TimeCoefficients.java:[402,48]=C2=A0error: no suitable= method found for add(int)}} > {{[ERROR]=C2=A0method Collection.add(Double) is not applicable}} > {{[ERROR]=C2=A0(argument mismatch; int cannot be converted to Double)}} > {{[ERROR]=C2=A0method List.add(Double) is not applicable}} > {{[ERROR]=C2=A0(argument mismatch; int cannot be converted to Double)}} > Next, I changed the line as follows and the compilation became successful= . > {{const list timeCoefficients =3D=C2=A0[24.1, 60.1, 60.1, 1000.1,= 1000.1, 1000.1]}} > When I reviewed the generated Java source files, I=C2=A0discovered that > {{const list timeCoefficients =3D=C2=A0[24, 60, 60, 1000, 1000, 1= 000]}} > compiles to > {{public static final java.util.List timeCoefficients = =3D new java.util.ArrayList();}} > {{static {}} > {{=C2=A0 timeCoefficients.add((double)24);}} > {{=C2=A0 timeCoefficients.add((double)60);}} > {{=C2=A0 timeCoefficients.add((double)60);}} > {{=C2=A0 timeCoefficients.add((double)1000);}} > {{=C2=A0 timeCoefficients.add((double)1000);}} > {{=C2=A0 timeCoefficients.add((double)1000);}} > {{}}} > whilst > {{const list timeCoefficients =3D=C2=A0[24.0, 60.0, 60.0, 1000.0,= 1000.0, 1000.0]}} > compiles to > {{public static final java.util.List timeCoefficients = =3D new java.util.ArrayList();}} > {{static {}} > {{=C2=A0 timeCoefficients.add(24);}} > {{=C2=A0 timeCoefficients.add(60);}} > {{=C2=A0 timeCoefficients.add(60);}} > {{=C2=A0 timeCoefficients.add(1000);}} > {{=C2=A0 timeCoefficients.add(1000);}} > {{=C2=A0 timeCoefficients.add(1000);}} > {{}}} > which leads to an error. > When I modified this line as follows > {{const list timeCoefficients =3D=C2=A0[24.1, 60.1, 60.1, 1000.1,= 1000.1, 1000.1]}} > this line compiled to > {{public static final java.util.List timeCoefficients = =3D new java.util.ArrayList();}} > {{static {}} > {{=C2=A0 timeCoefficients.add(24.1);}} > {{=C2=A0 timeCoefficients.add(60.1);}} > {{=C2=A0 timeCoefficients.add(60.1);}} > {{=C2=A0 timeCoefficients.add(1000.1);}} > {{=C2=A0 timeCoefficients.add(1000.1);}} > {{=C2=A0 timeCoefficients.add(1000.1);}} > {{}}} > My guess is that, even if I put=C2=A0{{.0}}=C2=A0at the end of each numer= ic constant, on the Java side, Thrift compiler considers them to be=C2=A0{{= double}} and does no typecasts. However, the {{.0}} s are getting lost some= where and the items become integers in the generated Java code. Thus, when = it comes to populating the array, Java cannot succeed.=C2=A0{{Double}}=C2= =A0s cannot be unboxed to integer and Java thinks=C2=A0{{int}}=C2=A0and=C2= =A0{{Double}}=C2=A0are not related. -- This message was sent by Atlassian JIRA (v7.6.3#76005)