harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r394878 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/lang/ test/java/org/apache/harmony/tests/java/lang/ test/java/tests/api/java/lang/ test/java/tests/api/java/util/
Date Tue, 18 Apr 2006 07:42:26 GMT
Author: mloenko
Date: Tue Apr 18 00:42:22 2006
New Revision: 394878

URL: http://svn.apache.org/viewcvs?rev=394878&view=rev
Log:
fix for HARMONY-356
[classlib][luni] Generics uplift and clean up for java.lang primitive wrappers

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Byte.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Character.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Double.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Float.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Integer.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Long.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Short.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/ByteTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/CharacterTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/DoubleTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ByteTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/CharacterTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/DoubleTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/FloatTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/IntegerTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/LongTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ShortTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/CollectionsTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Byte.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Byte.java?rev=394878&r1=394877&r2=394878&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Byte.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Byte.java
Tue Apr 18 00:42:22 2006
@@ -17,10 +17,9 @@
 
 /**
  * <p>Byte is the wrapper for the primitive type <code>byte</code>.</p>
- * @since 1.0
+ * @since 1.1
  */
-public final class Byte extends Number implements Comparable {
-    //TODO Add Comparable<Byte> to implements when generics are supported.    
+public final class Byte extends Number implements Comparable<Byte> {    
 	private static final long serialVersionUID = -7183698231559129828L;
 
 	/**
@@ -55,7 +54,7 @@
 	/**
 	 * The java.lang.Class that represents this class.
 	 */
-	public static final Class TYPE = new byte[0].getClass().getComponentType();
+	public static final Class<Byte> TYPE = new byte[0].getClass().getComponentType();
 
 	// Note: This can't be set to "byte.class", since *that* is
 	// defined to be "java.lang.Byte.TYPE";
@@ -99,13 +98,24 @@
 		return value;
 	}
 
-	public int compareTo(Byte object) {
-		return value > object.value ? 1 : (value < object.value ? -1 : 0);
-	}
-
-	public int compareTo(Object object) {
-		return compareTo((Byte) object);
-	}
+	/**
+     * <p>
+     * Compares this <code>Byte</code> to the <code>Byte</code> passed.
If
+     * this instance's value is equal to the value of the instance passed, then
+     * 0 is returned. If this instance's value is less than the value of the
+     * instance passed, then a negative value is returned. If this instance's
+     * value is greater than the value of the instance passed, then a positive
+     * value is returned.
+     * </p>
+     * 
+     * @param object The instance to compare to.
+     * @throws NullPointerException if <code>object</code> is
+     *         <code>null</code>.
+     * @since 1.2
+     */
+    public int compareTo(Byte object) {
+        return value > object.value ? 1 : (value < object.value ? -1 : 0);
+    }
 
 	/**
 	 * Parses the string argument as if it was a byte value and returns the

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Character.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Character.java?rev=394878&r1=394877&r2=394878&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Character.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Character.java
Tue Apr 18 00:42:22 2006
@@ -52,8 +52,7 @@
  * 
  * @since 1.0
  */
-public final class Character implements Serializable, Comparable {
-    //TODO Add Comparable<Character> when support for generics is available.
+public final class Character implements Serializable, Comparable<Character> {
 	private static final long serialVersionUID = 3786198910865385080L;
 
 	private final char value;
@@ -84,7 +83,7 @@
 	 * The maximum possible radix used for conversions between Characters and
 	 * integers.
 	 */
-	public static final Class TYPE = new char[0].getClass().getComponentType();
+	public static final Class<Character> TYPE = new char[0].getClass().getComponentType();
 
 	// Note: This can't be set to "char.class", since *that* is
 	// defined to be "java.lang.Character.TYPE";
@@ -1114,26 +1113,11 @@
 	 * @return an int < 0 if this Character is less than the specified
 	 *         Character, 0 if they are equal, and > 0 if this Character is
 	 *         greater
+     * @throws NullPointerException if <code>c</code> is <code>null</code>.
+     * @since 1.2
 	 */
 	public int compareTo(Character c) {
 		return value - c.value;
-	}
-
-	/**
-	 * Compare the receiver to the specified Object to determine the relative
-	 * ordering.
-	 * 
-	 * @param object
-	 *            an Object
-	 * @return an int < 0 if this Character is less than the specified
-	 *         Character, 0 if they are equal, and > 0 if this Character is
-	 *         greater
-	 * 
-	 * @throws ClassCastException
-	 *             when object is not a Character
-	 */
-	public int compareTo(Object object) {
-		return value - ((Character) object).value;
 	}
     
 	/*

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Double.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Double.java?rev=394878&r1=394877&r2=394878&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Double.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Double.java
Tue Apr 18 00:42:22 2006
@@ -23,7 +23,7 @@
  * @see java.lang.Number
  * @since 1.0
  */
-public final class Double extends Number implements Comparable {
+public final class Double extends Number implements Comparable<Double> {
 
 	private static final long serialVersionUID = -9172774392245257468L;
 
@@ -73,7 +73,7 @@
 	 * The java.lang.Class that represents this class.
      * @since 1.1
 	 */
-	public static final Class TYPE = new double[0].getClass()
+	public static final Class<Double> TYPE = new double[0].getClass()
 			.getComponentType();
 
 	// Note: This can't be set to "double.class", since *that* is
@@ -123,6 +123,9 @@
 	 *         object.doubleValue(), zero when this.doubleValue() equals
 	 *         object.doubleValue(), and less than zero when this.doubleValue()
 	 *         is less than object.doubleValue()
+     *         
+     * @throws NullPointerException if <code>object</code> is <code>null</code>.
+     * @since 1.2
 	 */
 	public int compareTo(Double object) {
 		long d1, d2;
@@ -144,26 +147,6 @@
 			return d1 > d2 ? 1 : -1;
 		}
 		return value > object.value ? 1 : -1;
-	}
-
-	/**
-	 * Compares the receiver with a Double parameter.
-	 * 
-	 * @param object
-	 *            the Double to compare to the receiver
-	 * 
-	 * @return Returns greater than zero when this.doubleValue() is greater than
-	 *         object.doubleValue(), zero when this.doubleValue() equals
-	 *         object.doubleValue(), and less than zero when this.doubleValue()
-	 *         is less than object.doubleValue()
-	 * 
-	 * @throws ClassCastException
-	 *             when object is not a Double
-	 * 
-	 * @see #compareTo(Double)
-	 */
-	public int compareTo(Object object) {
-		return compareTo((Double) object);
 	}
 
 	/**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Float.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Float.java?rev=394878&r1=394877&r2=394878&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Float.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Float.java
Tue Apr 18 00:42:22 2006
@@ -24,8 +24,8 @@
  * @see java.lang.Number
  * @since 1.0
  */
-public final class Float extends Number implements Comparable {
-    //TODO Add Comparable<Float> to implements when generics are supported.
+public final class Float extends Number implements Comparable<Float> {
+
 	private static final long serialVersionUID = -2671257302660747028L;
 
 	/**
@@ -72,7 +72,7 @@
 	 * The java.lang.Class that represents this class.
      * @since 1.1
 	 */
-	public static final Class TYPE = new float[0].getClass().getComponentType();
+	public static final Class<Float> TYPE = new float[0].getClass().getComponentType();
 
 	// Note: This can't be set to "float.class", since *that* is
 	// defined to be "java.lang.Float.TYPE";
@@ -132,6 +132,7 @@
 	 *         object.floatValue(), zero when this.floatValue() equals
 	 *         object.floatValue(), and less than zero when this.floatValue() is
 	 *         less than object.floatValue()
+     * @throws NullPointerException if <code>object</code> is <code>null</code>.
      * @since 1.2
 	 */
 	public int compareTo(Float object) {
@@ -154,26 +155,6 @@
 			return f1 > f2 ? 1 : -1;
 		}
 		return value > object.value ? 1 : -1;
-	}
-
-	/**
-	 * Compares the receiver with a Float parameter.
-	 * 
-	 * @param object
-	 *            the Float to compare to the receiver
-	 * 
-	 * @return Returns greater than zero when this.floatValue() is greater than
-	 *         object.floatValue(), zero when this.floatValue() equals
-	 *         object.floatValue(), and less than zero when this.floatValue() is
-	 *         less than object.floatValue()
-	 * 
-	 * @throws ClassCastException
-	 *             when object is not a Float
-	 * 
-	 * @see #compareTo(Float)
-	 */
-	public int compareTo(Object object) {
-		return compareTo((Float) object);
 	}
 
 	/**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Integer.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Integer.java?rev=394878&r1=394877&r2=394878&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Integer.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Integer.java
Tue Apr 18 00:42:22 2006
@@ -30,8 +30,8 @@
  * @see java.lang.Number
  * @since 1.1
  */
-public final class Integer extends Number implements Comparable {
-    //TODO Add Comparable<Integer> to implements when generics are supported.
+public final class Integer extends Number implements Comparable<Integer> {
+
 	private static final long serialVersionUID = 1360826667806852920L;
 
 	/**
@@ -66,7 +66,7 @@
 	/**
 	 * The java.lang.Class that represents this class.
 	 */
-	public static final Class TYPE = new int[0].getClass().getComponentType();
+	public static final Class<Integer> TYPE = new int[0].getClass().getComponentType();
 
 	// Note: This can't be set to "int.class", since *that* is
 	// defined to be "java.lang.Integer.TYPE";
@@ -110,12 +110,23 @@
 		return (byte) value;
 	}
 
+    /**
+     * <p>
+     * Compares this <code>Integer</code> to the <code>Integer</code>
+     * passed. If this instance's value is equal to the value of the instance
+     * passed, then 0 is returned. If this instance's value is less than the
+     * value of the instance passed, then a negative value is returned. If this
+     * instance's value is greater than the value of the instance passed, then a
+     * positive value is returned.
+     * </p>
+     * 
+     * @param object The instance to compare to.
+     * @throws NullPointerException if <code>object</code> is
+     *         <code>null</code>.
+     * @since 1.2
+     */
 	public int compareTo(Integer object) {
 		return value > object.value ? 1 : (value < object.value ? -1 : 0);
-	}
-
-	public int compareTo(Object object) {
-		return compareTo((Integer) object);
 	}
 
 	/**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Long.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Long.java?rev=394878&r1=394877&r2=394878&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Long.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Long.java
Tue Apr 18 00:42:22 2006
@@ -30,7 +30,7 @@
  * @see java.lang.Number
  * @since 1.0
  */
-public final class Long extends Number implements Comparable {
+public final class Long extends Number implements Comparable<Long> {
 
 	private static final long serialVersionUID = 4290774380558885855L;
 
@@ -56,7 +56,7 @@
 	/**
 	 * The java.lang.Class that represents this class.
 	 */
-	public static final Class TYPE = new long[0].getClass().getComponentType();
+	public static final Class<Long> TYPE = new long[0].getClass().getComponentType();
 
 	// Note: This can't be set to "long.class", since *that* is
 	// defined to be "java.lang.Long.TYPE";
@@ -110,12 +110,23 @@
 		return (byte) value;
 	}
 
+    /**
+     * <p>
+     * Compares this <code>Long</code> to the <code>Long</code>
+     * passed. If this instance's value is equal to the value of the instance
+     * passed, then 0 is returned. If this instance's value is less than the
+     * value of the instance passed, then a negative value is returned. If this
+     * instance's value is greater than the value of the instance passed, then a
+     * positive value is returned.
+     * </p>
+     * 
+     * @param object The instance to compare to.
+     * @throws NullPointerException if <code>object</code> is
+     *         <code>null</code>.
+     * @since 1.2
+     */
 	public int compareTo(Long object) {
 		return value > object.value ? 1 : (value < object.value ? -1 : 0);
-	}
-
-	public int compareTo(Object object) {
-		return compareTo((Long) object);
 	}
 
 	/**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Short.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Short.java?rev=394878&r1=394877&r2=394878&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Short.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Short.java
Tue Apr 18 00:42:22 2006
@@ -23,8 +23,8 @@
  * @see java.lang.Number
  * @since 1.1
  */
-public final class Short extends Number implements Comparable {
-    //TODO Add Comparable<Short> to implements when generics are supported.
+public final class Short extends Number implements Comparable<Short> {
+
 	private static final long serialVersionUID = 7515723908773894738L;
 
 	/**
@@ -59,7 +59,7 @@
 	/**
 	 * The java.lang.Class that represents this class.
 	 */
-	public static final Class TYPE = new short[0].getClass().getComponentType();
+	public static final Class<Short> TYPE = new short[0].getClass().getComponentType();
 
 	// Note: This can't be set to "short.class", since *that* is
 	// defined to be "java.lang.Short.TYPE";
@@ -103,10 +103,21 @@
 		return (byte) value;
 	}
 
-	public int compareTo(Object object) {
-		return compareTo((Short) object);
-	}
-
+    /**
+     * <p>
+     * Compares this <code>Short</code> to the <code>Short</code>
+     * passed. If this instance's value is equal to the value of the instance
+     * passed, then 0 is returned. If this instance's value is less than the
+     * value of the instance passed, then a negative value is returned. If this
+     * instance's value is greater than the value of the instance passed, then a
+     * positive value is returned.
+     * </p>
+     * 
+     * @param object The instance to compare to.
+     * @throws NullPointerException if <code>object</code> is
+     *         <code>null</code>.
+     * @since 1.2
+     */
 	public int compareTo(Short object) {
 		return value > object.value ? 1 : (value < object.value ? -1 : 0);
 	}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/ByteTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/ByteTest.java?rev=394878&r1=394877&r2=394878&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/ByteTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/ByteTest.java
Tue Apr 18 00:42:22 2006
@@ -325,4 +325,32 @@
         assertEquals(0, new Byte((byte)0).shortValue());
         assertEquals(1, new Byte((byte)1).shortValue());
     }
+    
+    /**
+     * @tests java.lang.Byte#compareTo(Byte)
+     */
+    public void test_compareToLjava_lang_Byte() {
+        final Byte min = new Byte(Byte.MIN_VALUE);
+        final Byte zero = new Byte((byte)0);
+        final Byte max = new Byte(Byte.MAX_VALUE);
+        
+        assertTrue(max.compareTo(max) == 0);
+        assertTrue(min.compareTo(min) == 0);
+        assertTrue(zero.compareTo(zero) == 0);
+        
+        assertTrue(max.compareTo(zero) > 0);
+        assertTrue(max.compareTo(min) > 0);
+        
+        assertTrue(zero.compareTo(max) < 0);
+        assertTrue(zero.compareTo(min) > 0);
+        
+        assertTrue(min.compareTo(zero) < 0);
+        assertTrue(min.compareTo(max) < 0);
+        
+        try {
+            min.compareTo(null);
+            fail("No NPE");
+        } catch (NullPointerException e) {
+        }
+    }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/CharacterTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/CharacterTest.java?rev=394878&r1=394877&r2=394878&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/CharacterTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/CharacterTest.java
Tue Apr 18 00:42:22 2006
@@ -573,4 +573,32 @@
         } catch (IndexOutOfBoundsException e) {
         }
     }
+    
+    /**
+     * @tests java.lang.Character#compareTo(Character)
+     */
+    public void test_compareToLjava_lang_Byte() {
+        final Character min = new Character(Character.MIN_VALUE);
+        final Character mid = new Character((char)(Character.MAX_VALUE/2));
+        final Character max = new Character(Character.MAX_VALUE);
+        
+        assertTrue(max.compareTo(max) == 0);
+        assertTrue(min.compareTo(min) == 0);
+        assertTrue(mid.compareTo(mid) == 0);
+        
+        assertTrue(max.compareTo(mid) > 0);
+        assertTrue(max.compareTo(min) > 0);
+        
+        assertTrue(mid.compareTo(max) < 0);
+        assertTrue(mid.compareTo(min) > 0);
+        
+        assertTrue(min.compareTo(mid) < 0);
+        assertTrue(min.compareTo(max) < 0);
+        
+        try {
+            min.compareTo(null);
+            fail("No NPE");
+        } catch (NullPointerException e) {
+        }
+    }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/DoubleTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/DoubleTest.java?rev=394878&r1=394877&r2=394878&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/DoubleTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/lang/DoubleTest.java
Tue Apr 18 00:42:22 2006
@@ -54,6 +54,12 @@
 						D2.compareTo(objDouble) == 1);
 			}
 		}
+        
+        try {
+            new Double(0.0D).compareTo(null);
+            fail("No NPE");
+        } catch(NullPointerException e) {
+        }
 	}
 
 	/**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ByteTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ByteTest.java?rev=394878&r1=394877&r2=394878&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ByteTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ByteTest.java
Tue Apr 18 00:42:22 2006
@@ -63,26 +63,6 @@
 	}
 
 	/**
-	 * @tests java.lang.Byte#compareTo(java.lang.Object)
-	 */
-	public void test_compareToLjava_lang_Object() {
-		// Test for method int java.lang.Byte.compareTo(java.lang.Object)
-		assertTrue("Comparison failed", new Byte((byte) 1)
-				.compareTo((Object) new Byte((byte) 2)) < 0);
-		assertTrue("Comparison failed", new Byte((byte) 1)
-				.compareTo((Object) new Byte((byte) -2)) > 0);
-		assertTrue("Comparison failed", new Byte((byte) 1)
-				.compareTo((Object) new Byte((byte) 1)) == 0);
-		try {
-			new Byte((byte) 1).compareTo(new Object());
-		} catch (ClassCastException e) {
-			// correct
-			return;
-		}
-		fail("Failed to throw ClassCastException");
-	}
-
-	/**
 	 * @tests java.lang.Byte#decode(java.lang.String)
 	 */
 	public void test_decodeLjava_lang_String() {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/CharacterTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/CharacterTest.java?rev=394878&r1=394877&r2=394878&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/CharacterTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/CharacterTest.java
Tue Apr 18 00:42:22 2006
@@ -55,24 +55,6 @@
 	}
 
 	/**
-	 * @tests java.lang.Character#compareTo(java.lang.Object)
-	 */
-	public void test_compareToLjava_lang_Object() {
-		// Test for method int java.lang.Character.compareTo(java.lang.Object)
-		Character c = new Character('c');
-		assertTrue("Returned false for same Character",
-				c.compareTo((Object) c) == 0);
-		try {
-			c.compareTo(new Object());
-		} catch (ClassCastException e) {
-			// Correct
-			return;
-		}
-		fail(
-				"Failed to throw exception when comparing to non-Character");
-	}
-
-	/**
 	 * @tests java.lang.Character#digit(char, int)
 	 */
 	public void test_digitCI() {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/DoubleTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/DoubleTest.java?rev=394878&r1=394877&r2=394878&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/DoubleTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/DoubleTest.java
Tue Apr 18 00:42:22 2006
@@ -343,6 +343,12 @@
 						.compareTo(D1) == 1);
 			}
 		}
