Fri, 12 Jun 2020 02:59:56 +0100
8233197: Invert JvmtiExport::post_vm_initialized() and Jfr:on_vm_start() start-up order for correct option parsing
8246703: [TESTBUG] Add test for JDK-8233197
Reviewed-by: aph, adinn, neugens
1 /*
2 * Copyright (c) 2016, 2018, 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 */
25 #ifndef SHARE_VM_JFR_JNI_JFRJAVASUPPORT_HPP
26 #define SHARE_VM_JFR_JNI_JFRJAVASUPPORT_HPP
28 #include "jfr/jni/jfrJavaCall.hpp"
29 #include "utilities/exceptions.hpp"
31 class Klass;
32 class JavaThread;
33 class outputStream;
35 class JfrJavaSupport : public AllStatic {
36 public:
37 static jobject local_jni_handle(const oop obj, Thread* t);
38 static jobject local_jni_handle(const jobject handle, Thread* t);
39 static void destroy_local_jni_handle(const jobject handle);
41 static jobject global_jni_handle(const oop obj, Thread* t);
42 static jobject global_jni_handle(const jobject handle, Thread* t);
43 static void destroy_global_jni_handle(const jobject handle);
45 static oop resolve_non_null(jobject obj);
46 static void notify_all(jobject obj, TRAPS);
47 static void set_array_element(jobjectArray arr, jobject element, int index, Thread* t);
49 // naked oop result
50 static void call_static(JfrJavaArguments* args, TRAPS);
51 static void call_special(JfrJavaArguments* args, TRAPS);
52 static void call_virtual(JfrJavaArguments* args, TRAPS);
54 static void set_field(JfrJavaArguments* args, TRAPS);
55 static void get_field(JfrJavaArguments* args, TRAPS);
56 static void new_object(JfrJavaArguments* args, TRAPS);
58 // global jni handle result
59 static void new_object_global_ref(JfrJavaArguments* args, TRAPS);
60 static void get_field_global_ref(JfrJavaArguments* args, TRAPS);
62 // local jni handle result
63 static void new_object_local_ref(JfrJavaArguments* args, TRAPS);
64 static void get_field_local_ref(JfrJavaArguments* args, TRAPS);
66 static jstring new_string(const char* c_str, TRAPS);
67 static jobjectArray new_string_array(int length, TRAPS);
69 static jobject new_java_lang_Boolean(bool value, TRAPS);
70 static jobject new_java_lang_Integer(jint value, TRAPS);
71 static jobject new_java_lang_Long(jlong value, TRAPS);
73 // misc
74 static Klass* klass(const jobject handle);
75 // caller needs ResourceMark
76 static const char* c_str(jstring string, Thread* jt);
78 // exceptions
79 static void throw_illegal_state_exception(const char* message, TRAPS);
80 static void throw_illegal_argument_exception(const char* message, TRAPS);
81 static void throw_internal_error(const char* message, TRAPS);
82 static void throw_out_of_memory_error(const char* message, TRAPS);
83 static void throw_class_format_error(const char* message, TRAPS);
84 static void throw_runtime_exception(const char* message, TRAPS);
86 static jlong jfr_thread_id(jobject target_thread);
88 // critical
89 static void abort(jstring errorMsg, TRAPS);
90 static void uncaught_exception(jthrowable throwable, Thread* t);
92 // asserts
93 DEBUG_ONLY(static void check_java_thread_in_vm(Thread* t);)
94 DEBUG_ONLY(static void check_java_thread_in_native(Thread* t);)
96 enum CAUSE {
97 VM_ERROR,
98 OUT_OF_MEMORY,
99 STACK_OVERFLOW,
100 RUNTIME_EXCEPTION,
101 UNKNOWN,
102 NOF_CAUSES
103 };
105 static CAUSE cause();
107 private:
108 static CAUSE _cause;
109 static void set_cause(jthrowable throwable, Thread* t);
110 };
112 #endif // SHARE_VM_JFR_JNI_JFRJAVASUPPORT_HPP