[PATCH] compareTo for Number sub-classes in java.lang

Dalibor Topic kaffe@rufus.w3.org
Wed, 20 Mar 2002 15:14:20 +0100



--------------Boundary-00=_WJZ9E0KLEULK4XR5DLWC
Content-Type: text/plain;
  charset="iso-8859-15"
Content-Transfer-Encoding: 8bit

Hi,

I tried to run make check with javac 1.3.1 and it failed on SortTest.java. It 
turned out that javac was using jdk's classes and generating code to call 
Integer.compareTo(Integer). That method is not implemented yet, so kaffe 
complained.

It is an interoperability issue. In Klasses.jar, only 
Integer.compareTo(Object) exists, thus all virtual calls go there. In jdk 
1.2+, there is a compareTo(own type) method. The compiler generates calls to 
the own type version, if it can.

This patch adds the compareTo(own type) method to sub classes of 
java.lang.Number, and adapts the compareTo(Object) method to call it.

have fun,

dalibor topic
--------------Boundary-00=_WJZ9E0KLEULK4XR5DLWC
Content-Type: text/plain;
  charset="iso-8859-15";
  name="ChangeLog"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="ChangeLog"

CSogbGlicmFyaWVzL2phdmFsaWIvamF2YS9sYW5nL0J5dGUuamF2YSwKCWxpYnJhcmllcy9qYXZh
bGliL2phdmEvbGFuZy9DaGFyYWN0ZXIuamF2YSwKCWxpYnJhcmllcy9qYXZhbGliL2phdmEvbGFu
Zy9Eb3VibGUuamF2YSwKCWxpYnJhcmllcy9qYXZhbGliL2phdmEvbGFuZy9GbG9hdC5qYXZhLAoJ
bGlicmFyaWVzL2phdmFsaWIvamF2YS9sYW5nL0ludGVnZXIuamF2YSwKCWxpYnJhcmllcy9qYXZh
bGliL2phdmEvbGFuZy9Mb25nLmphdmEsCglsaWJyYXJpZXMvamF2YWxpYi9qYXZhL2xhbmcvU2hv
cnQuamF2YToKCWFkZGVkIGNvbXBhcmVUbyBtZXRob2RzIHRvIGNvbXBhcmUgd2l0aCBzYW1lIHR5
cGUuCg==

--------------Boundary-00=_WJZ9E0KLEULK4XR5DLWC
Content-Type: text/x-diff;
  charset="iso-8859-15";
  name="compareTo.patch"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="compareTo.patch"

ZGlmZiAtdXIga2FmZmUvbGlicmFyaWVzL2phdmFsaWIvamF2YS9sYW5nL0J5dGUuamF2YSBwYXRj
aGVkLWthZmZlL2xpYnJhcmllcy9qYXZhbGliL2phdmEvbGFuZy9CeXRlLmphdmEKLS0tIGthZmZl
L2xpYnJhcmllcy9qYXZhbGliL2phdmEvbGFuZy9CeXRlLmphdmEJVGh1IEp1bCAgOCAyMDowNToy
NCAxOTk5CisrKyBwYXRjaGVkLWthZmZlL2xpYnJhcmllcy9qYXZhbGliL2phdmEvbGFuZy9CeXRl
LmphdmEJV2VkIE1hciAyMCAxNDoyMjoxOSAyMDAyCkBAIC05Myw4ICs5MywxMSBAQAogCXJldHVy
biAobmV3IEJ5dGUocGFyc2VCeXRlKHMsIHJhZGl4KSkpOwogfQogCi1wdWJsaWMgaW50IGNvbXBh
cmVUbyhPYmplY3QgbykgewotCXJldHVybiAoaW50KXZhbHVlIC0gKGludCkoKEJ5dGUpbykudmFs
dWU7CitwdWJsaWMgaW50IGNvbXBhcmVUbyhCeXRlIGIpIHsKKwlyZXR1cm4gKGludCl2YWx1ZSAt
IChpbnQpYi52YWx1ZTsKIH0KIAorcHVibGljIGludCBjb21wYXJlVG8oT2JqZWN0IG8pIHsKKwly
ZXR1cm4gY29tcGFyZVRvKChCeXRlKSBvKTsKK30KIH0KZGlmZiAtdXIga2FmZmUvbGlicmFyaWVz
L2phdmFsaWIvamF2YS9sYW5nL0NoYXJhY3Rlci5qYXZhIHBhdGNoZWQta2FmZmUvbGlicmFyaWVz
L2phdmFsaWIvamF2YS9sYW5nL0NoYXJhY3Rlci5qYXZhCi0tLSBrYWZmZS9saWJyYXJpZXMvamF2
YWxpYi9qYXZhL2xhbmcvQ2hhcmFjdGVyLmphdmEJU2F0IFNlcCAxOCAwMTowOTo1MiAxOTk5Cisr
KyBwYXRjaGVkLWthZmZlL2xpYnJhcmllcy9qYXZhbGliL2phdmEvbGFuZy9DaGF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0Y2hlZC1r
YWZmZS9saWJyYXJpZXMvamF2YWxpYi9qYXZhL2xhbmcvU2hvcnQuamF2YQotLS0ga2FmZmUvbGli
cmFyaWVzL2phdmFsaWIvamF2YS9sYW5nL1Nob3J0LmphdmEJVGh1IEp1bCAgOCAyMDowNToyNiAx
OTk5CisrKyBwYXRjaGVkLWthZmZlL2xpYnJhcmllcy9qYXZhbGliL2phdmEvbGFuZy9TaG9ydC5q
YXZhCVdlZCBNYXIgMjAgMTQ6MjI6MDggMjAwMgpAQCAtNDksNyArNDksMTEgQEAKIH0KIAogcHVi
bGljIGludCBjb21wYXJlVG8oT2JqZWN0IG8pIHsKLQlyZXR1cm4gKGludCl2YWx1ZSAtIChpbnQp
KChTaG9ydClvKS52YWx1ZTsKKwlyZXR1cm4gY29tcGFyZVRvKChTaG9ydCkgbyk7Cit9CisKK3B1
YmxpYyBpbnQgY29tcGFyZVRvKFNob3J0IHMpIHsKKwlyZXR1cm4gKGludCl2YWx1ZSAtIChpbnQp
cy52YWx1ZTsKIH0KIAogcHVibGljIGZsb2F0IGZsb2F0VmFsdWUoKQo=

--------------Boundary-00=_WJZ9E0KLEULK4XR5DLWC--



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com