1 /* 2 * Copyright (c) 2017, 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 package runtime.valhalla.valuetypes; 24 25 final class ContainerValue1 { 26 static TestValue1 staticValueField; 27 TestValue1 nonStaticValueField; 28 TestValue1[] valueArray; 29 } 30 31 public __ByValue final class TestValue1 { 32 33 static TestValue1 staticValue = getInstance(); 34 35 final int i; 36 final String name; 37 38 private TestValue1() { 39 i = (int)System.nanoTime(); 40 name = Integer.valueOf(i).toString(); 41 } 42 43 __ValueFactory public static TestValue1 create(int i) { 44 TestValue1 v = __MakeDefault TestValue1(); 45 v.i = i; 46 v.name = Integer.valueOf(i).toString(); 47 return v; 48 } 49 50 __ValueFactory public static TestValue1 create() { 51 TestValue1 v = __MakeDefault TestValue1(); 52 v.i = (int)System.nanoTime(); 53 v.name = Integer.valueOf(v.i).toString(); 54 return v; 55 } 56 57 public static TestValue1 getInstance() { 58 return create(); 59 } 60 61 public static TestValue1 getNonBufferedInstance() { 62 return staticValue; 63 } 64 65 public boolean verify() { 66 if (name == null) return i == 0; 67 return Integer.valueOf(i).toString().compareTo(name) == 0; 68 } 69 }