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