1 // Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file 2 // for details. All rights reserved. Use of this source code is governed by a 3 // BSD-style license that can be found in the LICENSE file. 4 package rewrite; 5 6 public class LongCompare { 7 simpleCompare(long l1, long l2)8 public static int simpleCompare(long l1, long l2) { 9 try { 10 return Long.compare(l1, l2); 11 } catch (Throwable t) { 12 System.out.println(t); 13 } 14 return 2; 15 } 16 getValue1()17 public static long getValue1() { 18 return 123456789L; 19 } 20 getValue2()21 public static long getValue2() { 22 return 0; 23 } 24 complexCompare(long l1, long l2)25 public static boolean complexCompare(long l1, long l2) { 26 return Long.compare(getValue1(), l1) == 0 && Long.compare(l2, getValue2()) > 0; 27 } 28 main(String[] args)29 public static void main(String[] args) { 30 System.out.println(simpleCompare(123456789L, 987654321L)); 31 System.out.println(simpleCompare(Long.MAX_VALUE, 0L)); 32 System.out.println(simpleCompare(Long.MIN_VALUE, 0L)); 33 System.out.println(simpleCompare(Long.MAX_VALUE, Long.MAX_VALUE)); 34 35 System.out.println(complexCompare(123456789L, 1)); 36 System.out.println(complexCompare(123456789L, -1)); 37 System.out.println(complexCompare(1234567890L, 1)); 38 System.out.println(complexCompare(1234567890L, -1)); 39 } 40 } 41