diff --git a/classpath/java/lang/Boolean.java b/classpath/java/lang/Boolean.java index be44e955d5..e2b6a10fbf 100644 --- a/classpath/java/lang/Boolean.java +++ b/classpath/java/lang/Boolean.java @@ -1,6 +1,6 @@ package java.lang; -public final class Boolean { +public final class Boolean implements Comparable { public static final Class TYPE = Class.forCanonicalName("Z"); public static final Boolean FALSE = new Boolean(false); @@ -24,6 +24,10 @@ public final class Boolean { return ("true".equals(s) ? Boolean.TRUE : Boolean.FALSE); } + public int compareTo(Boolean o) { + return (value ? (o.value ? 0 : 1) : (o.value ? -1 : 0)); + } + public boolean equals(Object o) { return o instanceof Boolean && ((Boolean) o).value == value; } diff --git a/classpath/java/lang/Byte.java b/classpath/java/lang/Byte.java index 3007906695..1d1f4caac2 100644 --- a/classpath/java/lang/Byte.java +++ b/classpath/java/lang/Byte.java @@ -1,6 +1,6 @@ package java.lang; -public final class Byte extends Number { +public final class Byte extends Number implements Comparable { public static final Class TYPE = Class.forCanonicalName("B"); private final byte value; @@ -25,6 +25,10 @@ public final class Byte extends Number { return toString(value); } + public int compareTo(Byte o) { + return value - o.value; + } + public static String toString(byte v, int radix) { return Long.toString(v, radix); } diff --git a/classpath/java/lang/Character.java b/classpath/java/lang/Character.java index dd7658d52b..b5543e9e5c 100644 --- a/classpath/java/lang/Character.java +++ b/classpath/java/lang/Character.java @@ -1,6 +1,6 @@ package java.lang; -public final class Character { +public final class Character implements Comparable { public static final Class TYPE = Class.forCanonicalName("C"); private final char value; @@ -13,6 +13,10 @@ public final class Character { return new Character(value); } + public int compareTo(Character o) { + return value - o.value; + } + public boolean equals(Object o) { return o instanceof Character && ((Character) o).value == value; } diff --git a/classpath/java/lang/Long.java b/classpath/java/lang/Long.java index 401d31492f..013ac883bb 100644 --- a/classpath/java/lang/Long.java +++ b/classpath/java/lang/Long.java @@ -1,6 +1,6 @@ package java.lang; -public final class Long extends Number { +public final class Long extends Number implements Comparable { public static final Class TYPE = Class.forCanonicalName("J"); public static final Long MAX_VALUE = 9223372036854775807l; @@ -22,6 +22,10 @@ public final class Long extends Number { return new Long(value); } + public int compareTo(Long o) { + return value > o.value ? 1 : (value < o.value ? -1 : 0); + } + public boolean equals(Object o) { return o instanceof Long && ((Long) o).value == value; } diff --git a/classpath/java/lang/Short.java b/classpath/java/lang/Short.java index 8c3834eff6..bfca752af5 100644 --- a/classpath/java/lang/Short.java +++ b/classpath/java/lang/Short.java @@ -1,6 +1,6 @@ package java.lang; -public final class Short extends Number { +public final class Short extends Number implements Comparable { public static final Class TYPE = Class.forCanonicalName("S"); public static final short MAX_VALUE = 32767; @@ -14,6 +14,10 @@ public final class Short extends Number { return new Short(value); } + public int compareTo(Short o) { + return value - o.value; + } + public boolean equals(Object o) { return o instanceof Short && ((Short) o).value == value; }