Path: blob/master/test/hotspot/jtreg/runtime/LoadClass/TriggerResize.java
40942 views
/*1* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.lang.ClassLoader;2425public class TriggerResize extends ClassLoader26{27static private int[] DATA = // bytes for "class TestCase00000 {}"28{29-54, -2, -70, -66, 0, 0, 0, 52, 0, 13, // 03010, 0, 3, 0, 10, 7, 0, 11, 7, 0, // 103112, 1, 0, 6, 60, 105, 110, 105, 116, 62, // 20321, 0, 3, 40, 41, 86, 1, 0, 4, 67, // 3033111, 100, 101, 1, 0, 15, 76, 105, 110, 101, // 403478, 117, 109, 98, 101, 114, 84, 97, 98, 108, // 5035101, 1, 0, 10, 83, 111, 117, 114, 99, 101, // 603670, 105, 108, 101, 1, 0, 18, 84, 101, 115, // 7037116, 67, 97, 115, 101, 48, 48, 48, 48, 48, // 803846, 106, 97, 118, 97, 12, 0, 4, 0, 5, // 90391, 0, 13, 84, 101, 115, 116, 67, 97, 115, // 10040101, 48, 48, 48, 48, 48, 1, 0, 16, 106, // 1104197, 118, 97, 47, 108, 97, 110, 103, 47, 79, // 1204298, 106, 101, 99, 116, 0, 32, 0, 2, 0, // 130433, 0, 0, 0, 0, 0, 1, 0, 0, 0, // 140444, 0, 5, 0, 1, 0, 6, 0, 0, 0, // 1504529, 0, 1, 0, 1, 0, 0, 0, 5, 42, // 16046-73, 0, 1, -79, 0, 0, 0, 1, 0, 7, // 170470, 0, 0, 6, 0, 1, 0, 0, 0, 1, // 180480, 1, 0, 8, 0, 0, 0, 2, 0, 9 // 19049};5051static private int INDEX1 = 85;52static private int INDEX2 = 111;53static private int BASE = 48;5455public TriggerResize()56{57super();58}5960public void load(int index)61{62byte[] bytes = new byte[TriggerResize.DATA.length];63for (int i=0; i<bytes.length; i++)64{65bytes[i] = (byte)TriggerResize.DATA[i];66}6768// replace id "00000" in TestCase00000 to generate new class on the fly69{70int byte1 = index % 10;71int byte2 = index / 10 % 10;72int byte3 = index / 100 % 10;73int byte4 = index / 1000 % 10;74int byte5 = index / 10000 % 10;7576bytes[INDEX1+0] = bytes[INDEX2+0] = (byte)(BASE+byte5);77bytes[INDEX1+1] = bytes[INDEX2+1] = (byte)(BASE+byte4);78bytes[INDEX1+2] = bytes[INDEX2+2] = (byte)(BASE+byte3);79bytes[INDEX1+3] = bytes[INDEX2+3] = (byte)(BASE+byte2);80bytes[INDEX1+4] = bytes[INDEX2+4] = (byte)(BASE+byte1);81}8283Class generatedClass = defineClass(bytes, 0, bytes.length);84resolveClass(generatedClass);85}8687public static void main(String args[]) throws Exception88{89int count = 0;90if (args.length >= 1) {91Integer i = Integer.parseInt(args[0]);92count = i.intValue();93}9495TriggerResize test = new TriggerResize();96for (int i = 0; i <= count; i++)97{98test.load(i);99}100101// trigger safepoint to resize the SystemDictionary if needed102System.gc();103}104}105106107