1 /* 2 * Copyright (c) 2001, 2009, 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 */ 24 25 # include "incls/_precompiled.incl" 26 # include "incls/_jniCheck.cpp.incl" 27 28 29 // Heap objects are allowed to be directly referenced only in VM code, 30 // not in native code. 31 32 #define ASSERT_OOPS_ALLOWED \ 33 assert(JavaThread::current()->thread_state() == _thread_in_vm, \ 34 "jniCheck examining oops in bad state.") 35 36 37 // Execute the given block of source code with the thread in VM state. 38 // To do this, transition from the NATIVE state to the VM state, execute 39 // the code, and transtition back. The ThreadInVMfromNative constructor 40 // performs the transition to VM state, its destructor restores the 41 // NATIVE state. 42 43 #define IN_VM(source_code) { \ 44 { \ 45 ThreadInVMfromNative __tiv(thr); \ 46 source_code \ | 1 /* 2 * Copyright (c) 2001, 2010, 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 */ 24 25 #include "precompiled.hpp" 26 #include "classfile/systemDictionary.hpp" 27 #include "classfile/vmSymbols.hpp" 28 #include "oops/instanceKlass.hpp" 29 #include "oops/oop.inline.hpp" 30 #include "oops/symbolOop.hpp" 31 #include "prims/jni.h" 32 #include "prims/jniCheck.hpp" 33 #include "prims/jvm_misc.hpp" 34 #include "runtime/fieldDescriptor.hpp" 35 #include "runtime/handles.hpp" 36 #include "runtime/interfaceSupport.hpp" 37 #include "runtime/jfieldIDWorkaround.hpp" 38 #include "runtime/thread.hpp" 39 #ifdef TARGET_ARCH_x86 40 # include "jniTypes_x86.hpp" 41 #endif 42 #ifdef TARGET_ARCH_sparc 43 # include "jniTypes_sparc.hpp" 44 #endif 45 #ifdef TARGET_ARCH_zero 46 # include "jniTypes_zero.hpp" 47 #endif 48 49 50 // Heap objects are allowed to be directly referenced only in VM code, 51 // not in native code. 52 53 #define ASSERT_OOPS_ALLOWED \ 54 assert(JavaThread::current()->thread_state() == _thread_in_vm, \ 55 "jniCheck examining oops in bad state.") 56 57 58 // Execute the given block of source code with the thread in VM state. 59 // To do this, transition from the NATIVE state to the VM state, execute 60 // the code, and transtition back. The ThreadInVMfromNative constructor 61 // performs the transition to VM state, its destructor restores the 62 // NATIVE state. 63 64 #define IN_VM(source_code) { \ 65 { \ 66 ThreadInVMfromNative __tiv(thr); \ 67 source_code \ |