Martin Buchholz wrote:
Google would like to contribute implementations of the methods below.
Here's a webrev:

http://cr.openjdk.java.net/~martin/webrevs/openjdk7/compare/

Wherever these compare methods go, into the N wrapper classes or into java.util.Compare, I think the instance method compareTo should be rewritten in terms of the new static compare. In particular,

422     public int compareTo(Short anotherShort) {
423         return this.value - anotherShort.value;
424     }

should get replaced with

422     public int compareTo(Short anotherShort) {
423         return compare(this.value, anotherShort.value);
424     }

This consolidates the comparison logic in a single method per type and reuses the existing implementation tests.

(Later in JDK 7, a set of "unsignedCompare" methods are possible additions to the platform too.)

We have tests (not yet included) but they would need to be jtreg-ified.
Is there any junit support yet for jtreg?

No.

Once the home of the new methods is determined, I'll file a ccc request so these changes can go back after any additional testing is settled.

Thanks,

-Joe

Martin

On Wed, Sep 9, 2009 at 16:54, Stephen Colebourne<scolebou...@joda.org> wrote:
2009/9/9 Joe Darcy <joe.da...@sun.com>:
The following are missing methods on Integer/Long:

7) Compare two primitives.
int Byte.compare(byte value1, byte value2)
int Short.compare(short value1, short value2)
int Integer.compare(int value1, int value2)
int Long.compare(long value1, long value2)
Safely returns the comparison (-1/0/1) indicator for two primitives.
(These methods already exist on Float/Double).

Reply via email to