Wed, 21 May 2014 10:56:41 -0700
Added tag jdk8u20-b15 for changeset 8c785f9bde6f
1 /*
2 * Copyright (c) 2013, 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 */
24 #include <assert.h>
25 #include <jni.h>
27 #include <pthread.h>
29 JavaVM* jvm;
31 void *
32 floobydust (void *p) {
33 JNIEnv *env;
35 jvm->AttachCurrentThread((void**)&env, NULL);
37 jclass class_id = env->FindClass ("DoOverflow");
38 assert (class_id);
40 jmethodID method_id = env->GetStaticMethodID(class_id, "printIt", "()V");
41 assert (method_id);
43 env->CallStaticVoidMethod(class_id, method_id, NULL);
45 jvm->DetachCurrentThread();
46 }
48 int
49 main (int argc, const char** argv) {
50 JavaVMOption options[1];
51 options[0].optionString = (char*) "-Xss320k";
53 JavaVMInitArgs vm_args;
54 vm_args.version = JNI_VERSION_1_2;
55 vm_args.ignoreUnrecognized = JNI_TRUE;
56 vm_args.options = options;
57 vm_args.nOptions = 1;
59 JNIEnv* env;
60 jint result = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
61 assert(result >= 0);
63 pthread_t thr;
64 pthread_create(&thr, NULL, floobydust, NULL);
65 pthread_join(thr, NULL);
67 floobydust(NULL);
69 return 0;
70 }