1 /* 2 * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 package runtime.valhalla.valuetypes; 25 26 import java.lang.reflect.Array; 27 import java.util.Arrays; 28 import java.util.ArrayList; 29 import java.util.List; 30 31 import static jdk.test.lib.Asserts.*; 32 33 /* 34 * @test ValueTypeArray 35 * @summary Plain array test for Inline Types 36 * @library /test/lib 37 * @compile -XDallowGenericsOverValues ValueTypeArray.java Point.java Long8Value.java Person.java 38 * @run main/othervm -Xint -XX:ValueArrayElemMaxFlatSize=-1 runtime.valhalla.valuetypes.ValueTypeArray 39 * @run main/othervm -Xint -XX:ValueArrayElemMaxFlatSize=0 runtime.valhalla.valuetypes.ValueTypeArray 40 * @run main/othervm -Xcomp -XX:ValueArrayElemMaxFlatSize=-1 runtime.valhalla.valuetypes.ValueTypeArray 41 * @run main/othervm -Xcomp -XX:ValueArrayElemMaxFlatSize=0 runtime.valhalla.valuetypes.ValueTypeArray 42 * @run main/othervm -Xbatch -XX:ForceNonTearable=* runtime.valhalla.valuetypes.ValueTypeArray 43 */ 44 public class ValueTypeArray { 45 public static void main(String[] args) { 46 ValueTypeArray valueTypeArray = new ValueTypeArray(); 47 valueTypeArray.run(); 48 } 49 50 public void run() { 51 testClassForName(); 52 testSimplePointArray(); 53 testLong8Array(); 54 testMixedPersonArray(); 55 testMultiDimPointArray(); 56 testComposition(); 57 58 testSanityCheckcasts(); 59 testObjectArrayOfValues(); 60 61 testReflectArray(); 62 testUtilArrays(); 63 64 testValueArrayOom(); 65 } 66 67 void testClassForName() { 68 String arrayClsName = "[Lruntime.valhalla.valuetypes.Point;"; 69 String qarrayClsName = "[Qruntime.valhalla.valuetypes.Point;"; 70 try { 71 // L-type.. 72 Class<?> arrayCls = Class.forName(arrayClsName); 73 assertTrue(arrayCls.isArray(), "Expected an array class"); 74 75 assertTrue(arrayCls.getComponentType() == Point.class.asIndirectType(), 76 "Expected component type of Point.class got: " + arrayCls.getComponentType()); 77 78 arrayClsName = "[" + arrayClsName; 79 Class<?> mulArrayCls = Class.forName(arrayClsName); 80 assertTrue(mulArrayCls.isArray()); 81 assertTrue(mulArrayCls.getComponentType() == arrayCls); 82 83 // Q-type... 84 arrayCls = Class.forName(qarrayClsName); 85 assertTrue(arrayCls.isArray(), "Expected an array class"); 86 87 assertTrue(arrayCls.getComponentType() == Point.class, 88 arrayCls + 89 " Expected component type of Point.class got: " + arrayCls.getComponentType()); 90 91 qarrayClsName = "[" + qarrayClsName; 92 mulArrayCls = Class.forName(qarrayClsName); 93 assertTrue(mulArrayCls.isArray()); 94 assertTrue(mulArrayCls.getComponentType() == arrayCls); 95 } 96 catch (ClassNotFoundException cnfe) { 97 fail("Class.forName(" + arrayClsName + ") failed", cnfe); 98 } 99 } 100 101 void testSimplePointArray() { 102 Point[] defaultPoint = new Point[1]; 103 Point p = defaultPoint[0]; 104 assertEquals(p.x, 0, "invalid default loaded from array"); 105 assertEquals(p.y, 0, "invalid default loaded from array"); 106 boolean gotNpe = false; 107 try { 108 defaultPoint[0] = (Point) getNull(); 109 } catch (NullPointerException npe) { 110 gotNpe = true; 111 } 112 assertTrue(gotNpe, "Expected NullPointerException"); 113 114 Point[] points = createSimplePointArray(); 115 System.gc(); // check that VTs survive GC 116 checkSimplePointArray(points); 117 118 assertTrue(points instanceof Point[], "Instance of"); 119 120 testSimplePointArrayCopy(); 121 } 122 123 void testSimplePointArrayCopy() { 124 Point[] points = createSimplePointArray(); 125 Point[] pointsCopy = new Point[points.length]; 126 System.arraycopy(points, 0, pointsCopy, 0, points.length); 127 checkSimplePointArray(pointsCopy); 128 129 // Conjoint, overlap...left 130 System.arraycopy(points, 0, points, 1, 2); 131 checkArrayElementsEqual(points, new Point[] { pointsCopy[0], pointsCopy[0], pointsCopy[1], pointsCopy[3] }); 132 133 // Conjoint, overlap...right 134 points = createSimplePointArray(); 135 System.arraycopy(points, 2, points, 1, 2); 136 checkArrayElementsEqual(points, new Point[] { pointsCopy[0], pointsCopy[2], pointsCopy[3], pointsCopy[3] }); 137 } 138 139 static Point[] createSimplePointArray() { 140 Point[] ps = new Point[4]; 141 assertEquals(ps.length, 4, "Length"); 142 ps.toString(); 143 ps[0] = Point.createPoint(1, 2); 144 ps[1] = Point.createPoint(3, 4); 145 ps[2] = Point.createPoint(5, 6); 146 ps[3] = Point.createPoint(7, 8); 147 boolean sawOob = false; 148 try { 149 ps[ps.length] = Point.createPoint(0, 0); 150 } catch (ArrayIndexOutOfBoundsException aioobe) { sawOob = true; } 151 assertTrue(sawOob, "Didn't see AIOOBE"); 152 return ps; 153 } 154 155 static void checkSimplePointArray(Point[] points) { 156 assertEquals(points[0].x, 1, "invalid 0 point x value"); 157 assertEquals(points[0].y, 2, "invalid 0 point y value"); 158 assertEquals(points[1].x, 3, "invalid 1 point x value"); 159 assertEquals(points[1].y, 4, "invalid 1 point y value"); 160 assertEquals(points[2].x, 5, "invalid 2 point x value"); 161 assertEquals(points[2].y, 6, "invalid 2 point y value"); 162 assertEquals(points[3].x, 7, "invalid 3 point x value"); 163 assertEquals(points[3].y, 8, "invalid 3 point y value"); 164 } 165 166 void testLong8Array() { 167 Long8Value[] values = new Long8Value[3]; 168 assertEquals(values.length, 3, "length"); 169 values.toString(); 170 Long8Value value = values[1]; 171 long zl = 0; 172 Long8Value.check(value, zl, zl, zl, zl, zl, zl, zl, zl); 173 values[1] = Long8Value.create(1, 2, 3, 4, 5, 6, 7, 8); 174 value = values[1]; 175 Long8Value.check(value, 1, 2, 3, 4, 5, 6, 7, 8); 176 177 Long8Value[] copy = new Long8Value[values.length]; 178 System.arraycopy(values, 0, copy, 0, values.length); 179 value = copy[1]; 180 Long8Value.check(value, 1, 2, 3, 4, 5, 6, 7, 8); 181 } 182 183 void testMixedPersonArray() { 184 Person[] people = new Person[3]; 185 186 people[0] = Person.create(1, "First", "Last"); 187 assertEquals(people[0].getId(), 1, "Invalid Id person"); 188 assertEquals(people[0].getFirstName(), "First", "Invalid First Name"); 189 assertEquals(people[0].getLastName(), "Last", "Invalid Last Name"); 190 191 people[1] = Person.create(2, "Jane", "Wayne"); 192 people[2] = Person.create(3, "Bob", "Dobalina"); 193 194 Person[] peopleCopy = new Person[people.length]; 195 System.arraycopy(people, 0, peopleCopy, 0, people.length); 196 assertEquals(peopleCopy[2].getId(), 3, "Invalid Id"); 197 assertEquals(peopleCopy[2].getFirstName(), "Bob", "Invalid First Name"); 198 assertEquals(peopleCopy[2].getLastName(), "Dobalina", "Invalid Last Name"); 199 } 200 201 void testMultiDimPointArray() { 202 Point[][][] multiPoints = new Point[2][3][4]; 203 assertEquals(multiPoints.length, 2, "1st dim length"); 204 assertEquals(multiPoints[0].length, 3, "2st dim length"); 205 assertEquals(multiPoints[0][0].length, 4, "3rd dim length"); 206 207 Point defaultPoint = multiPoints[1][2][3]; 208 assertEquals(defaultPoint.x, 0, "invalid point x value"); 209 assertEquals(defaultPoint.y, 0, "invalid point x value"); 210 } 211 212 void testReflectArray() { 213 // Check the java.lang.reflect.Array.newInstance methods... 214 Class<?> cls = (Class<?>) Point[].class; 215 Point[][] array = (Point[][]) Array.newInstance(cls, 1); 216 assertEquals(array.length, 1, "Incorrect length"); 217 assertTrue(array[0] == null, "Expected NULL"); 218 219 Point[][][] array3 = (Point[][][]) Array.newInstance(cls, 1, 2); 220 assertEquals(array3.length, 1, "Incorrect length"); 221 assertEquals(array3[0].length, 2, "Incorrect length"); 222 assertTrue(array3[0][0] == null, "Expected NULL"); 223 224 // Now create ObjArrays of ValueArray... 225 cls = (Class<?>) Point.class.asIndirectType(); 226 Point?[][] barray = (Point?[][]) Array.newInstance(cls, 1, 2); 227 assertEquals(barray.length, 1, "Incorrect length"); 228 assertEquals(barray[0].length, 2, "Incorrect length"); 229 barray[0][1] = Point.createPoint(1, 2); 230 Point? pb = barray[0][1]; 231 int x = pb.getX(); 232 assertEquals(x, 1, "Bad Point Value"); 233 } 234 235 static final inline class MyInt implements Comparable<MyInt?> { 236 final int value; 237 238 private MyInt() { this(0); } 239 private MyInt(int v) { value = v; } 240 public int getValue() { return value; } 241 public String toString() { return "MyInt: " + getValue(); } 242 public int compareTo(MyInt? that) { return Integer.compare(this.getValue(), that.getValue()); } 243 public boolean equals(Object o) { 244 if (o instanceof MyInt) { 245 return this.getValue() == ((MyInt) o).getValue(); 246 } 247 return false; 248 } 249 250 public static MyInt create(int v) { 251 return new MyInt(v); 252 } 253 254 // Null-able fields here are a temp hack to avoid ClassCircularityError 255 public static final MyInt? MIN = MyInt.create(Integer.MIN_VALUE); 256 public static final MyInt? ZERO = MyInt.create(0); 257 public static final MyInt? MAX = MyInt.create(Integer.MAX_VALUE); 258 } 259 260 static MyInt staticMyInt = MyInt.create(-1); 261 static MyInt[] staticMyIntArray = new MyInt[] { staticMyInt }; 262 static MyInt[][] staticMyIntArrayArray = new MyInt[][] { staticMyIntArray, staticMyIntArray }; 263 264 static interface SomeSecondaryType { 265 default String hi() { return "Hi"; } 266 } 267 268 static final inline class MyOtherInt implements SomeSecondaryType { 269 final int value; 270 private MyOtherInt() { value = 0; } 271 } 272 273 void testSanityCheckcasts() { 274 MyInt[] myInts = new MyInt[1]; 275 assertTrue(myInts instanceof Object[]); 276 assertTrue(myInts instanceof Comparable[]); 277 assertTrue(myInts instanceof MyInt?[]); 278 279 Class<?> cls = MyInt.class; 280 assertTrue(cls.isInlineClass()); 281 Object arrObj = Array.newInstance(cls, 1); 282 assertTrue(arrObj instanceof Object[], "Not Object array"); 283 assertTrue(arrObj instanceof Comparable[], "Not Comparable array"); 284 assertTrue(arrObj instanceof MyInt[], "Not MyInt array"); 285 286 Object[] arr = (Object[]) arrObj; 287 assertTrue(arr instanceof Comparable[], "Not Comparable array"); 288 assertTrue(arr instanceof MyInt[], "Not MyInt array"); 289 Comparable[] comparables = (Comparable[])arr; 290 MyInt[] myIntArr = (MyInt[]) arr; 291 292 // multi-dim, check secondary array types are setup... 293 MyOtherInt[][] matrix = new MyOtherInt[1][1]; 294 assertTrue(matrix[0] instanceof MyOtherInt[]); 295 assertTrue(matrix[0] instanceof SomeSecondaryType[]); 296 assertTrue(matrix[0] instanceof MyOtherInt?[]); 297 298 // Box types vs Inline... 299 MyInt?[] myValueRefs = new MyInt?[1]; 300 assertTrue(myValueRefs instanceof MyInt?[]); 301 assertTrue(myValueRefs instanceof Object[]); 302 assertTrue(myValueRefs instanceof Comparable[]); 303 assertFalse(myValueRefs instanceof MyInt[]); 304 305 MyInt?[][] myMdValueRefs = new MyInt?[1][1]; 306 assertTrue(myMdValueRefs[0] instanceof MyInt?[]); 307 assertTrue(myMdValueRefs[0] instanceof Object[]); 308 assertTrue(myMdValueRefs[0] instanceof Comparable[]); 309 assertFalse(myMdValueRefs[0] instanceof MyInt[]); 310 311 // Did we break checkcast... 312 MyInt?[] va1 = (MyInt?[])null; 313 MyInt?[] va2 = null; 314 MyInt?[][] va3 = (MyInt?[][])null; 315 MyInt?[][][] va4 = (MyInt?[][][])null; 316 MyInt[] va5 = null; 317 MyInt[] va6 = (MyInt[])null; 318 MyInt[][] va7 = (MyInt[][])null; 319 MyInt[][][] va8 = (MyInt[][][])null; 320 } 321 322 323 void testUtilArrays() { 324 // Sanity check j.u.Arrays 325 326 // cast to q-type temp effect of avoiding circularity error (decl static MyInt?) 327 MyInt[] myInts = new MyInt[] { (MyInt) MyInt.MAX, (MyInt) MyInt.MIN }; 328 // Sanity sort another copy 329 MyInt[] copyMyInts = Arrays.copyOf(myInts, myInts.length + 1); 330 checkArrayElementsEqual(copyMyInts, new MyInt[] { myInts[0], myInts[1], (MyInt) MyInt.ZERO}); 331 332 Arrays.sort(copyMyInts); 333 checkArrayElementsEqual(copyMyInts, new MyInt[] { (MyInt) MyInt.MIN, (MyInt) MyInt.ZERO, (MyInt) MyInt.MAX }); 334 335 List myIntList = Arrays.asList(copyMyInts); 336 checkArrayElementsEqual(copyMyInts, myIntList.toArray(new MyInt[copyMyInts.length])); 337 // This next line needs testMixedLayoutArrays to work 338 checkArrayElementsEqual(copyMyInts, myIntList.toArray()); 339 340 // Sanity check j.u.ArrayList 341 ArrayList<MyInt> aList = new ArrayList<MyInt>(Arrays.asList(copyMyInts)); 342 assertTrue(aList.indexOf(MyInt.MIN) == 0, "Bad Index"); 343 assertTrue(aList.indexOf(MyInt.ZERO) == 1, "Bad Index"); 344 assertTrue(aList.indexOf(MyInt.MAX) == 2, "Bad Index"); 345 346 aList.remove(2); 347 aList.add(MyInt.create(5)); 348 } 349 350 351 void testObjectArrayOfValues() { 352 testSanityObjectArrays(); 353 testMixedLayoutArrays(); 354 } 355 356 void testSanityObjectArrays() { 357 Object[] objects = new Object[2]; 358 assertTrue(objects[0] == null && objects[1] == null, "Not null ?"); 359 360 objects[0] = MyInt.create(1); 361 objects[1] = Integer.valueOf(2); 362 assertTrue(objects[0].equals(MyInt.create(1)), "Bad Value"); 363 assertTrue(objects[1].equals(Integer.valueOf(2)), "Bad Object"); 364 365 Comparable[] copyComparables = new Comparable[objects.length]; 366 System.arraycopy(objects, 0, copyComparables, 0, objects.length); 367 checkArrayElementsEqual(objects, copyComparables); 368 369 objects[0] = null; 370 objects[1] = null; 371 assertTrue(objects[0] == null && objects[1] == null, "Not null ?"); 372 373 Comparable[] comparables = new Comparable[2]; 374 assertTrue(comparables[0] == null && comparables[1] == null, "Not null ?"); 375 comparables[0] = MyInt.create(3); 376 comparables[1] = Integer.valueOf(4); 377 assertTrue(comparables[0].equals(MyInt.create(3)), "Bad Value"); 378 assertTrue(comparables[1].equals(Integer.valueOf(4)), "Bad Object"); 379 380 Object[] copyObjects = new Object[2]; 381 System.arraycopy(comparables, 0, copyObjects, 0, comparables.length); 382 checkArrayElementsEqual(comparables, copyObjects); 383 384 comparables[0] = null; 385 comparables[1] = null; 386 assertTrue(comparables[0] == null && comparables[1] == null, "Not null ?"); 387 388 MyInt?[] myIntRefArray = new MyInt?[1]; 389 assertTrue(myIntRefArray[0] == null, "Got: " + myIntRefArray[0]); 390 myIntRefArray[0] = null; 391 392 MyInt?[] srcNulls = new MyInt?[2]; 393 MyInt?[] dstNulls = new MyInt?[2]; 394 System.arraycopy(srcNulls, 0, dstNulls, 0, 2); 395 checkArrayElementsEqual(srcNulls, dstNulls); 396 srcNulls[1] = MyInt.create(1); 397 System.arraycopy(srcNulls, 0, dstNulls, 0, 2); 398 checkArrayElementsEqual(srcNulls, dstNulls); 399 } 400 401 void testMixedLayoutArrays() { 402 Object[] objArray = new Object[3]; 403 Comparable[] compArray = new Comparable[3]; 404 MyInt[] valArray = new MyInt[] { (MyInt) MyInt.MIN, (MyInt) MyInt.ZERO, (MyInt) MyInt.MAX }; 405 406 arrayCopy(valArray, 0, objArray, 0, 3); 407 checkArrayElementsEqual(valArray, objArray); 408 arrayCopy(valArray, 0, objArray, 0, 3); 409 410 objArray = new Object[3]; 411 System.arraycopy(valArray, 0, objArray, 0, 3); 412 checkArrayElementsEqual(valArray, objArray); 413 414 System.arraycopy(valArray, 0, compArray, 0, 3); 415 checkArrayElementsEqual(valArray, compArray); 416 417 valArray = new MyInt[] { (MyInt) MyInt.ZERO, (MyInt) MyInt.ZERO, (MyInt) MyInt.ZERO }; 418 System.arraycopy(compArray, 0, valArray, 0, 3); 419 checkArrayElementsEqual(valArray, compArray); 420 421 valArray = new MyInt[] { (MyInt) MyInt.ZERO, (MyInt) MyInt.ZERO, (MyInt) MyInt.ZERO }; 422 System.arraycopy(objArray, 0, valArray, 0, 3); 423 checkArrayElementsEqual(valArray, objArray); 424 425 // Sanity check dst == src 426 System.arraycopy(valArray, 0, valArray, 0, 3); 427 checkArrayElementsEqual(valArray, objArray); 428 429 objArray[0] = "Not an inline object"; 430 try { 431 System.arraycopy(objArray, 0, valArray, 0, 3); 432 throw new RuntimeException("Expected ArrayStoreException"); 433 } catch (ArrayStoreException ase) {} 434 435 MyInt?[] myIntRefArray = new MyInt?[3]; 436 System.arraycopy(valArray, 0, myIntRefArray, 0, 3); 437 checkArrayElementsEqual(valArray, myIntRefArray); 438 439 myIntRefArray[0] = null; 440 try { 441 System.arraycopy(myIntRefArray, 0, valArray, 0, 3); 442 throw new RuntimeException("Expected NullPointerException"); 443 } catch (NullPointerException npe) {} 444 } 445 446 static final inline class MyPoint { 447 final MyInt x; 448 final MyInt y; 449 450 private MyPoint() { this(0, 0); } 451 private MyPoint(int x, int y) { 452 this.x = new MyInt(x); 453 this.y = new MyInt(y); 454 } 455 public boolean equals(Object that) { 456 if (that instanceof MyPoint) { 457 MyPoint thatPoint = (MyPoint) that; 458 return x.equals(thatPoint.x) && java.util.Objects.equals(y, thatPoint.y); 459 } 460 return false; 461 } 462 static MyPoint create(int x) { 463 return new MyPoint(x, x); 464 } 465 static MyPoint create(int x, int y) { 466 return new MyPoint(x, y); 467 } 468 static final MyPoint? ORIGIN = create(0); 469 } 470 471 void testComposition() { 472 // Test array operations with compostion of inline types, check element payload is correct... 473 MyPoint a = MyPoint.create(1, 2); 474 MyPoint b = MyPoint.create(7, 21); 475 MyPoint c = MyPoint.create(Integer.MAX_VALUE, Integer.MIN_VALUE); 476 477 MyPoint[] pts = new MyPoint[3]; 478 if (!pts[0].equals(MyPoint.ORIGIN)) { 479 throw new RuntimeException("Equals failed: " + pts[0] + " vs " + MyPoint.ORIGIN); 480 } 481 pts = new MyPoint[] { a, b, c }; 482 checkArrayElementsEqual(pts, new Object[] { a, b, c}); 483 Object[] oarr = new Object[3]; 484 485 arrayCopy(pts, 0, oarr, 0, 3); 486 checkArrayElementsEqual(pts, oarr); 487 488 oarr = new Object[3]; 489 System.arraycopy(pts, 0, oarr, 0, 3); 490 checkArrayElementsEqual(pts, oarr); 491 492 System.arraycopy(oarr, 0, pts, 0, 3); 493 checkArrayElementsEqual(pts, oarr); 494 495 oarr = new Object[3]; 496 try { 497 System.arraycopy(oarr, 0, pts, 0, 3); 498 throw new RuntimeException("Expected NPE"); 499 } 500 catch (NullPointerException npe) {} 501 502 oarr = new Object[3]; 503 oarr[0] = new Object(); 504 try { 505 System.arraycopy(oarr, 0, pts, 0, 3); 506 throw new RuntimeException("Expected ASE"); 507 } 508 catch (ArrayStoreException ase) {} 509 } 510 511 void checkArrayElementsEqual(MyInt[] arr1, Object[] arr2) { 512 assertTrue(arr1.length == arr2.length, "Bad length"); 513 for (int i = 0; i < arr1.length; i++) { 514 assertTrue(java.util.Objects.equals(arr1[i], arr2[i]), "Element " + i + " not equal"); 515 } 516 } 517 518 void checkArrayElementsEqual(MyPoint[] arr1, Object[] arr2) { 519 assertTrue(arr1.length == arr2.length, "Bad length"); 520 for (int i = 0; i < arr1.length; i++) { 521 assertTrue(java.util.Objects.equals(arr1[i], arr2[i]), "Element " + i + " not equal"); 522 } 523 } 524 525 void checkArrayElementsEqual(Object[] arr1, Object[] arr2) { 526 assertTrue(arr1.length == arr2.length, "Bad length"); 527 for (int i = 0; i < arr1.length; i++) { 528 assertTrue(java.util.Objects.equals(arr1[i], arr2[i]), "Element " + i + " not equal"); 529 } 530 } 531 532 void arrayCopy(MyInt[] src, int srcPos, Object[] dst, int dstPos, int length) { 533 for (int i = 0; i < length ; i++) { 534 dst[dstPos++] = src[srcPos++]; 535 } 536 } 537 void arrayCopy(MyPoint[] src, int srcPos, Object[] dst, int dstPos, int length) { 538 for (int i = 0; i < length ; i++) { 539 dst[dstPos++] = src[srcPos++]; 540 } 541 } 542 543 Object getNull() { return null; } 544 545 546 void testValueArrayOom() { 547 int size = Integer.MAX_VALUE; 548 try { 549 MyPoint[] pts = new MyPoint[size]; 550 throw new RuntimeException("Excepted OOM"); 551 } catch (OutOfMemoryError oom) {} 552 } 553 554 }