Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/runtime/StackGap/exestack-gap.c
32284 views
1
/*
2
* Copyright (c) 2018, Red Hat, Inc. 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
#include <jni.h>
25
#include <stdio.h>
26
#include <stdlib.h>
27
28
JNIEnv* create_vm(JavaVM **jvm, char *extra_option)
29
{
30
JNIEnv* env;
31
JavaVMInitArgs args;
32
JavaVMOption options[4];
33
args.version = JNI_VERSION_1_8;
34
args.nOptions = 3 + (extra_option != NULL);
35
options[0].optionString = "-Xss2048k";
36
char classpath[4096];
37
snprintf(classpath, sizeof classpath,
38
"-Djava.class.path=%s", getenv("CLASSPATH"));
39
options[1].optionString = classpath;
40
options[2].optionString = "-XX:+UnlockExperimentalVMOptions";
41
if (extra_option) {
42
options[3].optionString = extra_option;
43
}
44
args.options = &options[0];
45
args.ignoreUnrecognized = 0;
46
int rv;
47
rv = JNI_CreateJavaVM(jvm, (void**)&env, &args);
48
if (rv < 0) return NULL;
49
return env;
50
}
51
52
void run(char *extra_arg) {
53
JavaVM *jvm;
54
jclass T_class;
55
jmethodID test_method;
56
JNIEnv *env = create_vm(&jvm, extra_arg);
57
if (env == NULL)
58
exit(1);
59
T_class = (*env)->FindClass(env, "T");
60
if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
61
(*env)->ExceptionDescribe(env);
62
exit(1);
63
}
64
test_method = (*env)->GetStaticMethodID(env, T_class, "test", "(I)V");
65
if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
66
(*env)->ExceptionDescribe(env);
67
exit(1);
68
}
69
(*env)->CallStaticVoidMethod(env, T_class, test_method, 1000);
70
}
71
72
73
int main(int argc, char **argv)
74
{
75
if (argc > 1) {
76
run(argv[1]);
77
} else {
78
run(NULL);
79
}
80
81
return 0;
82
}
83
84