1 /* 2 * Copyright (c) 2019, 2020, 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 compiler.valhalla.inlinetypes; 25 26 class TestUnloadedInlineTypeField { 27 static class MyValue3 { 28 int foo; 29 } 30 31 static class MyValue3Holder { 32 MyValue3 v; 33 } 34 35 static class MyValue10 { 36 int foo; 37 } 38 39 static class MyValue10Holder { 40 MyValue10 v1; 41 MyValue10 v2; 42 } 43 44 static class MyValue13 { 45 int foo; 46 } 47 48 static class MyValue13Holder { 49 MyValue13 v; 50 } 51 52 static class MyValue14 { 53 int foo; 54 } 55 56 static class MyValue14Holder { 57 MyValue14 v; 58 } 59 60 static class MyValue15 { 61 int foo; 62 } 63 64 static class MyValue15Holder { 65 MyValue15 v; 66 } 67 68 static primitive class MyValue16 { 69 int foo = 42; 70 } 71 72 static primitive class MyValue17 { 73 int foo = 42; 74 } 75 } 76 77 class GetUnresolvedInlineFieldWrongSignature { 78 static int test3(Object holder) { 79 if (holder != null) { 80 // Don't use MyValue3Holder in the signature, it might trigger class loading 81 return ((TestUnloadedInlineTypeField.MyValue3Holder)holder).v.foo + 3; 82 } else { 83 return 0; 84 } 85 } 86 87 static void test10(Object holder) { 88 if (holder != null) { 89 // Don't use MyValue10Holder in the signature, it might trigger class loading 90 ((TestUnloadedInlineTypeField.MyValue10Holder)holder).v1 = ((TestUnloadedInlineTypeField.MyValue10Holder)holder).v2; 91 } 92 } 93 94 static void test13(Object holder) { 95 if (holder != null) { 96 // Don't use MyValue13Holder in the signature, it might trigger class loading 97 ((TestUnloadedInlineTypeField.MyValue13Holder)holder).v = new TestUnloadedInlineTypeField.MyValue13(); 98 } 99 } 100 101 static void test14(Object holder) { 102 if (holder != null) { 103 // Don't use MyValue14Holder in the signature, it might trigger class loading 104 ((TestUnloadedInlineTypeField.MyValue14Holder)holder).v = null; 105 } 106 } 107 108 static void test15(Object holder) { 109 if (holder != null) { 110 // Don't use MyValue15Holder in the signature, it might trigger class loading 111 ((TestUnloadedInlineTypeField.MyValue15Holder)holder).v = new TestUnloadedInlineTypeField.MyValue15(); 112 } 113 } 114 115 static Object test16(boolean warmup) { 116 if (!warmup) { 117 return TestUnloadedInlineTypeField.MyValue16.default; 118 } else { 119 return null; 120 } 121 } 122 123 static Object test17(boolean warmup) { 124 if (!warmup) { 125 return TestUnloadedInlineTypeField.MyValue17.default; 126 } else { 127 return null; 128 } 129 } 130 }