namespace linker { class ImageWriter;
} // namespace linker
namespace mirror { class Array;
} // namespace mirror
class ArtMethod; class IsMarkedVisitor; class Libraries; class ParsedOptions; class Runtime; struct RuntimeArgumentMap; class ScopedObjectAccess;
class JavaVMExt; // Hook definition for runtime plugins. using GetEnvHook = jint (*)(JavaVMExt* vm, /*out*/void** new_env, jint version);
class JavaVMExt : public JavaVM { public: // Creates a new JavaVMExt object. // Returns nullptr on error, in which case error_msg is set to a message // describing the error. static std::unique_ptr<JavaVMExt> Create(Runtime* runtime, const RuntimeArgumentMap& runtime_options,
std::string* error_msg);
// Aborts execution unless there is an abort handler installed in which case it will return. Its // therefore important that callers return after aborting as otherwise code following the abort // will be executed in the abort handler case. void JniAbort(constchar* jni_function_name, constchar* msg);
// If both "-Xcheck:jni" and "-Xjnitrace:" are enabled, we print trace messages // when a native method that matches the -Xjnitrace argument calls a JNI function // such as NewByteArray. // If -verbose:third-party-jni is on, we want to log any JNI function calls // made by a third-party native method. bool ShouldTrace(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_);
// Decode weak global as strong. Use only if the target object is known to be alive.
ObjPtr<mirror::Object> DecodeWeakGlobalAsStrong(IndirectRef ref)
REQUIRES_SHARED(Locks::mutator_lock_)
REQUIRES(!Locks::jni_weak_globals_lock_);
// Like DecodeWeakGlobal() but to be used only during a runtime shutdown where self may be // null.
ObjPtr<mirror::Object> DecodeWeakGlobalDuringShutdown(Thread* self, IndirectRef ref)
REQUIRES_SHARED(Locks::mutator_lock_)
REQUIRES(!Locks::jni_weak_globals_lock_);
// Checks if the weak global ref has been cleared by the GC without decode (read barrier.) bool IsWeakGlobalCleared(Thread* self, IndirectRef ref)
REQUIRES_SHARED(Locks::mutator_lock_)
REQUIRES(!Locks::jni_weak_globals_lock_);
// Return the library search path for the given classloader, if the classloader is of a // well-known type. The jobject will be a local reference and is expected to be managed by the // caller. static jstring GetLibrarySearchPath(JNIEnv* env, jobject class_loader);
private: // The constructor should not be called directly. Use `Create()` that initializes // the new `JavaVMExt` object by calling `Initialize()`.
JavaVMExt(Runtime* runtime, const RuntimeArgumentMap& runtime_options);
// Initialize the `JavaVMExt` object. bool Initialize(std::string* error_msg);
// Return true if self can currently access weak globals. bool MayAccessWeakGlobals(Thread* self) const REQUIRES_SHARED(Locks::mutator_lock_);
// Used for testing. By default, we'll LOG(FATAL) the reason. void (*check_jni_abort_hook_)(void* data, const std::string& reason); void* check_jni_abort_hook_data_;
// Extra checking. bool check_jni_; constbool force_copy_; constbool tracing_enabled_;
// Extra diagnostics. const std::string trace_;
IndirectReferenceTable globals_;
// No lock annotation since UnloadNativeLibraries is called on libraries_ but locks the // jni_libraries_lock_ internally.
std::unique_ptr<Libraries> libraries_;
// Used by -Xcheck:jni. const JNIInvokeInterface* const unchecked_functions_;
// Since weak_globals_ contain weak roots, be careful not to // directly access the object references in it. Use Get() with the // read barrier enabled or disabled based on the use case.
IndirectReferenceTable weak_globals_;
Atomic<bool> allow_accessing_weak_globals_;
ConditionVariable weak_globals_add_condition_ GUARDED_BY(Locks::jni_weak_globals_lock_);
// TODO Maybe move this to Runtime.
ReaderWriterMutex env_hooks_lock_ BOTTOM_MUTEX_ACQUIRED_AFTER;
std::vector<GetEnvHook> env_hooks_ GUARDED_BY(env_hooks_lock_);
// We report the number of global references after every kGlobalRefReportInterval changes. static constexpr uint32_t kGlobalRefReportInterval = 17;
uint32_t weak_global_ref_report_counter_ GUARDED_BY(Locks::jni_weak_globals_lock_)
= kGlobalRefReportInterval;
uint32_t global_ref_report_counter_ GUARDED_BY(Locks::jni_globals_lock_)
= kGlobalRefReportInterval;
friendclass linker::ImageWriter; // Uses `globals_` and `weak_globals_` without read barrier. friend IndirectReferenceTable* GetIndirectReferenceTable(ScopedObjectAccess& soa,
IndirectRefKind kind);
DISALLOW_COPY_AND_ASSIGN(JavaVMExt);
};
} // namespace art
#endif// ART_RUNTIME_JNI_JAVA_VM_EXT_H_
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet am 2026-06-29)
¤
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.