< prev index next >

test/hotspot/jtreg/runtime/cds/appcds/aotCache/HeapObjectIdentity.java

Print this page

  1 /*
  2  * Copyright (c) 2025, 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  *

 77                     "-Xlog:aot+class=debug",
 78                     "-XX:AOTInitTestClass=MyAOTInitedClass",
 79                     bootcp
 80                 };
 81             } else {
 82                 return new String[] {bootcp};
 83             }
 84         }
 85 
 86         @Override
 87         public String[] appCommandLine(RunMode runMode) {
 88             return new String[] {
 89                 mainClass,
 90                 runMode.toString(),
 91             };
 92         }
 93 
 94         @Override
 95         public void checkExecution(OutputAnalyzer out, RunMode runMode) throws Exception {
 96             if (runMode == RunMode.ASSEMBLY) {
 97                 out.shouldContain("MyAOTInitedClass aot-linked inited");
 98             }
 99         }
100     }
101 }
102 
103 class HeapObjectIdentityApp {
104     public static void main(String... args) {
105         MyAOTInitedClass.test();
106     }
107 }
108 
109 // This class is loaded by the boot loader, as -XX:AOTInitTestClass is not too friendly
110 // with classes by other loaders.
111 class MyAOTInitedClass {
112     static Object[] archivedObjects;
113     static {
114         if (archivedObjects == null) {
115             archivedObjects = new Object[14];
116             archivedObjects[0] = Wrapper.BOOLEAN;
117             archivedObjects[1] = Wrapper.INT.zero();

  1 /*
  2  * Copyright (c) 2025, 2026, 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  *

 77                     "-Xlog:aot+class=debug",
 78                     "-XX:AOTInitTestClass=MyAOTInitedClass",
 79                     bootcp
 80                 };
 81             } else {
 82                 return new String[] {bootcp};
 83             }
 84         }
 85 
 86         @Override
 87         public String[] appCommandLine(RunMode runMode) {
 88             return new String[] {
 89                 mainClass,
 90                 runMode.toString(),
 91             };
 92         }
 93 
 94         @Override
 95         public void checkExecution(OutputAnalyzer out, RunMode runMode) throws Exception {
 96             if (runMode == RunMode.ASSEMBLY) {
 97                 out.shouldContain("MyAOTInitedClass aot-linked early inited");
 98             }
 99         }
100     }
101 }
102 
103 class HeapObjectIdentityApp {
104     public static void main(String... args) {
105         MyAOTInitedClass.test();
106     }
107 }
108 
109 // This class is loaded by the boot loader, as -XX:AOTInitTestClass is not too friendly
110 // with classes by other loaders.
111 class MyAOTInitedClass {
112     static Object[] archivedObjects;
113     static {
114         if (archivedObjects == null) {
115             archivedObjects = new Object[14];
116             archivedObjects[0] = Wrapper.BOOLEAN;
117             archivedObjects[1] = Wrapper.INT.zero();
< prev index next >