Skip to content
This repository has been archived by the owner on May 1, 2023. It is now read-only.

Commit

Permalink
Switch from javaClass look up from static to local
Browse files Browse the repository at this point in the history
Summary:
For some cases of loading, this function can actually be recursively called. Unfortunately, the static initialization of a local variable in a recursive call is actually undefined behavior and for some compilers this results in a deadlock.

> If the initialization recursively enters the block in which the variable is being initialized, the behavior is undefined.

Cite: https://en.cppreference.com/w/cpp/language/storage_duration

Reviewed By: mhorowitz

Differential Revision: D16172871

fbshipit-source-id: 224835620763c60130730946f2ab065f8e66e371
  • Loading branch information
mzlee authored and facebook-github-bot committed Jul 22, 2019
1 parent 577d3f6 commit ba57583
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion deps/fbjni/cxx/fbjni/detail/Hybrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class HybridClass : public detail::HybridTraits<Base>::CxxBase {
using detail::HybridTraits<Base>::CxxBase::CxxBase;

static void registerHybrid(std::initializer_list<NativeMethod> methods) {
javaClassStatic()->registerNatives(methods);
javaClassLocal()->registerNatives(methods);
}

static local_ref<detail::HybridData> makeHybridData(std::unique_ptr<T> cxxPart) {
Expand Down

0 comments on commit ba57583

Please sign in to comment.