[ nice-Bugs-871232 ] Byte Integer type param interfaces
"SourceForge.net" <[email protected]>
| Newsgroups | gmane.comp.lang.nice.devel |
|---|---|
| Message-ID | <[email protected]> |
Bugs item #871232, was opened at 2004-01-05 22:38
Message generated for change (Comment added) made by bonniot
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112788&aid=871232&group_id=12788
Category: None
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Isaac Gouy (igouy)
>Assigned to: Daniel Bonniot (bonniot)
Summary: Byte Integer type param interfaces
Initial Comment:
set() converts Integer to Byte?
\Nice\Test>java -jar t.jar
set 1 class java.lang.Byte
get 1 class java.lang.Integer
Exception in
thread "main"java.util.NoSuchElementException
at test.fun.get(I:\pls\Nice\Test\..\test:10)
at test.dispatch.get()
at test.fun.main(I:\pls\Nice\Test\..\test:17)
void main(String[] args){
HashPropertyMap<int, double> h = new
HashPropertyMap();
h.set(1, 2.5);
h.get(1);
}
public interface ReadablePropertyMap<K, V> {
V get(K key);
}
public interface ReadWritePropertyMap<K, V> extends
ReadablePropertyMap<K, V> {
void set(K key, V value);
}
public class HashPropertyMap<K, V>
implements ReadWritePropertyMap<K, V> {
private HashMap<K, V> data = new HashMap();
set(key, value){
let o = object(key);
if (o != null) println("set " key " " o.getClass());
data.put(key, value);
}
get(key){
let o = object(key);
if (o != null) println("get " key " " o.getClass());
let res = data[key];
if (res == null)
throw new NoSuchElementException();
return res;
}
}
----------------------------------------------------------------------
Comment By: Daniel Bonniot (bonniot)
Date: 2004-01-17 18:14
Message:
Logged In: YES
user_id=88952
This bug has been fixed. The next release of the compiler will
include this correction. In the mean time, I encourage you try
the development version. It contains a version of the compiler
that fixes the bug. Please try it and reopen the bug-report if
you find any problem with it.
To know how to get an install the development version of the
compiler that fixes this bug, please read
http://nice.sourceforge.net/cgi-bin/twiki/view/Dev/DevelopmentVersion
Thanks again for your help by submiting this bug report.
Daniel Bonniot
----------------------------------------------------------------------
Comment By: Arjan Boeijink (arjanb)
Date: 2004-01-08 21:35
Message:
Logged In: YES
user_id=688815
The difference in compiling the literals in the get an the set
method is caused by whether the instanciatedDomain in
CallExp.java is calculated or not.
Daniel I think this one is for you to fix.
----------------------------------------------------------------------
Comment By: Arjan Boeijink (arjanb)
Date: 2004-01-06 00:56
Message:
Logged In: YES
user_id=688815
I found an example where the codegeneration is correct but
the result is unexpected because of the java implementation
of the Object versions of the primitives.
int x = 1;
long y = x;
Set<long> set = new HashSet();
set.add(x);
println(set.contains(y));
----------------------------------------------------------------------
Comment By: Isaac Gouy (igouy)
Date: 2004-01-06 00:36
Message:
Logged In: YES
user_id=536291
> new Integer(1).equals(new Byte(1)) returning false
I'm not even going to pretend that I understand what's
happening. From an "application programmers" perspective
the key - 1 - in these adjacent statements should turn out to
be the same thing.
h.set(1, 2.5);
h.get(1);
Meanwhile I'll make some progress using keys like 40003,
40004, ...
----------------------------------------------------------------------
Comment By: Arjan Boeijink (arjanb)
Date: 2004-01-06 00:28
Message:
Logged In: YES
user_id=688815
In your examples the codegeneration is wrong but even if this
case is fixed, the problem caused by new Integer(1).equals
(new Byte(1)) returning false could still occur i fear.
----------------------------------------------------------------------
Comment By: Isaac Gouy (igouy)
Date: 2004-01-06 00:09
Message:
Logged In: YES
user_id=536291
void main(String[] args){
HashPropertyMap<int, double> h = new HashPropertyMap();
h.set(32767, 2.5);
h.get(32767);
}
gives:
\Nice\Test>java -jar t.jar
set 32767 class java.lang.Short
get 32767 class java.lang.Integer
Exception in thread "main" java.util.NoSuchElementException
at test.fun.get(I:\pls\Nice\Test\..\test:10)
at test.dispatch.get()
at test.fun.main(I:\pls\Nice\Test\..\test:17)
----------------------------------------------------------------------
Comment By: Arjan Boeijink (arjanb)
Date: 2004-01-05 23:56
Message:
Logged In: YES
user_id=688815
Something is wrong with the code generated in the main
method and but I have no idea why it happens yet.
----------------------------------------------------------------------
Comment By: Isaac Gouy (igouy)
Date: 2004-01-05 22:40
Message:
Logged In: YES
user_id=536291
Nice compiler version 0.9.6 prerelease (build 2004.01.05,
05:42:10 UTC)
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112788&aid=871232&group_id=12788
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn