jniCheck.hpp revision 465
286N/A/*
286N/A * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
286N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
286N/A *
286N/A * This code is free software; you can redistribute it and/or modify it
286N/A * under the terms of the GNU General Public License version 2 only, as
286N/A * published by the Free Software Foundation.
286N/A *
286N/A * This code is distributed in the hope that it will be useful, but WITHOUT
286N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
286N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
286N/A * version 2 for more details (a copy is included in the LICENSE file that
286N/A * accompanied this code).
286N/A *
286N/A * You should have received a copy of the GNU General Public License version
286N/A * 2 along with this work; if not, write to the Free Software Foundation,
286N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
286N/A *
286N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
286N/A * CA 95054 USA or visit www.sun.com if you need additional information or
286N/A * have any questions.
286N/A *
286N/A */
286N/A
286N/Aextern "C" {
286N/A // Report a JNI failure caught by -Xcheck:jni. Perform a core dump.
286N/A // Note: two variations -- one to be called when in VM state (e.g. when
286N/A // within IN_VM macro), one to be called when in NATIVE state.
286N/A
286N/A // When in VM state:
286N/A static void ReportJNIFatalError(JavaThread* thr, const char *msg) {
286N/A tty->print_cr("FATAL ERROR in native method: %s", msg);
286N/A thr->print_stack();
286N/A os::abort(true);
286N/A }
286N/A}
286N/A
286N/A//
286N/A// Checked JNI routines that are useful for outside of checked JNI
286N/A//
286N/A
286N/Aclass jniCheck : public AllStatic {
286N/A public:
286N/A static oop validate_handle(JavaThread* thr, jobject obj);
286N/A static oop validate_object(JavaThread* thr, jobject obj);
286N/A static klassOop validate_class(JavaThread* thr, jclass clazz, bool allow_primitive = false);
286N/A static void validate_class_descriptor(JavaThread* thr, const char* name);
286N/A static void validate_throwable_klass(JavaThread* thr, klassOop klass);
286N/A static void validate_call_object(JavaThread* thr, jobject obj, jmethodID method_id);
286N/A static void validate_call_class(JavaThread* thr, jclass clazz, jmethodID method_id);
286N/A static methodOop validate_jmethod_id(JavaThread* thr, jmethodID method_id);
286N/A};
286N/A