class ArtMethod; class ArtField; class JavaVMExt; class ScopedObjectAccess; class ScopedObjectAccessAlreadyRunnable;
namespace mirror { class Object;
} // namespace mirror
class JNIEnvExt : public JNIEnv { public: // Creates a new JNIEnvExt. Returns null on error, in which case error_msg // will contain a description of the error. static JNIEnvExt* Create(Thread* self, JavaVMExt* vm, std::string* error_msg); static MemberOffset LrtSegmentStateOffset(PointerSize pointer_size); static MemberOffset LrtPreviousStateOffset(PointerSize pointer_size); static MemberOffset SelfOffset(PointerSize pointer_size); static jint GetEnvHandler(JavaVMExt* vm, /*out*/void** out, jint version);
// Functions to keep track of monitor lock and unlock operations. Used to ensure proper locking // rules in CheckJNI mode.
// Record locking of a monitor. void RecordMonitorEnter(jobject obj) REQUIRES_SHARED(Locks::mutator_lock_);
// Check the release, that is, that the release is performed in the same JNI "segment." void CheckMonitorRelease(jobject obj) REQUIRES_SHARED(Locks::mutator_lock_);
// Check that no monitors are held that have been acquired in this JNI "segment." void CheckNoHeldMonitors() REQUIRES_SHARED(Locks::mutator_lock_);
// Set the functions to the runtime shutdown functions. void SetFunctionsToRuntimeShutdownFunctions();
// Set the functions to the new JNI functions based on Runtime::GetJniIdType. void UpdateJniFunctionsPointer();
// Set the function table override. This will install the override (or original table, if null) // to all threads. // Note: JNI function table overrides are sensitive to the order of operations wrt/ CheckJNI. // After overriding the JNI function table, CheckJNI toggling is ignored.
EXPORT staticvoid SetTableOverride(const JNINativeInterface* table_override)
REQUIRES(!Locks::thread_list_lock_, !Locks::jni_function_table_lock_);
// Return either the regular, or the CheckJNI function table. Will return table_override_ instead // if it is not null.
EXPORT staticconst JNINativeInterface* GetFunctionTable(bool check_jni)
REQUIRES(Locks::jni_function_table_lock_);
// Override of function tables. This applies to both default as well as instrumented (CheckJNI) // function tables. staticconst JNINativeInterface* table_override_ GUARDED_BY(Locks::jni_function_table_lock_);
// The constructor should not be called directly. Use `Create()` that initializes // the new `JNIEnvExt` object by calling `Initialize()`.
JNIEnvExt(Thread* self, JavaVMExt* vm)
REQUIRES(!Locks::jni_function_table_lock_);
// Initialize the `JNIEnvExt` object. bool Initialize(std::string* error_msg);
// Link to Thread::Current().
Thread* const self_;
// The invocation interface JavaVM.
JavaVMExt* const vm_;
// JNI local references.
jni::LocalReferenceTable locals_;
// Stack of cookies corresponding to PushLocalFrame/PopLocalFrame calls. // TODO: to avoid leaks (and bugs), we need to clear this vector on entry (or return) // to a native method.
std::vector<jni::LRTSegmentState> stacked_local_ref_cookies_;
// Entered JNI monitors, for bulk exit on thread detach.
ReferenceTable monitors_;
// Used by -Xcheck:jni.
JNINativeInterface const* unchecked_functions_;
// All locked objects, with the (Java caller) stack frame that locked them. Used in CheckJNI // to ensure that only monitors locked in this native frame are being unlocked, and that at // the end all are unlocked.
std::vector<std::pair<uintptr_t, jobject>> locked_objects_;
// Start time of "critical" JNI calls to ensure that their use doesn't // excessively block the VM with CheckJNI.
uint64_t critical_start_us_;
// How many nested "critical" JNI calls are we in? Used by CheckJNI to ensure that criticals are
uint32_t critical_;
// Frequently-accessed fields cached from JavaVM. bool check_jni_;
// If we are a JNI env for a daemon thread with a deleted runtime.
std::atomic<bool> runtime_deleted_;
// Used to save and restore the JNIEnvExt state when not going through code created by the JNI // compiler. class ScopedJniEnvLocalRefState { public: explicit ScopedJniEnvLocalRefState(JNIEnvExt* env) :
env_(env),
saved_local_ref_cookie_(env->PushLocalReferenceFrame()) {}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.