Path: blob/master/test/hotspot/jtreg/serviceability/jvmti/SetBreakpoint/TestManyBreakpoints.java
66646 views
/*1* Copyright (c) 2022, 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*/2223/*24* @test25* @bug 814499226* @requires vm.jvmti27* @modules java.base/jdk.internal.org.objectweb.asm28* @run main/othervm/native -agentlib:TestManyBreakpoints29* -Xlog:gc+metaspace30* -Xint31* -XX:MetaspaceSize=16K -XX:MaxMetaspaceSize=64M32* TestManyBreakpoints33*/3435import jdk.internal.org.objectweb.asm.ClassWriter;36import jdk.internal.org.objectweb.asm.Label;37import jdk.internal.org.objectweb.asm.MethodVisitor;38import jdk.internal.org.objectweb.asm.Opcodes;3940public class TestManyBreakpoints {4142static final int BATCHES = 50;43static final int METHODS = 1000;4445public static void main(String[] args) throws Exception {46for (int c = 0; c < BATCHES; c++) {47System.out.println("Batch " + c);48TestClassLoader loader = new TestClassLoader();49Class.forName("Target", true, loader);50}51}5253private static class TestClassLoader extends ClassLoader implements Opcodes {54static byte[] TARGET_BYTES = generateTarget();5556private static byte[] generateTarget() {57ClassWriter cw = new ClassWriter(0);5859cw.visit(52, ACC_SUPER | ACC_PUBLIC, "Target", null, "java/lang/Object", null);60for (int m = 0; m < METHODS; m++) {61MethodVisitor mv = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "m" + m, "()V", null, null);62mv.visitCode();63mv.visitInsn(RETURN);64mv.visitMaxs(0, 0);65mv.visitEnd();66}67cw.visitEnd();68return cw.toByteArray();69}7071@Override72protected Class<?> findClass(String name) throws ClassNotFoundException {73if (name.equals("Target")) {74return defineClass(name, TARGET_BYTES, 0, TARGET_BYTES.length);75} else {76return super.findClass(name);77}78}79}8081}828384