This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: kawa 1.14: java.io.PrintWriter prints everything as "true"
- From: Per Bothner <per at bothner dot com>
- To: Ito Kazumitsu <kaz at maczuka dot gcd dot org>
- Cc: kawa at sourceware dot org
- Date: Tue, 08 Oct 2013 22:56:36 -0700
- Subject: Re: kawa 1.14: java.io.PrintWriter prints everything as "true"
- Authentication-results: sourceware.org; auth=none
- References: <20131008 dot 131857 dot 433844808 dot kaz at maczuka dot gcd dot org> <5253AEAA dot 6030605 at bothner dot com> <20131009 dot 105106 dot 389956539 dot kaz at maczuka dot gcd dot org>
On 10/08/2013 06:51 PM, Ito Kazumitsu wrote:
I succeeded in simplifying the script significantly.
Indeed, that is a helpful testcase. Thanks.
The bug war introduced 2013-06-02 when fixing Savannah bug #39047
"Wrong incompatible type (boolean) with expected int".
Specifically the changes in the compare method in LangPrimType.java.
"Fixing" that method fixes your bug, but causes other issues
I'm looking at.
The underlying issue is that Scheme allows any value to
used as a boolean. Kawa generalizes this so that any value
can be converted to boolean - which then leads to some
awkwardness with overload resolution: Which is the
"more specific method" of:
PrintWriter#println(boolean)
PrintWriter#println(Object)
They are equally general, in that any value can be converted to boolean,
and any value can be converted to Object. I think we have this ok
when it comes to compile-time method selection (bug #39047 was partly
about fixing this), but it may be harder to get it right for run-time
method selection. However, I will keep looking at the problem.
To work around the problem you can do:
(define-constant wtr
(java.io.PrintWriter
(java.io.OutputStreamWriter (java.lang.System:.out) "UTF-8")))
or:
(define wtr ::java.io.PrintWriter
(java.io.PrintWriter
(java.io.OutputStreamWriter (java.lang.System:.out) "UTF-8")))
--
--Per Bothner
per@bothner.com http://per.bothner.com/