41 * @run main/othervm -Xcomp -XX:ValueArrayElemMaxFlatSize=0 -XX:+EnableValhalla runtime.valhalla.valuetypes.ValueTypeArray 42 */ 43 public class ValueTypeArray { 44 public static void main(String[] args) { 45 ValueTypeArray valueTypeArray = new ValueTypeArray(); 46 valueTypeArray.run(); 47 } 48 49 public void run() { 50 testClassForName(); 51 testSimplePointArray(); 52 testLong8Array(); 53 testMixedPersonArray(); 54 testMultiDimPointArray(); 55 testComposition(); 56 57 testSanityCheckcasts(); 58 testObjectArrayOfValues(); 59 60 testReflectArray(); 61 // testUtilArrays(); 62 } 63 64 void testClassForName() { 65 String arrayClsName = "[Lruntime.valhalla.valuetypes.Point;"; 66 try { 67 Class<?> arrayCls = Class.forName(arrayClsName); 68 assertTrue(arrayCls.isArray(), "Expected an array class"); 69 // array-of-L-type not supported yet 70 // the component type of a flattened value array is of the value type 71 // the component type of a non-flattened array is of the box type 72 assertTrue(arrayCls.getComponentType().asBoxType() == Point.class, 73 "Expected component type of Point.class got: " + arrayCls.getComponentType()); 74 75 arrayClsName = "[" + arrayClsName; 76 Class<?> mulArrayCls = Class.forName(arrayClsName); 77 assertTrue(mulArrayCls.isArray()); 78 assertTrue(mulArrayCls.getComponentType() == arrayCls); 79 } 80 catch (ClassNotFoundException cnfe) { 81 fail("Class.forName(" + arrayClsName + ") failed", cnfe); 82 } 83 } 84 85 void testSimplePointArray() { 86 Point[] defaultPoint = new Point[1]; 87 Point p = defaultPoint[0]; 88 assertEquals(p.x, 0, "invalid default loaded from array"); 89 assertEquals(p.y, 0, "invalid default loaded from array"); 90 boolean gotNpe = false; 91 try { 92 defaultPoint[0] = (Point) getNull(); 93 } catch (NullPointerException npe) { 94 gotNpe = true; 95 } 96 assertTrue(gotNpe, "Expected NullPointerException"); 97 98 Point[] points = createSimplePointArray(); 170 assertEquals(multiPoints[0][0].length, 4, "3rd dim length"); 171 172 Point defaultPoint = multiPoints[1][2][3]; 173 assertEquals(defaultPoint.x, 0, "invalid point x value"); 174 assertEquals(defaultPoint.y, 0, "invalid point x value"); 175 } 176 177 void testReflectArray() { 178 // Check the java.lang.reflect.Array.newInstance methods... 179 Class<?> cls = (Class<?>) Point[].class; 180 Point[][] array = (Point[][]) Array.newInstance(cls, 1); 181 assertEquals(array.length, 1, "Incorrect length"); 182 assertTrue(array[0] == null, "Expected NULL"); 183 184 Point[][][] array3 = (Point[][][]) Array.newInstance(cls, 1, 2); 185 assertEquals(array3.length, 1, "Incorrect length"); 186 assertEquals(array3[0].length, 2, "Incorrect length"); 187 assertTrue(array3[0][0] == null, "Expected NULL"); 188 189 // Now create ObjArrays of ValueArray... 190 cls = (Class<?>) Point.class; 191 array = (Point[][]) Array.newInstance(cls, 1, 2); 192 assertEquals(array.length, 1, "Incorrect length"); 193 assertEquals(array[0].length, 2, "Incorrect length"); 194 Point p = array[0][1]; 195 int x = p.x; 196 assertEquals(x, 0, "Bad Point Value"); 197 } 198 199 static final value class MyInt implements Comparable<MyInt> { 200 final int value; 201 202 private MyInt() { value = 0; } 203 public int getValue() { return value; } 204 public String toString() { return "MyInt: " + getValue(); } 205 public int compareTo(MyInt that) { return Integer.compare(this.getValue(), that.getValue()); } 206 public boolean equals(Object o) { 207 if (o instanceof MyInt) { 208 return this.getValue() == ((MyInt) o).getValue(); 209 } 210 return false; 211 } 212 213 public static MyInt create(int v) { 214 MyInt mi = MyInt.default; 215 mi = __WithField(mi.value, v); 216 return mi; 217 } 218 219 public static final MyInt.box MIN = MyInt.create(Integer.MIN_VALUE); 220 public static final MyInt.box ZERO = MyInt.create(0); 221 public static final MyInt.box MAX = MyInt.create(Integer.MAX_VALUE); 222 } 223 224 static interface SomeSecondaryType { 225 default String hi() { return "Hi"; } 226 } 227 228 static final value class MyOtherInt implements SomeSecondaryType { 229 final int value; 230 private MyOtherInt() { value = 0; } 231 } 232 233 void testSanityCheckcasts() { 234 // TODO Re-enable if value type arrays become covariant with object arrays 235 /* 236 237 MyInt[] myInts = new MyInt[1]; 238 assertTrue(myInts instanceof Object[]); 239 assertTrue(myInts instanceof Comparable[]); 240 241 Object arrObj = Array.newInstance(MyInt.class, 1); 242 assertTrue(arrObj instanceof Object[], "Not Object array"); 243 assertTrue(arrObj instanceof Comparable[], "Not Comparable array"); 244 assertTrue(arrObj instanceof MyInt[], "Not MyInt array"); 245 246 Object[] arr = (Object[]) arrObj; 247 assertTrue(arr instanceof Comparable[], "Not Comparable array"); 248 assertTrue(arr instanceof MyInt[], "Not MyInt array"); 249 Comparable[] comparables = (Comparable[])arr; 250 MyInt[] myIntArr = (MyInt[]) arr; 251 252 // multi-dim, check secondary array types are setup... 253 MyOtherInt[][] matrix = new MyOtherInt[1][1]; 254 assertTrue(matrix[0] instanceof MyOtherInt[]); 255 assertTrue(matrix[0] instanceof SomeSecondaryType[]); 256 */ 257 } 258 259 /* 260 * Comment out this test because value type arrays are not assignable to the array 261 * parameter types used by the methods in class java.util.Arrays. 262 * 263 void testUtilArrays() { 264 // Sanity check j.u.Arrays 265 MyInt[] myInts = new MyInt[] { MyInt.MAX, MyInt.MIN }; 266 // Sanity sort another copy 267 MyInt[] copyMyInts = Arrays.copyOf(myInts, myInts.length + 1); 268 checkArrayElementsEqual(copyMyInts, new MyInt[] { myInts[0], myInts[1], MyInt.ZERO}); 269 270 Arrays.sort(copyMyInts); 271 checkArrayElementsEqual(copyMyInts, new MyInt[] { MyInt.MIN, MyInt.ZERO, MyInt.MAX }); 272 273 List myIntList = Arrays.asList(copyMyInts); 274 checkArrayElementsEqual(copyMyInts, myIntList.toArray(new MyInt[copyMyInts.length])); 275 // This next line needs testMixedLayoutArrays to work 276 checkArrayElementsEqual(copyMyInts, myIntList.toArray()); 277 278 // Sanity check j.u.ArrayList 279 ArrayList<MyInt> aList = new ArrayList<MyInt>(Arrays.asList(copyMyInts)); 280 assertTrue(aList.indexOf(MyInt.MIN) == 0, "Bad Index"); 281 assertTrue(aList.indexOf(MyInt.ZERO) == 1, "Bad Index"); 282 assertTrue(aList.indexOf(MyInt.MAX) == 2, "Bad Index"); 283 284 aList.remove(2); 285 aList.add(MyInt.create(5)); 286 287 // Interesting: 288 //aList.add((MyInt)getNull()); 289 290 // javac currently generating "java/util/Objects.requireNonNull 291 // should checkcast treat null against Value class as CCE ? 292 // Then in the end, ArrayList.elementData is Object[], (that's why remove works) 293 // why can't I write add(null) then ? 294 } 295 */ 296 297 void testObjectArrayOfValues() { 298 testSanityObjectArrays(); 299 testMixedLayoutArrays(); 300 } 301 302 void testSanityObjectArrays() { 303 Object[] objects = new Object[2]; 304 assertTrue(objects[0] == null && objects[1] == null, "Not null ?"); 305 306 objects[0] = MyInt.create(1); 307 objects[1] = Integer.valueOf(2); 308 assertTrue(objects[0].equals(MyInt.create(1)), "Bad Value"); 309 assertTrue(objects[1].equals(Integer.valueOf(2)), "Bad Object"); 310 311 Comparable[] copyComparables = new Comparable[objects.length]; 312 System.arraycopy(objects, 0, copyComparables, 0, objects.length); 313 checkArrayElementsEqual(objects, copyComparables); 314 315 objects[0] = null; 316 objects[1] = null; 317 assertTrue(objects[0] == null && objects[1] == null, "Not null ?"); 318 319 Comparable[] comparables = new Comparable[2]; 320 assertTrue(comparables[0] == null && comparables[1] == null, "Not null ?"); 321 comparables[0] = MyInt.create(3); 322 comparables[1] = Integer.valueOf(4); 323 assertTrue(comparables[0].equals(MyInt.create(3)), "Bad Value"); 324 assertTrue(comparables[1].equals(Integer.valueOf(4)), "Bad Object"); 325 326 Object[] copyObjects = new Object[2]; 327 System.arraycopy(comparables, 0, copyObjects, 0, comparables.length); 328 checkArrayElementsEqual(comparables, copyObjects); 329 330 comparables[0] = null; 331 comparables[1] = null; 332 assertTrue(comparables[0] == null && comparables[1] == null, "Not null ?"); 333 } 334 335 void testMixedLayoutArrays() { 336 Object[] objArray = new Object[3]; 337 Comparable[] compArray = new Comparable[3]; 338 MyInt[] valArray = new MyInt[] { MyInt.MIN, MyInt.ZERO, MyInt.MAX }; 339 340 arrayCopy(valArray, 0, objArray, 0, 3); 341 checkArrayElementsEqual(valArray, objArray); 342 arrayCopy(valArray, 0, objArray, 0, 3); 343 344 objArray = new Object[3]; 345 System.arraycopy(valArray, 0, objArray, 0, 3); 346 checkArrayElementsEqual(valArray, objArray); 347 348 System.arraycopy(valArray, 0, compArray, 0, 3); 349 checkArrayElementsEqual(valArray, compArray); 350 351 valArray = new MyInt[] { MyInt.ZERO, MyInt.ZERO, MyInt.ZERO }; 352 System.arraycopy(compArray, 0, valArray, 0, 3); 353 checkArrayElementsEqual(valArray, compArray); 354 355 valArray = new MyInt[] { MyInt.ZERO, MyInt.ZERO, MyInt.ZERO }; 356 System.arraycopy(objArray, 0, valArray, 0, 3); 357 checkArrayElementsEqual(valArray, objArray); 358 359 // Sanity check dst == src 360 System.arraycopy(valArray, 0, valArray, 0, 3); 361 checkArrayElementsEqual(valArray, objArray); 362 363 objArray[0] = "Not a value object"; 364 try { 365 System.arraycopy(objArray, 0, valArray, 0, 3); 366 throw new RuntimeException("Expected ArrayStoreException"); 367 } catch (ArrayStoreException ase) {} 368 } 369 370 static final value class MyPoint { 371 final MyInt.val x; 372 final MyInt y; 373 374 private MyPoint() { 375 x = MyInt.ZERO; 376 y = x; 377 } 378 public boolean equals(Object that) { 379 if (that instanceof MyPoint) { 380 MyPoint thatPoint = (MyPoint) that; 381 return x.equals(thatPoint.x) && java.util.Objects.equals(y, thatPoint.y); 382 } 383 return false; 384 } 385 static MyPoint create(int x) { 386 MyPoint mp = MyPoint.default; 387 mp = __WithField(mp.x, MyInt.create(x)); | 41 * @run main/othervm -Xcomp -XX:ValueArrayElemMaxFlatSize=0 -XX:+EnableValhalla runtime.valhalla.valuetypes.ValueTypeArray 42 */ 43 public class ValueTypeArray { 44 public static void main(String[] args) { 45 ValueTypeArray valueTypeArray = new ValueTypeArray(); 46 valueTypeArray.run(); 47 } 48 49 public void run() { 50 testClassForName(); 51 testSimplePointArray(); 52 testLong8Array(); 53 testMixedPersonArray(); 54 testMultiDimPointArray(); 55 testComposition(); 56 57 testSanityCheckcasts(); 58 testObjectArrayOfValues(); 59 60 testReflectArray(); 61 testUtilArrays(); 62 } 63 64 void testClassForName() { 65 String arrayClsName = "[Lruntime.valhalla.valuetypes.Point;"; 66 String qarrayClsName = "[Qruntime.valhalla.valuetypes.Point;"; 67 try { 68 // L-type.. 69 Class<?> arrayCls = Class.forName(arrayClsName); 70 assertTrue(arrayCls.isArray(), "Expected an array class"); 71 72 assertTrue(arrayCls.getComponentType() == Point.class.asBoxType(), 73 "Expected component type of Point.class got: " + arrayCls.getComponentType()); 74 75 arrayClsName = "[" + arrayClsName; 76 Class<?> mulArrayCls = Class.forName(arrayClsName); 77 assertTrue(mulArrayCls.isArray()); 78 assertTrue(mulArrayCls.getComponentType() == arrayCls); 79 80 // Q-type... 81 arrayCls = Class.forName(qarrayClsName); 82 assertTrue(arrayCls.isArray(), "Expected an array class"); 83 84 assertTrue(arrayCls.getComponentType() == Point.class.asValueType(), 85 arrayCls + 86 " Expected component type of Point.class got: " + arrayCls.getComponentType()); 87 88 qarrayClsName = "[" + qarrayClsName; 89 mulArrayCls = Class.forName(qarrayClsName); 90 assertTrue(mulArrayCls.isArray()); 91 assertTrue(mulArrayCls.getComponentType() == arrayCls); 92 } 93 catch (ClassNotFoundException cnfe) { 94 fail("Class.forName(" + arrayClsName + ") failed", cnfe); 95 } 96 } 97 98 void testSimplePointArray() { 99 Point[] defaultPoint = new Point[1]; 100 Point p = defaultPoint[0]; 101 assertEquals(p.x, 0, "invalid default loaded from array"); 102 assertEquals(p.y, 0, "invalid default loaded from array"); 103 boolean gotNpe = false; 104 try { 105 defaultPoint[0] = (Point) getNull(); 106 } catch (NullPointerException npe) { 107 gotNpe = true; 108 } 109 assertTrue(gotNpe, "Expected NullPointerException"); 110 111 Point[] points = createSimplePointArray(); 183 assertEquals(multiPoints[0][0].length, 4, "3rd dim length"); 184 185 Point defaultPoint = multiPoints[1][2][3]; 186 assertEquals(defaultPoint.x, 0, "invalid point x value"); 187 assertEquals(defaultPoint.y, 0, "invalid point x value"); 188 } 189 190 void testReflectArray() { 191 // Check the java.lang.reflect.Array.newInstance methods... 192 Class<?> cls = (Class<?>) Point[].class; 193 Point[][] array = (Point[][]) Array.newInstance(cls, 1); 194 assertEquals(array.length, 1, "Incorrect length"); 195 assertTrue(array[0] == null, "Expected NULL"); 196 197 Point[][][] array3 = (Point[][][]) Array.newInstance(cls, 1, 2); 198 assertEquals(array3.length, 1, "Incorrect length"); 199 assertEquals(array3[0].length, 2, "Incorrect length"); 200 assertTrue(array3[0][0] == null, "Expected NULL"); 201 202 // Now create ObjArrays of ValueArray... 203 cls = (Class<?>) Point.class.asBoxType(); 204 Point.box[][] barray = (Point.box[][]) Array.newInstance(cls, 1, 2); 205 assertEquals(barray.length, 1, "Incorrect length"); 206 assertEquals(barray[0].length, 2, "Incorrect length"); 207 barray[0][1] = Point.createPoint(1, 2); 208 Point.box pb = barray[0][1]; 209 int x = pb.getX(); 210 assertEquals(x, 1, "Bad Point Value"); 211 } 212 213 static final value class MyInt implements Comparable<MyInt> { 214 final int value; 215 216 private MyInt() { value = 0; } 217 public int getValue() { return value; } 218 public String toString() { return "MyInt: " + getValue(); } 219 public int compareTo(MyInt that) { return Integer.compare(this.getValue(), that.getValue()); } 220 public boolean equals(Object o) { 221 if (o instanceof MyInt) { 222 return this.getValue() == ((MyInt) o).getValue(); 223 } 224 return false; 225 } 226 227 public static MyInt create(int v) { 228 MyInt mi = MyInt.default; 229 mi = __WithField(mi.value, v); 230 return mi; 231 } 232 233 public static final MyInt.box MIN = MyInt.create(Integer.MIN_VALUE); 234 public static final MyInt.box ZERO = MyInt.create(0); 235 public static final MyInt.box MAX = MyInt.create(Integer.MAX_VALUE); 236 } 237 238 static MyInt staticMyInt = MyInt.create(-1); 239 static MyInt[] staticMyIntArray = new MyInt[] { staticMyInt }; 240 static MyInt[][] staticMyIntArrayArray = new MyInt[][] { staticMyIntArray, staticMyIntArray }; 241 242 static interface SomeSecondaryType { 243 default String hi() { return "Hi"; } 244 } 245 246 static final value class MyOtherInt implements SomeSecondaryType { 247 final int value; 248 private MyOtherInt() { value = 0; } 249 } 250 251 void testSanityCheckcasts() { 252 MyInt[] myInts = new MyInt[1]; 253 assertTrue(myInts instanceof Object[]); 254 assertTrue(myInts instanceof Comparable[]); 255 256 Class<?> cls = MyInt.class.asValueType(); 257 assertTrue(cls.isValue()); 258 Object arrObj = Array.newInstance(cls, 1); 259 assertTrue(arrObj instanceof Object[], "Not Object array"); 260 assertTrue(arrObj instanceof Comparable[], "Not Comparable array"); 261 assertTrue(arrObj instanceof MyInt[], "Not MyInt array"); 262 263 Object[] arr = (Object[]) arrObj; 264 assertTrue(arr instanceof Comparable[], "Not Comparable array"); 265 assertTrue(arr instanceof MyInt[], "Not MyInt array"); 266 Comparable[] comparables = (Comparable[])arr; 267 MyInt[] myIntArr = (MyInt[]) arr; 268 269 // multi-dim, check secondary array types are setup... 270 MyOtherInt[][] matrix = new MyOtherInt[1][1]; 271 assertTrue(matrix[0] instanceof MyOtherInt[]); 272 assertTrue(matrix[0] instanceof SomeSecondaryType[]); 273 274 // Box types vs Value... 275 MyInt.box[] myValueRefs = new MyInt.box[1]; 276 assertTrue(myValueRefs instanceof MyInt.box[]); 277 assertTrue(myValueRefs instanceof Object[]); 278 assertTrue(myValueRefs instanceof Comparable[]); 279 } 280 281 282 void testUtilArrays() { 283 // Sanity check j.u.Arrays 284 MyInt[] myInts = new MyInt[] { MyInt.MAX, MyInt.MIN }; 285 // Sanity sort another copy 286 MyInt[] copyMyInts = Arrays.copyOf(myInts, myInts.length + 1); 287 checkArrayElementsEqual(copyMyInts, new MyInt[] { myInts[0], myInts[1], MyInt.ZERO}); 288 289 Arrays.sort(copyMyInts); 290 checkArrayElementsEqual(copyMyInts, new MyInt[] { MyInt.MIN, MyInt.ZERO, MyInt.MAX }); 291 292 List myIntList = Arrays.asList(copyMyInts); 293 checkArrayElementsEqual(copyMyInts, myIntList.toArray(new MyInt[copyMyInts.length])); 294 // This next line needs testMixedLayoutArrays to work 295 checkArrayElementsEqual(copyMyInts, myIntList.toArray()); 296 297 // Sanity check j.u.ArrayList 298 ArrayList<MyInt> aList = new ArrayList<MyInt>(Arrays.asList(copyMyInts)); 299 assertTrue(aList.indexOf(MyInt.MIN) == 0, "Bad Index"); 300 assertTrue(aList.indexOf(MyInt.ZERO) == 1, "Bad Index"); 301 assertTrue(aList.indexOf(MyInt.MAX) == 2, "Bad Index"); 302 303 aList.remove(2); 304 aList.add(MyInt.create(5)); 305 } 306 307 308 void testObjectArrayOfValues() { 309 testSanityObjectArrays(); 310 testMixedLayoutArrays(); 311 } 312 313 void testSanityObjectArrays() { 314 Object[] objects = new Object[2]; 315 assertTrue(objects[0] == null && objects[1] == null, "Not null ?"); 316 317 objects[0] = MyInt.create(1); 318 objects[1] = Integer.valueOf(2); 319 assertTrue(objects[0].equals(MyInt.create(1)), "Bad Value"); 320 assertTrue(objects[1].equals(Integer.valueOf(2)), "Bad Object"); 321 322 Comparable[] copyComparables = new Comparable[objects.length]; 323 System.arraycopy(objects, 0, copyComparables, 0, objects.length); 324 checkArrayElementsEqual(objects, copyComparables); 325 326 objects[0] = null; 327 objects[1] = null; 328 assertTrue(objects[0] == null && objects[1] == null, "Not null ?"); 329 330 Comparable[] comparables = new Comparable[2]; 331 assertTrue(comparables[0] == null && comparables[1] == null, "Not null ?"); 332 comparables[0] = MyInt.create(3); 333 comparables[1] = Integer.valueOf(4); 334 assertTrue(comparables[0].equals(MyInt.create(3)), "Bad Value"); 335 assertTrue(comparables[1].equals(Integer.valueOf(4)), "Bad Object"); 336 337 Object[] copyObjects = new Object[2]; 338 System.arraycopy(comparables, 0, copyObjects, 0, comparables.length); 339 checkArrayElementsEqual(comparables, copyObjects); 340 341 comparables[0] = null; 342 comparables[1] = null; 343 assertTrue(comparables[0] == null && comparables[1] == null, "Not null ?"); 344 345 MyInt.box[] myIntRefArray = new MyInt.box[1]; 346 assertTrue(myIntRefArray[0] == null, "Got: " + myIntRefArray[0]); 347 myIntRefArray[0] = null; 348 } 349 350 void testMixedLayoutArrays() { 351 Object[] objArray = new Object[3]; 352 Comparable[] compArray = new Comparable[3]; 353 MyInt[] valArray = new MyInt[] { MyInt.MIN, MyInt.ZERO, MyInt.MAX }; 354 355 arrayCopy(valArray, 0, objArray, 0, 3); 356 checkArrayElementsEqual(valArray, objArray); 357 arrayCopy(valArray, 0, objArray, 0, 3); 358 359 objArray = new Object[3]; 360 System.arraycopy(valArray, 0, objArray, 0, 3); 361 checkArrayElementsEqual(valArray, objArray); 362 363 System.arraycopy(valArray, 0, compArray, 0, 3); 364 checkArrayElementsEqual(valArray, compArray); 365 366 valArray = new MyInt[] { MyInt.ZERO, MyInt.ZERO, MyInt.ZERO }; 367 System.arraycopy(compArray, 0, valArray, 0, 3); 368 checkArrayElementsEqual(valArray, compArray); 369 370 valArray = new MyInt[] { MyInt.ZERO, MyInt.ZERO, MyInt.ZERO }; 371 System.arraycopy(objArray, 0, valArray, 0, 3); 372 checkArrayElementsEqual(valArray, objArray); 373 374 // Sanity check dst == src 375 System.arraycopy(valArray, 0, valArray, 0, 3); 376 checkArrayElementsEqual(valArray, objArray); 377 378 objArray[0] = "Not a value object"; 379 try { 380 System.arraycopy(objArray, 0, valArray, 0, 3); 381 throw new RuntimeException("Expected ArrayStoreException"); 382 } catch (ArrayStoreException ase) {} 383 384 MyInt.box[] myIntRefArray = new MyInt.box[3]; 385 System.arraycopy(valArray, 0, myIntRefArray, 0, 3); 386 checkArrayElementsEqual(valArray, myIntRefArray); 387 388 myIntRefArray[0] = null; 389 try { 390 System.arraycopy(myIntRefArray, 0, valArray, 0, 3); 391 throw new RuntimeException("Expected NullPointerException"); 392 } catch (NullPointerException npe) {} 393 } 394 395 static final value class MyPoint { 396 final MyInt.val x; 397 final MyInt y; 398 399 private MyPoint() { 400 x = MyInt.ZERO; 401 y = x; 402 } 403 public boolean equals(Object that) { 404 if (that instanceof MyPoint) { 405 MyPoint thatPoint = (MyPoint) that; 406 return x.equals(thatPoint.x) && java.util.Objects.equals(y, thatPoint.y); 407 } 408 return false; 409 } 410 static MyPoint create(int x) { 411 MyPoint mp = MyPoint.default; 412 mp = __WithField(mp.x, MyInt.create(x)); |