Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1 | // Copyright (c) 2016, 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 conversions; |
| 5 | |
| 6 | public class Conversions { |
| 7 | |
| 8 | public static byte b(byte b) { |
| 9 | return b; |
| 10 | } |
| 11 | |
| 12 | public static char c(char c) { |
| 13 | return c; |
| 14 | } |
| 15 | |
| 16 | public static short s(short s) { |
| 17 | return s; |
| 18 | } |
| 19 | |
| 20 | public static int i() { |
| 21 | return 1; |
| 22 | } |
| 23 | |
| 24 | public static int i(int i) { |
| 25 | return i; |
| 26 | } |
| 27 | |
| 28 | public static long l() { |
| 29 | return 1; |
| 30 | } |
| 31 | |
| 32 | public static long l(long l) { |
| 33 | return l; |
| 34 | } |
| 35 | |
| 36 | public static double d() { |
| 37 | return 1; |
| 38 | } |
| 39 | |
| 40 | public static double d(double d) { |
| 41 | return d; |
| 42 | } |
| 43 | |
| 44 | public static float f() { |
| 45 | return 1; |
| 46 | } |
| 47 | |
| 48 | public static float f(float f) { |
| 49 | return f; |
| 50 | } |
| 51 | |
| 52 | public static void main(String[] args) { |
| 53 | // I2L, I2F, I2D |
| 54 | System.out.println(l(i())); |
| 55 | System.out.println(f(i())); |
| 56 | System.out.println(d(i())); |
| 57 | // L2I, L2F, L2D |
| 58 | System.out.println(i((int) l())); |
| 59 | System.out.println(f(l())); |
| 60 | System.out.println(d(l())); |
| 61 | // F2I, F2L, F2D |
| 62 | System.out.println(i((int) f())); |
| 63 | System.out.println(l((long) f())); |
| 64 | System.out.println(d(f())); |
| 65 | // D2I, D2L, D2F |
| 66 | System.out.println(i((int) d())); |
| 67 | System.out.println(l((long) d())); |
| 68 | System.out.println(f((float) d())); |
| 69 | // I2B, I2C, I2S |
| 70 | System.out.println(b((byte) i())); |
| 71 | System.out.println(c((char) i())); |
| 72 | System.out.println(s((short) i())); |
| 73 | } |
| 74 | } |