[
https://issues.apache.org/jira/browse/THRIFT-4476?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16403451#comment-16403451
]
ASF GitHub Bot commented on THRIFT-4476:
----------------------------------------
GitHub user ozymaxx reopened a pull request:
https://github.com/apache/thrift/pull/1496
THRIFT-4476: Typecasting problem on list items (+ low precision double
rendering, + mis-rendering non-fractional double literals in Python)
- high precision double rendering in JS, Java, Python and C++
- testing double rendering in JS, Java, Python and C++
see the related issue: https://issues.apache.org/jira/browse/THRIFT-4476
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/ozymaxx/thrift THRIFT-4476
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/thrift/pull/1496.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #1496
----
commit f5a6337d4448a30c284a3033307865dfc992ac7d
Author: Ozan Can Altiok <ozan@...>
Date: 2018-02-19T13:55:09Z
- high precision double rendering in JS, Java, Python and C++
- testing double rendering in JS, Java, Python and C++
commit 6dbc35f74fe53a9bacf06867036c21f2761c823e
Author: Ozan Can Altiok <ozan@...>
Date: 2018-02-22T09:47:27Z
- a comment added (about setprecision)
- BOOST_TEST -> BOOST_CHECK
commit 55e3371ed9ea7eadc5826a7f17d3e432e9b99858
Author: Ozan Can Altiok <ozan@...>
Date: 2018-02-23T14:10:15Z
double rendering in erlang, fixed (some additional tests added)
commit 36cc6f9dfe5b508a531ad70958ca3209c3b65e84
Author: Ozan Can Altiok <ozan@...>
Date: 2018-02-23T14:44:31Z
less than operator - correction in erlang test
commit a22d72f024bbf463895022792a31d04054a79445
Author: Ozan Can Altiok <ozan@...>
Date: 2018-02-26T06:17:16Z
style changes, some fixes in erlang test
commit a615812729096a7fa106f8259eb2f41d61ac99ce
Author: Ozan Can Altiok <ozan@...>
Date: 2018-02-26T06:51:24Z
some fixes in erlang test
commit 50b9a3fc69b82a9af2e78602a2e60b9a649874ee
Author: Ozan Can Altiok <ozan@...>
Date: 2018-02-26T07:22:41Z
some fixes in erlang test - no need for including lists library
commit b4e9ce56aecf75beffbf77864f02891808072204
Author: Ozan Can Altiok <ozan@...>
Date: 2018-02-26T09:31:46Z
more style changes - something overlooked
commit 39bb546d0ccbec7177866a1a78d9b5f4de0d9ec1
Author: Ozan Can Altiok <ozan@...>
Date: 2018-02-26T10:24:45Z
expected 2 lines before main - fixed (not seen locally)
commit 98db81883af06d10e9277fb32988edfd3f044d1d
Author: Ozan Can Altiok <ozan@...>
Date: 2018-02-26T11:24:05Z
noticed that test cases should be added manually in Python
commit 64aae330efac4ee23ed01694bc7dceb5a7a9164b
Author: Ozan Can Altiok <ozan@...>
Date: 2018-02-27T06:48:48Z
DoubleConstantTest thrift compilation directive is now given in
generate.cmake
commit decb436f40990e0a04be9730accd3becab951c39
Author: Ozan Can Altiok <ozan@...>
Date: 2018-02-28T06:13:34Z
render_double_to_string -> emit_double_as_string
commit e9b2e389b1184efa4d8ad1d6424ec52a108b80c9
Author: Ozan Can Altiok <ozan@...>
Date: 2018-03-02T12:45:54Z
added assertion error messages to see the problems inside Java tests in
more detail
commit 248e8a4c208e518da30f761a2d836ff790cd9b0d
Author: Ozan Can Altiok <ozan@...>
Date: 2018-03-05T06:59:59Z
RDP access to AppVeyor build workers
commit dd9b65113f143f13e6524917add6c216b16f86e5
Author: Ozan Can Altiok <ozan@...>
Date: 2018-03-05T07:01:07Z
Merge branch 'master' of https://github.com/apache/thrift into THRIFT-4476
commit 65a6588d049dcbbef7d3df5d7c3ba9a7b141917a
Author: Ozan Can Altiok <ozan@...>
Date: 2018-03-05T07:03:20Z
duplicate key problem in appveyor settings
commit 6305384d9203bd532983d18a992515db802b29a5
Author: Ozan Can Altiok <ozan@...>
Date: 2018-03-05T09:31:22Z
ignore the test cases with (-+)1.7e+308 in Java tests
commit 74667acf55c435c661c5fc19de729eb5f82758dc
Author: Ozan Can Altiok <ozan@...>
Date: 2018-03-05T10:00:31Z
ignore the test cases with (-+)1.7e+308 in Java tests - 2
commit 85b872bac39078446aa27336ca57001022524fc0
Author: Ozan Can Altiok <ozan@...>
Date: 2018-03-05T12:18:14Z
pyflakes8 style changes
commit af11ef8c7475c5f57f2d6619bedea23856a0fd17
Author: Ozan Can Altiok <ozan@...>
Date: 2018-03-06T08:21:51Z
disabling the test named 'TestRenderedDoubleConstants' on machines with the
MSVC2010 configuration
commit 8ed1997141dce6c4b4505b09d2d6843344dfa04b
Author: Ozan Can Altiok <ozan@...>
Date: 2018-03-06T08:58:25Z
msvc.profile parameter existence check
commit beb12744f990ed0890648b07d81f19c121303c59
Author: Ozan Can Altiok <ozan@...>
Date: 2018-03-06T12:05:04Z
passing "msvc profile" on build stage
commit 1a0756aa8d48b693ae39dd860bdbeb7de5252cae
Author: Ozan Can Altiok <ozan@...>
Date: 2018-03-06T12:50:10Z
"MSVC_PROFILE" as a cache variable
commit b40fc4e06083f2787db3f805756abe7e6c2c704d
Author: Ozan Can Altiok <ozan@...>
Date: 2018-03-06T13:01:48Z
wrong usage of cache variables
commit ef43030fd69f1dee060c3cf447acfcceefb4be71
Author: Ozan Can Altiok <ozan@...>
Date: 2018-03-06T13:19:42Z
let's see whether the MSVC_PROFILE parameter is passed correctly
commit ec32218d28d6054f6fa5148c0d5d24236660afcf
Author: Ozan Can Altiok <ozan@...>
Date: 2018-03-06T13:23:39Z
let's see whether the MSVC_PROFILE parameter is passed correctly
commit bd1207f29b0662022e46371d1b1cc7be37013151
Author: Ozan Can Altiok <ozan@...>
Date: 2018-03-06T14:03:27Z
let's see whether TestRenderedDoubleConstants is excluded or not
commit 6c3e243c2afc09d726113ae578b5236e673640ad
Author: Ozan Can Altiok <ozan@...>
Date: 2018-03-06T14:49:41Z
msvc.profile access - fixed
commit 201fcb541ae3a5774b509efc5f3d036c85e2495f
Author: Ozan Can Altiok <ozan@...>
Date: 2018-03-07T06:22:34Z
msvc.profile access - fixed
commit 788118364ae60781f56779f89b33e90aee116750
Author: Ozan Can Altiok <ozan@...>
Date: 2018-03-07T06:27:45Z
Merge branch 'master' of https://github.com/apache/thrift into THRIFT-4476
----
> 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 a thrift interface file.
> {{const list<double> timeCoefficients = [24, 60, 60, 1000, 1000, 1000]}}
> With the definition given above the {{.thrift}} file compiled properly.
> However, I noticed that in Python, the items in {{timeCoefficients}} are
> considered to be integer although the list has been defined to include items
> of {{double}} type. Then I modified the definition as given below to make
> sure all the items are of type {{double}}.
> {{const list<double> timeCoefficients = [24.0, 60.0, 60.0, 1000.0, 1000.0,
> 1000.0]}}
> After the change, I ran into the following error during compilation.
> {{[ERROR] .../TimeCoefficients.java:[402,48] error: no suitable method found
> for add(int)}}
> {{[ERROR] method Collection.add(Double) is not applicable}}
> {{[ERROR] (argument mismatch; int cannot be converted to Double)}}
> {{[ERROR] method List.add(Double) is not applicable}}
> {{[ERROR] (argument mismatch; int cannot be converted to Double)}}
> Next, I changed the line as follows and the compilation became successful.
> {{const list<double> timeCoefficients = [24.1, 60.1, 60.1, 1000.1, 1000.1,
> 1000.1]}}
> When I reviewed the generated Java source files, I discovered that
> {{const list<double> timeCoefficients = [24, 60, 60, 1000, 1000, 1000]}}
> compiles to
> {{public static final java.util.List<java.lang.Double> timeCoefficients = new
> java.util.ArrayList<java.lang.Double>();}}
> {{static {}}
> {{ timeCoefficients.add((double)24);}}
> {{ timeCoefficients.add((double)60);}}
> {{ timeCoefficients.add((double)60);}}
> {{ timeCoefficients.add((double)1000);}}
> {{ timeCoefficients.add((double)1000);}}
> {{ timeCoefficients.add((double)1000);}}
> {{}}}
> whilst
> {{const list<double> timeCoefficients = [24.0, 60.0, 60.0, 1000.0, 1000.0,
> 1000.0]}}
> compiles to
> {{public static final java.util.List<java.lang.Double> timeCoefficients = new
> java.util.ArrayList<java.lang.Double>();}}
> {{static {}}
> {{ timeCoefficients.add(24);}}
> {{ timeCoefficients.add(60);}}
> {{ timeCoefficients.add(60);}}
> {{ timeCoefficients.add(1000);}}
> {{ timeCoefficients.add(1000);}}
> {{ timeCoefficients.add(1000);}}
> {{}}}
> which leads to an error.
> When I modified this line as follows
> {{const list<double> timeCoefficients = [24.1, 60.1, 60.1, 1000.1, 1000.1,
> 1000.1]}}
> this line compiled to
> {{public static final java.util.List<java.lang.Double> timeCoefficients = new
> java.util.ArrayList<java.lang.Double>();}}
> {{static {}}
> {{ timeCoefficients.add(24.1);}}
> {{ timeCoefficients.add(60.1);}}
> {{ timeCoefficients.add(60.1);}}
> {{ timeCoefficients.add(1000.1);}}
> {{ timeCoefficients.add(1000.1);}}
> {{ timeCoefficients.add(1000.1);}}
> {{}}}
> My guess is that, even if I put {{.0}} at the end of each numeric constant,
> on the Java side, Thrift compiler considers them to be {{double}} and does no
> typecasts. However, the {{.0}} s are getting lost somewhere and the items
> become integers in the generated Java code. Thus, when it comes to populating
> the array, Java cannot succeed. {{Double}} s cannot be unboxed to integer and
> Java thinks {{int}} and {{Double}} are not related.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)