1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 /** Sample values for use in VarHandle tests. These are here to avoid repeatedly boxing which 18 * makes gcstress tests run slowly. */ 19 public class SampleValues { 20 public static final boolean[] PRIMITIVE_BOOLEANS = new boolean[] {true, false}; 21 22 public static final Boolean[] BOOLEANS = new Boolean[] {true, false}; 23 24 public static final byte[] PRIMITIVE_BYTES = 25 new byte[] {(byte) -128, (byte) -61, (byte) 7, (byte) 127, (byte) 33}; 26 27 public static final Byte[] BYTES = 28 new Byte[] {(byte) -128, (byte) -61, (byte) 7, (byte) 127, (byte) 33}; 29 30 public static final short[] PRIMITIVE_SHORTS = 31 new short[] {(short) -32768, (short) -384, (short) 32767, (short) 0xaa55}; 32 33 public static final Short[] SHORTS = 34 new Short[] {(short) -32768, (short) -384, (short) 32767, (short) 0xaa55}; 35 36 public static final char[] PRIMITIVE_CHARS = 37 new char[] {'A', '#', '$', 'Z', 't', 'c'}; 38 39 public static final Character[] CHARACTERS = 40 new Character[] {'A', '#', '$', 'Z', 't', 'c'}; 41 42 public static final int[] PRIMITIVE_INTS = 43 new int[] {-0x01234567, 0x7f6e5d4c, 0x12345678, 0x10215220, 42}; 44 45 public static final Integer[] INTEGERS = 46 new Integer[] {-0x01234567, 0x7f6e5d4c, 0x12345678, 0x10215220, 42}; 47 48 public static final long[] PRIMITIVE_LONGS = 49 new long[] {-0x0123456789abcdefl, 0x789abcdef0123456l, 0xfedcba9876543210l}; 50 51 public static final Long[] LONGS = 52 new Long[] {-0x0123456789abcdefl, 0x789abcdef0123456l, 0xfedcba9876543210l}; 53 54 public static final float[] PRIMITIVE_FLOATS = 55 new float[] {-7.77e23f, 1.234e-17f, 3.40e36f, -8.888e3f, 4.442e11f}; 56 57 public static final Float[] FLOATS = 58 new Float[] {-7.77e23f, 1.234e-17f, 3.40e36f, -8.888e3f, 4.442e11f}; 59 60 public static final double[] PRIMITIVE_DOUBLES = 61 new double[] {-1.0e-200, 1.11e200, 3.141, 1.1111, 6.022e23, 6.626e-34}; 62 63 public static final Double[] DOUBLES = 64 new Double[] {-1.0e-200, 1.11e200, 3.141, 1.1111, 6.022e23, 6.626e-34}; 65 get_boolean(int index)66 public static boolean get_boolean(int index) { 67 return PRIMITIVE_BOOLEANS[index]; 68 } 69 get_Boolean(int index)70 public static Boolean get_Boolean(int index) { 71 return BOOLEANS[index]; 72 } 73 get_byte(int index)74 public static byte get_byte(int index) { 75 return PRIMITIVE_BYTES[index]; 76 } 77 get_Byte(int index)78 public static Byte get_Byte(int index) { 79 return BYTES[index]; 80 } 81 get_short(int index)82 public static short get_short(int index) { 83 return PRIMITIVE_SHORTS[index]; 84 } 85 get_Short(int index)86 public static Short get_Short(int index) { 87 return SHORTS[index]; 88 } 89 get_char(int index)90 public static char get_char(int index) { 91 return PRIMITIVE_CHARS[index]; 92 } 93 get_Character(int index)94 public static Character get_Character(int index) { 95 return CHARACTERS[index]; 96 } 97 get_int(int index)98 public static int get_int(int index) { 99 return PRIMITIVE_INTS[index]; 100 } 101 get_Integer(int index)102 public static Integer get_Integer(int index) { 103 return INTEGERS[index]; 104 } 105 get_long(int index)106 public static long get_long(int index) { 107 return PRIMITIVE_LONGS[index]; 108 } 109 get_Long(int index)110 public static Long get_Long(int index) { 111 return LONGS[index]; 112 } 113 get_float(int index)114 public static float get_float(int index) { 115 return PRIMITIVE_FLOATS[index]; 116 } 117 get_Float(int index)118 public static Float get_Float(int index) { 119 return FLOATS[index]; 120 } 121 get_double(int index)122 public static double get_double(int index) { 123 return PRIMITIVE_DOUBLES[index]; 124 } 125 get_Double(int index)126 public static Double get_Double(int index) { 127 return DOUBLES[index]; 128 } 129 } 130 131