Path: blob/master/src/hotspot/share/jfr/jni/jfrJavaSupport.hpp
41152 views
/*1* Copyright (c) 2016, 2021, Oracle and/or its affiliates. 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*22*/2324#ifndef SHARE_JFR_JNI_JFRJAVASUPPORT_HPP25#define SHARE_JFR_JNI_JFRJAVASUPPORT_HPP2627#include "jfr/jni/jfrJavaCall.hpp"28#include "utilities/exceptions.hpp"2930class Klass;31class outputStream;3233class JfrJavaSupport : public AllStatic {34public:35static jobject local_jni_handle(const oop obj, JavaThread* t);36static jobject local_jni_handle(const jobject handle, JavaThread* t);37static void destroy_local_jni_handle(jobject handle);3839static jobject global_jni_handle(const oop obj, JavaThread* t);40static jobject global_jni_handle(const jobject handle, JavaThread* t);41static void destroy_global_jni_handle(jobject handle);4243static jweak global_weak_jni_handle(const oop obj, JavaThread* t);44static jweak global_weak_jni_handle(const jobject handle, JavaThread* t);45static void destroy_global_weak_jni_handle(jweak handle);4647static oop resolve_non_null(jobject obj);48static void notify_all(jobject obj, TRAPS);49static void set_array_element(jobjectArray arr, jobject element, int index, JavaThread* t);5051// naked oop result52static void call_static(JfrJavaArguments* args, TRAPS);53static void call_special(JfrJavaArguments* args, TRAPS);54static void call_virtual(JfrJavaArguments* args, TRAPS);5556static void set_field(JfrJavaArguments* args, TRAPS);57static void get_field(JfrJavaArguments* args, TRAPS);58static void new_object(JfrJavaArguments* args, TRAPS);5960// global jni handle result61static void new_object_global_ref(JfrJavaArguments* args, TRAPS);62static void get_field_global_ref(JfrJavaArguments* args, TRAPS);6364// local jni handle result65static void new_object_local_ref(JfrJavaArguments* args, TRAPS);66static void get_field_local_ref(JfrJavaArguments* args, TRAPS);6768static jstring new_string(const char* c_str, TRAPS);69static jobjectArray new_string_array(int length, TRAPS);7071static jobject new_java_lang_Boolean(bool value, TRAPS);72static jobject new_java_lang_Integer(jint value, TRAPS);73static jobject new_java_lang_Long(jlong value, TRAPS);7475// misc76static Klass* klass(const jobject handle);77// caller needs ResourceMark78static const char* c_str(jstring string, JavaThread* jt);79static const char* c_str(oop string, JavaThread* t);8081// exceptions82static void throw_illegal_state_exception(const char* message, TRAPS);83static void throw_illegal_argument_exception(const char* message, TRAPS);84static void throw_internal_error(const char* message, TRAPS);85static void throw_out_of_memory_error(const char* message, TRAPS);86static void throw_class_format_error(const char* message, TRAPS);87static void throw_runtime_exception(const char* message, TRAPS);8889static bool is_jdk_jfr_module_available();90static bool is_jdk_jfr_module_available(outputStream* stream, TRAPS);9192static jlong jfr_thread_id(jobject thread);93static void exclude(jobject thread);94static void include(jobject thread);95static bool is_excluded(jobject thread);96static void on_thread_start(Thread* t);9798static jobject get_handler(jobject clazz, TRAPS);99static bool set_handler(jobject clazz, jobject handler, TRAPS);100101// critical102static void abort(jstring errorMsg, TRAPS);103static void uncaught_exception(jthrowable throwable, JavaThread* t);104105// asserts106DEBUG_ONLY(static void check_java_thread_in_vm(JavaThread* t);)107DEBUG_ONLY(static void check_java_thread_in_native(JavaThread* t);)108109enum CAUSE {110VM_ERROR,111OUT_OF_MEMORY,112STACK_OVERFLOW,113RUNTIME_EXCEPTION,114UNKNOWN,115NOF_CAUSES116};117118static CAUSE cause();119120private:121static CAUSE _cause;122static void set_cause(jthrowable throwable, JavaThread* t);123};124125#endif // SHARE_JFR_JNI_JFRJAVASUPPORT_HPP126127128