Bug in Boolean constructor

Maxim Kizub max at immsp.kiev.ua
Sat Nov 21 12:13:08 PST 1998


-----Original Message-----
From: Stephen Summerfield <stephen at netality.com>
To: kaffe at transvirtual.com <kaffe at transvirtual.com>
Date: 21 íîÿáðÿ 1998 ã. 20:40
Subject: Bug in Boolean constructor


>I discovered a bug in Kaffe 1.0.b2, in the java.lang.Boolean
>constructor.
>The following program shows the problem:
>
>public class TestBoolean {
>
>public static void main( String[] args ) {
> System.out.println( "new Boolean(\"false\")=" + new
>Boolean("false") );
> System.out.println( "new Boolean(\"true\")=" + new
>Boolean("true") );
>}
>}
>
>The result is true in both cases, instead of false and true.
>
>The fix is as follows:
>
>public Boolean(String s)
> {
> //if (s != null || s.equals("true")) {
> if (s != null && s.equals("true")) {  //<-- Changed to this
> value = true;
> }
> else {
> value = false;
> }
>}


The test for "true" must be case-insensitive !!!
"true", "TRUE", "True" ...




More information about the kaffe mailing list