+        
+        try {
+            new Double(0.0D).compareTo(null);
+            fail("No NPE");
+        } catch (NullPointerException e) {
+        }
 	}
 
 	/**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/FloatTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/FloatTest.java?rev=394878&r1=394877&r2=394878&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/FloatTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/FloatTest.java
Tue Apr 18 00:42:22 2006
@@ -182,6 +182,12 @@
 						.compareTo(F1) == 1);
 			}
 		}
+        
+        try {
+            new Float(0.0F).compareTo(null);
+            fail("No NPE");
+        } catch (NullPointerException e) {
+        }
 	}
 
 	/**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/IntegerTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/IntegerTest.java?rev=394878&r1=394877&r2=394878&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/IntegerTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/IntegerTest.java
Tue Apr 18 00:42:22 2006
@@ -61,27 +61,12 @@
 				.compareTo(new Integer(-2)) == 0);
 		assertTrue("3 compared to 2 gave non-positive answer", new Integer(3)
 				.compareTo(new Integer(2)) > 0);
-	}
-
-	/**
-	 * @tests java.lang.Integer#compareTo(java.lang.Object)
-	 */
-	public void test_compareToLjava_lang_Object() {
-		// Test for method int java.lang.Integer.compareTo(java.lang.Object)
-		assertTrue("-2 compared to 1 gave non-negative answer", new Integer(-2)
-				.compareTo((Object) new Integer(1)) < 0);
-		assertTrue("-2 compared to -2 gave non-zero answer", new Integer(-2)
-				.compareTo((Object) new Integer(-2)) == 0);
-		assertTrue("3 compared to 2 gave non-positive answer", new Integer(3)
-				.compareTo((Object) new Integer(2)) > 0);
-		try {
-			new Integer(3).compareTo(new Object());
-		} catch (ClassCastException e) {
-			// correct
-			return;
-		}
-		fail(
-				"3 compared to a non-integer object failed to throw an exception");
+        
+        try {
+            new Integer(0).compareTo(null);
+            fail("No NPE");
+        } catch (NullPointerException e) {
+        }
 	}
 
 	/**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/LongTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/LongTest.java?rev=394878&r1=394877&r2=394878&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/LongTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/LongTest.java
Tue Apr 18 00:42:22 2006
@@ -62,27 +62,12 @@
 				.compareTo(new Long(-2L)) == 0);
 		assertTrue("3 compared to 2 gave non-positive answer", new Long(3L)
 				.compareTo(new Long(2L)) > 0);
-	}
-
-	/**
-	 * @tests java.lang.Long#compareTo(java.lang.Object)
-	 */
-	public void test_compareToLjava_lang_Object() {
-		// Test for method int java.lang.Long.compareTo(java.lang.Object)
-		assertTrue("-2 compared to 1 gave non-negative answer", new Long(-2L)
-				.compareTo((Object) new Long(1L)) < 0);
-		assertTrue("-2 compared to -2 gave non-zero answer", new Long(-2L)
-				.compareTo((Object) new Long(-2L)) == 0);
-		assertTrue("3 compared to 2 gave non-positive answer", new Long(3L)
-				.compareTo((Object) new Long(2L)) > 0);
-		try {
-			new Long(3).compareTo(new Object());
-		} catch (ClassCastException e) {
-			// correct
-			return;
-		}
-		fail(
-				"3 compared to a non-integer object failed to throw an exception");
+        
+        try {
+            new Long(0).compareTo(null);
+            fail("No NPE");
+        } catch (NullPointerException e) {
+        }
 	}
 
 	/**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ShortTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ShortTest.java?rev=394878&r1=394877&r2=394878&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ShortTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ShortTest.java
Tue Apr 18 00:42:22 2006
@@ -55,34 +55,6 @@
 	}
 
 	/**
-	 * @tests java.lang.Short#compareTo(java.lang.Object)
-	 */
-	public void test_compareToLjava_lang_Object() {
-		// Test for method int java.lang.Short.compareTo(java.lang.Object)
-		Short s = new Short((short) 1);
-		Object x = new Short((short) 3);
-		assertTrue(
-				"Should have returned negative value when compared to greater short",
-				s.compareTo(x) < 0);
-		x = new Short((short) -1);
-		assertTrue(
-				"Should have returned positive value when compared to lesser short",
-				s.compareTo(x) > 0);
-		x = new Short((short) 1);
-		assertTrue("Should have returned zero when compared to equal short", s
-				.compareTo(x) == 0);
-		x = "5";
-		try {
-			s.compareTo(x);
-		} catch (ClassCastException e) {
-			// correct
-			return;
-		}
-		fail(
-				"Should have thrown ClassCastException when compared to non-short");
-	}
-
-	/**
 	 * @tests java.lang.Short#compareTo(java.lang.Short)
 	 */
 	public void test_compareToLjava_lang_Short() {
@@ -99,6 +71,12 @@
 		x = new Short((short) 1);
 		assertTrue("Should have returned zero when compared to equal short", s
 				.compareTo(x) == 0);
+        
+        try {
+            new Short((short)0).compareTo(null);
+            fail("No NPE");
+        } catch (NullPointerException e) {
+        }
 	}
 
 	/**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/CollectionsTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/CollectionsTest.java?rev=394878&r1=394877&r2=394878&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/CollectionsTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/CollectionsTest.java
Tue Apr 18 00:42:22 2006
@@ -585,7 +585,7 @@
 			Collections.shuffle(list, new Random(200));
 
 		for (int counter = 0; counter < size - 1; counter++) {
-			if (((Integer) list.get(counter)).compareTo(list.get(counter + 1)) > 0) {
+			if (((Integer) list.get(counter)).compareTo((Integer)list.get(counter + 1)) > 0) {
 				sorted = false;
 			}
 		}
@@ -668,13 +668,13 @@
 		for (int counter = 0; counter < llSize - 1; counter++) {
 			assertTrue(
 					"Sorting shuffled list resulted in unsorted list",
-					((Integer) ll.get(counter)).compareTo(ll.get(counter + 1)) < 0);
+					((Integer) ll.get(counter)).compareTo((Integer)ll.get(counter + 1)) < 0);
 		}
 
 		for (int counter = 0; counter < rllSize - 1; counter++) {
 			assertTrue("Sorting reversed list resulted in unsorted list",
 					((Integer) reversedLinkedList.get(counter))
-							.compareTo(reversedLinkedList.get(counter + 1)) < 0);
+							.compareTo((Integer)reversedLinkedList.get(counter + 1)) < 0);
 		}
 	}
 



Mime
View raw message