Skip to content

Commit

Permalink
Fix destruction of NumberFormat (#523)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #523

`NumberFormat::Impl` contains a JNI reference, and must be destroyed
in a context registered with the JVM. For now, do this using
`jni::ThreadScope::WithClassLoader`, since it avoids us needing to
add special logic to handle this in the GC.

Reviewed By: mhorowitz

Differential Revision: D28791955

fbshipit-source-id: ad81403f0a6482924721e4603f6ab8146d30dedb
  • Loading branch information
neildhar authored and facebook-github-bot committed Jun 8, 2021
1 parent 103f1d3 commit 1b3a0c2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/Platform/Intl/PlatformIntlAndroid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,9 @@ struct NumberFormat::Impl {

NumberFormat::NumberFormat() : impl_(std::make_unique<Impl>()) {}

NumberFormat::~NumberFormat() {}
NumberFormat::~NumberFormat() {
jni::ThreadScope::WithClassLoader([&] { impl_.reset(); });
}

vm::CallResult<std::vector<std::u16string>> NumberFormat::supportedLocalesOf(
vm::Runtime *runtime,
Expand Down

0 comments on commit 1b3a0c2

Please sign in to comment.