Re: j2s-development] Java 5 internal type conversion bug!
Brought to you by:
zhourenjian
|
From: Josson S. <jo...@sj...> - 2006-06-15 13:27:31
|
Some bugs of autoboxing are fixed. Check out codes, please.
But there are lots of others leaving unfixed. For example:
Float f = new Float(324.0);
f++;
System.out.println(f);
It seems that autoboxing and primitive types have lots of critical
differences for Java and JavaScript. And that there will be endless
bugs. So I think I should list autoboxing as the big thing in the defect
list.
Soheil Hassas Yeganeh wrote:
> yes! exactly!
>
> On 6/11/06, Josson Smith <jo...@sj...> wrote:
>
>> Now I get the point.
>>
>> It seems that Java2Script compiler should compile
>> m.put ("x", 1);
>> into
>> m.put("x", new Integer(1));
>> for all those autoboxing methods
>>
>> /js
>>
>> Soheil Hassas Yeganeh wrote:
>>
>>> I'm agreed with your points. But, I'm arguing about something different.
>>>
>>> Consider the example I've told before :
>>> Map m = new HashMap();
>>> m.put("x", 1); // Now works with m.put("x", new Integer(1));
>>> if( m.get("x") instanceof Integer){
>>> System.out.println("J2S Works!");
>>> }
>>> System.out.println(((Integer)m.get("x")).intValue()); // ***
>>> ...
>>> When the number is constructed with Integer constructor call, J2S
>>> works. But, without the initialization it does not.
>>> In other words, in Java 5, 1 is instance of Integer, 1l is insatnce of
>>> Long, 1d is intanceof Double, and false is instance of Boolean,
>>> without any constructor call.
>>> But as you said, there are no differences between Integer.intValue()
>>> and Double.doubleValue() of 1 in javascript. I think at least we have
>>> to propose proper classes for them.
>>> Suppose the *** line, J2S will say intValue is not found!
>>>
>>> Regards,
>>> Soheil
>>>
>>>
>>> _______________________________________________
>>> j2s-development mailing list
>>> j2s...@li...
>>> https://lists.sourceforge.net/lists/listinfo/j2s-development
>>>
>>>
>>>
>>>
>>
>> _______________________________________________
>> j2s-development mailing list
>> j2s...@li...
>> https://lists.sourceforge.net/lists/listinfo/j2s-development
>>
>>
>
>
> _______________________________________________
> j2s-development mailing list
> j2s...@li...
> https://lists.sourceforge.net/lists/listinfo/j2s-development
>
>
>
--
Regards
/js
|