Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 01c4dcce authored by Kenny Root's avatar Kenny Root Committed by Android (Google) Code Review
Browse files

Merge "Throw NullPointerException on args to Time#compare"

parents 6c454c32 467cabe8
Loading
Loading
Loading
Loading
+23 −4
Original line number Original line Diff line number Diff line
@@ -281,10 +281,29 @@ public class Time {
    }
    }


    /**
    /**
     * return a negative number if a is less than b, a positive number if a is
     * Compare two {@code Time} objects and return a negative number if {@code
     * greater than b, and 0 if they are equal.
     * a} is less than {@code b}, a positive number if {@code a} is greater than
     * {@code b}, or 0 if they are equal.
     *
     * @param a first {@code Time} instance to compare
     * @param b second {@code Time} instance to compare
     * @throws NullPointerException if either argument is {@code null}
     * @throws IllegalArgumentException if {@link #allDay} is true but {@code
     *             hour}, {@code minute}, and {@code second} are not 0.
     * @return a negative result if {@code a} is earlier, a positive result if
     *         {@code a} is earlier, or 0 if they are equal.
     */
     */
    native public static int compare(Time a, Time b);
    public static int compare(Time a, Time b) {
        if (a == null) {
            throw new NullPointerException("a == null");
        } else if (b == null) {
            throw new NullPointerException("b == null");
        }

        return nativeCompare(a, b);
    }

    private static native int nativeCompare(Time a, Time b);


    /**
    /**
     * Print the current value given the format string provided. See man
     * Print the current value given the format string provided. See man
+1 −1
Original line number Original line Diff line number Diff line
@@ -641,7 +641,7 @@ static JNINativeMethod gMethods[] = {
    /* name, signature, funcPtr */
    /* name, signature, funcPtr */
    { "normalize",               "(Z)J",                                        (void*)android_text_format_Time_normalize },
    { "normalize",               "(Z)J",                                        (void*)android_text_format_Time_normalize },
    { "switchTimezone",          "(Ljava/lang/String;)V",                       (void*)android_text_format_Time_switchTimezone },
    { "switchTimezone",          "(Ljava/lang/String;)V",                       (void*)android_text_format_Time_switchTimezone },
    { "compare",                 "(Landroid/text/format/Time;Landroid/text/format/Time;)I",     (void*)android_text_format_Time_compare },
    { "nativeCompare",           "(Landroid/text/format/Time;Landroid/text/format/Time;)I",     (void*)android_text_format_Time_compare },
    { "format1",                 "(Ljava/lang/String;)Ljava/lang/String;",      (void*)android_text_format_Time_format },
    { "format1",                 "(Ljava/lang/String;)Ljava/lang/String;",      (void*)android_text_format_Time_format },
    { "format2445",              "()Ljava/lang/String;",                        (void*)android_text_format_Time_format2445 },
    { "format2445",              "()Ljava/lang/String;",                        (void*)android_text_format_Time_format2445 },
    { "toString",                "()Ljava/lang/String;",                        (void*)android_text_format_Time_toString },
    { "toString",                "()Ljava/lang/String;",                        (void*)android_text_format_Time_toString },