Tue, 10 Apr 2012 08:15:25 -0700
7074397: Build infrastructure changes (makefile re-write)
Summary: New makefiles transition, old and new living side by side for now.
Reviewed-by: ohair, jjg, dholmes, ohrstrom, erikj, ihse, tgranat, ykantser
Contributed-by: ohrstrom <fredrik.ohrstrom@oracle.com>, erikj <erik.joelsson@oracle.com>, ihse <magnus.ihse.bursie@oracle.com>, tgranat <torbjorn.granat@oracle.com>, ykantser <yekaterina.kantserova@oracle.com>
duke@1 | 1 | /* |
ohair@554 | 2 | * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. |
duke@1 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | * |
duke@1 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@1 | 7 | * published by the Free Software Foundation. |
duke@1 | 8 | * |
duke@1 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 13 | * accompanied this code). |
duke@1 | 14 | * |
duke@1 | 15 | * You should have received a copy of the GNU General Public License version |
duke@1 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 18 | * |
ohair@554 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 20 | * or visit www.oracle.com if you need additional information or have any |
ohair@554 | 21 | * questions. |
duke@1 | 22 | */ |
duke@1 | 23 | |
duke@1 | 24 | /* |
duke@1 | 25 | * @test |
duke@1 | 26 | * @bug 4990346 |
duke@1 | 27 | * @summary Verify autoboxed values are cached as required. |
duke@1 | 28 | * @author Joseph D. Darcy |
duke@1 | 29 | */ |
duke@1 | 30 | |
duke@1 | 31 | public class BoxingCaching { |
duke@1 | 32 | |
duke@1 | 33 | static boolean verifyBooleanCaching() { |
duke@1 | 34 | boolean cached = true; |
duke@1 | 35 | |
duke@1 | 36 | Boolean results[] = new Boolean[2]; |
duke@1 | 37 | |
duke@1 | 38 | results[0] = false; |
duke@1 | 39 | results[1] = true; |
duke@1 | 40 | |
duke@1 | 41 | Boolean B; |
duke@1 | 42 | |
duke@1 | 43 | B = false; |
duke@1 | 44 | if (B != results[0]) { |
duke@1 | 45 | cached = false; |
duke@1 | 46 | System.err.println("Boolean value " + B + |
duke@1 | 47 | " is not cached appropriately."); |
duke@1 | 48 | } |
duke@1 | 49 | |
duke@1 | 50 | B = true; |
duke@1 | 51 | if (B != results[1]) { |
duke@1 | 52 | cached = false; |
duke@1 | 53 | System.err.println("Boolean value " + B + |
duke@1 | 54 | " is not cached appropriately."); |
duke@1 | 55 | } |
duke@1 | 56 | |
duke@1 | 57 | return cached; |
duke@1 | 58 | } |
duke@1 | 59 | |
duke@1 | 60 | static boolean verifyByteCaching() { |
duke@1 | 61 | boolean cached = true; |
duke@1 | 62 | |
duke@1 | 63 | Byte results[] = new Byte[-(-128) + 127 +1]; |
duke@1 | 64 | for(int i = 0; i < results.length; i++) |
duke@1 | 65 | results[i] = (byte)(i-128); |
duke@1 | 66 | |
duke@1 | 67 | for(int i = 0; i < results.length; i++) { |
duke@1 | 68 | Byte B = (byte)(i-128); |
duke@1 | 69 | if (B != results[i]) { |
duke@1 | 70 | cached = false; |
duke@1 | 71 | System.err.println("Byte value " + B + |
duke@1 | 72 | " is not cached appropriately."); |
duke@1 | 73 | } |
duke@1 | 74 | } |
duke@1 | 75 | |
duke@1 | 76 | for(int i = Byte.MIN_VALUE; i < Byte.MAX_VALUE; i++) { |
duke@1 | 77 | Byte B; |
duke@1 | 78 | B = (byte)i; |
duke@1 | 79 | if (B.byteValue() != i) { |
duke@1 | 80 | cached = false; |
duke@1 | 81 | System.err.println("Erroneous autoboxing conversion for " + |
duke@1 | 82 | "byte value " + i + " ."); |
duke@1 | 83 | } |
duke@1 | 84 | } |
duke@1 | 85 | |
duke@1 | 86 | return cached; |
duke@1 | 87 | } |
duke@1 | 88 | |
duke@1 | 89 | static boolean verifyCharacterCaching() { |
duke@1 | 90 | boolean cached = true; |
duke@1 | 91 | |
duke@1 | 92 | Character results[] = new Character[127 +1]; |
duke@1 | 93 | for(int i = 0; i < results.length; i++) |
duke@1 | 94 | results[i] = (char)i; |
duke@1 | 95 | |
duke@1 | 96 | for(int i = 0; i < results.length; i++) { |
duke@1 | 97 | Character C = (char)i; |
duke@1 | 98 | if (C != results[i]) { |
duke@1 | 99 | cached = false; |
duke@1 | 100 | System.err.println("Char value " + C + |
duke@1 | 101 | " is not cached appropriately."); |
duke@1 | 102 | } |
duke@1 | 103 | } |
duke@1 | 104 | |
duke@1 | 105 | for(int i = Character.MIN_VALUE; i < Character.MAX_VALUE; i++) { |
duke@1 | 106 | Character C; |
duke@1 | 107 | C = (char)i; |
duke@1 | 108 | if (C.charValue() != i) { |
duke@1 | 109 | cached = false; |
duke@1 | 110 | System.err.println("Erroneous autoboxing conversion for " + |
duke@1 | 111 | "char value " + i + " ."); |
duke@1 | 112 | } |
duke@1 | 113 | } |
duke@1 | 114 | |
duke@1 | 115 | return cached; |
duke@1 | 116 | } |
duke@1 | 117 | |
duke@1 | 118 | static boolean verifyIntegerCaching() { |
duke@1 | 119 | boolean cached = true; |
duke@1 | 120 | |
duke@1 | 121 | Integer results[] = new Integer[-(-128) + 127 +1]; |
duke@1 | 122 | for(int i = 0; i < results.length; i++) |
duke@1 | 123 | results[i] = (i-128); |
duke@1 | 124 | |
duke@1 | 125 | for(int i = 0; i < results.length; i++) { |
duke@1 | 126 | Integer I = (i-128); |
duke@1 | 127 | if (I != results[i]) { |
duke@1 | 128 | cached = false; |
duke@1 | 129 | System.err.println("Integer value " + I + |
duke@1 | 130 | " is not cached appropriately."); |
duke@1 | 131 | } |
duke@1 | 132 | } |
duke@1 | 133 | |
duke@1 | 134 | for(int i = -256; i < 255; i++) { |
duke@1 | 135 | Integer I; |
duke@1 | 136 | I = i; |
duke@1 | 137 | if (I.intValue() != i) { |
duke@1 | 138 | cached = false; |
duke@1 | 139 | System.err.println("Erroneous autoboxing conversion for " + |
duke@1 | 140 | "int value " + i + " ."); |
duke@1 | 141 | } |
duke@1 | 142 | } |
duke@1 | 143 | |
duke@1 | 144 | return cached; |
duke@1 | 145 | } |
duke@1 | 146 | |
duke@1 | 147 | static boolean verifyLongCaching() { |
duke@1 | 148 | boolean cached = true; |
duke@1 | 149 | |
duke@1 | 150 | Long results[] = new Long[-(-128) + 127 +1]; |
duke@1 | 151 | for(int i = 0; i < results.length; i++) |
duke@1 | 152 | results[i] = (long)(i-128); |
duke@1 | 153 | |
duke@1 | 154 | for(int i = 0; i < results.length; i++) { |
duke@1 | 155 | Long L = (long)(i-128); |
duke@1 | 156 | if (L != results[i]) { |
duke@1 | 157 | cached = false; |
duke@1 | 158 | System.err.println("Integer value " + L + |
duke@1 | 159 | " is not cached appropriately."); |
duke@1 | 160 | } |
duke@1 | 161 | } |
duke@1 | 162 | |
duke@1 | 163 | for(int i = -256; i < 255; i++) { |
duke@1 | 164 | Integer L; |
duke@1 | 165 | L = i; |
duke@1 | 166 | if (L.longValue() != i) { |
duke@1 | 167 | cached = false; |
duke@1 | 168 | System.err.println("Erroneous autoboxing conversion for " + |
duke@1 | 169 | "int value " + i + " ."); |
duke@1 | 170 | } |
duke@1 | 171 | } |
duke@1 | 172 | |
duke@1 | 173 | return cached; |
duke@1 | 174 | } |
duke@1 | 175 | |
duke@1 | 176 | static boolean verifyShortCaching() { |
duke@1 | 177 | boolean cached = true; |
duke@1 | 178 | |
duke@1 | 179 | Short results[] = new Short[-(-128) + 127 +1]; |
duke@1 | 180 | for(int i = 0; i < results.length; i++) |
duke@1 | 181 | results[i] = (short)(i-128); |
duke@1 | 182 | |
duke@1 | 183 | for(int i = 0; i < results.length; i++) { |
duke@1 | 184 | Short S = (short)(i-128); |
duke@1 | 185 | if (S != results[i]) { |
duke@1 | 186 | cached = false; |
duke@1 | 187 | System.err.println("Short value " + S + |
duke@1 | 188 | " is not cached appropriately."); |
duke@1 | 189 | } |
duke@1 | 190 | } |
duke@1 | 191 | |
duke@1 | 192 | for(int i = Short.MIN_VALUE; i < Short.MAX_VALUE; i++) { |
duke@1 | 193 | Short S; |
duke@1 | 194 | S = (short)i; |
duke@1 | 195 | if (S.shortValue() != i) { |
duke@1 | 196 | cached = false; |
duke@1 | 197 | System.err.println("Erroneous autoboxing conversion for " + |
duke@1 | 198 | "short value " + i + " ."); |
duke@1 | 199 | } |
duke@1 | 200 | } |
duke@1 | 201 | |
duke@1 | 202 | return cached; |
duke@1 | 203 | } |
duke@1 | 204 | |
duke@1 | 205 | public static void main(String argv[]) { |
duke@1 | 206 | boolean cached = true; |
duke@1 | 207 | |
duke@1 | 208 | cached &= verifyBooleanCaching(); |
duke@1 | 209 | cached &= verifyByteCaching(); |
duke@1 | 210 | cached &= verifyCharacterCaching(); |
duke@1 | 211 | cached &= verifyIntegerCaching(); |
duke@1 | 212 | cached &= verifyLongCaching(); |
duke@1 | 213 | cached &= verifyShortCaching(); |
duke@1 | 214 | |
duke@1 | 215 | if (!cached) |
duke@1 | 216 | throw new RuntimeException("Values not cached appropriately."); |
duke@1 | 217 | } |
duke@1 | 218 | } |