[Kaffe] patches for Byte and Short.
Moses DeJong
dejong at cs.umn.edu
Thu Feb 4 16:35:07 PST 1999
Here are a couple of quick patches that fix NullPointerExceptions in
the equals() method for Byte and Short.
later
mo dejong
dejong at cs.umn.edu
Index: Byte.java
===================================================================
RCS file: /home/cvspublic/kaffe/libraries/javalib/java/lang/Byte.java,v
retrieving revision 1.7
diff -u -r1.7 Byte.java
--- Byte.java 1999/01/28 19:25:46 1.7
+++ Byte.java 1999/02/05 01:37:21
@@ -49,13 +49,21 @@
}
public boolean equals(Object obj) {
- try {
+ // Catch the simple case where they're really the same
+ if (this == obj) {
+ return (true);
+ }
+ // If obj is null then they are not the same
+ if (obj == null) {
+ return (false);
+ }
+ // Check the val of the argument object
+ try {
if (((Byte)obj).val == val) {
return (true);
}
- }
- catch (ClassCastException _) {
}
+ catch (ClassCastException _) {}
return (false);
}
Index: Short.java
===================================================================
RCS file: /home/cvspublic/kaffe/libraries/javalib/java/lang/Short.java,v
retrieving revision 1.2
diff -u -r1.2 Short.java
--- Short.java 1998/08/05 21:16:19 1.2
+++ Short.java 1999/02/05 01:37:21
@@ -53,15 +53,22 @@
return ((double)val);
}
-public boolean equals(Object obj)
- {
- try {
+public boolean equals(Object obj) {
+ // Catch the simple case where they're really the same
+ if (this == obj) {
+ return (true);
+ }
+ // If obj is null then they are not the same
+ if (obj == null) {
+ return (false);
+ }
+ // Check the val of the argument object
+ try {
if (((Short)obj).val == val) {
return (true);
}
- }
- catch (ClassCastException _) {
}
+ catch (ClassCastException _) {}
return (false);
}
More information about the kaffe
mailing list