Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/test/hotspot/jtreg/serviceability/jvmti/SetBreakpoint/TestManyBreakpoints.java
66646 views
1
/*
2
* Copyright (c) 2022, 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
/*
25
* @test
26
* @bug 8144992
27
* @requires vm.jvmti
28
* @modules java.base/jdk.internal.org.objectweb.asm
29
* @run main/othervm/native -agentlib:TestManyBreakpoints
30
* -Xlog:gc+metaspace
31
* -Xint
32
* -XX:MetaspaceSize=16K -XX:MaxMetaspaceSize=64M
33
* TestManyBreakpoints
34
*/
35
36
import jdk.internal.org.objectweb.asm.ClassWriter;
37
import jdk.internal.org.objectweb.asm.Label;
38
import jdk.internal.org.objectweb.asm.MethodVisitor;
39
import jdk.internal.org.objectweb.asm.Opcodes;
40
41
public class TestManyBreakpoints {
42
43
static final int BATCHES = 50;
44
static final int METHODS = 1000;
45
46
public static void main(String[] args) throws Exception {
47
for (int c = 0; c < BATCHES; c++) {
48
System.out.println("Batch " + c);
49
TestClassLoader loader = new TestClassLoader();
50
Class.forName("Target", true, loader);
51
}
52
}
53
54
private static class TestClassLoader extends ClassLoader implements Opcodes {
55
static byte[] TARGET_BYTES = generateTarget();
56
57
private static byte[] generateTarget() {
58
ClassWriter cw = new ClassWriter(0);
59
60
cw.visit(52, ACC_SUPER | ACC_PUBLIC, "Target", null, "java/lang/Object", null);
61
for (int m = 0; m < METHODS; m++) {
62
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "m" + m, "()V", null, null);
63
mv.visitCode();
64
mv.visitInsn(RETURN);
65
mv.visitMaxs(0, 0);
66
mv.visitEnd();
67
}
68
cw.visitEnd();
69
return cw.toByteArray();
70
}
71
72
@Override
73
protected Class<?> findClass(String name) throws ClassNotFoundException {
74
if (name.equals("Target")) {
75
return defineClass(name, TARGET_BYTES, 0, TARGET_BYTES.length);
76
} else {
77
return super.findClass(name);
78
}
79
}
80
}
81
82
}
83
84