1 /*
  2  * Copyright (c) 2019, 2024, 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 value class MyValue16 {
 69         int foo = 42;
 70     }
 71 
 72     static value class MyValue17 {
 73         int foo = 42;
 74     }
 75 }
 76 
 77 class GetUnresolvedInlineFieldWrongSignature {
 78 
 79     static void test13(Object holder) {
 80         if (holder != null) {
 81             // Don't use MyValue13Holder in the signature, it might trigger class loading
 82             ((TestUnloadedInlineTypeField.MyValue13Holder)holder).v = new TestUnloadedInlineTypeField.MyValue13();
 83         }
 84     }
 85 
 86     static void test15(Object holder) {
 87         if (holder != null) {
 88             // Don't use MyValue15Holder in the signature, it might trigger class loading
 89             ((TestUnloadedInlineTypeField.MyValue15Holder)holder).v = new TestUnloadedInlineTypeField.MyValue15();
 90         }
 91     }
 92 
 93     static Object test16(boolean warmup) {
 94         if (!warmup) {
 95             return new TestUnloadedInlineTypeField.MyValue16();
 96         } else {
 97             return null;
 98         }
 99     }
100 
101     static Object test17(boolean warmup) {
102         if (!warmup) {
103             return new TestUnloadedInlineTypeField.MyValue17();
104         } else {
105             return null;
106         }
107     }
108 }