template<typename T>
class facebook::yoga::vanillajni::ScopedLocalRef< T >
ScopedLocalRef is a sort of smart reference that allows us to control the lifespan of a JNI local reference.
This class is designed so that when a ScopedLocalRef goes out of scope, its destructor will delete -JNIEnv->DeleteLocalRef()- the underlying JNI reference.
This class should be used to wrap all the local references that JNI gives us other than those that are passed to native methods at invocation time. The idea behind this is that in JNI we should be very explicit about the lifespan of local references. Local references can quickly get out of control, and the developer should always be very aware of the lifespan of each local reference that is created in JNI so that leaks are prevented.
This class is very explicit in its behavior, and it does not allow to perform unexpected conversions or unexpected ownership transfer. In practice, this class acts as a unique pointer where the underlying JNI reference can have one and just one owner. Transferring ownership is allowed but it is an explicit operation (implemented via move semantics and also via explicitly API calls).
As with standard JNI local references it is not a valid operation to keep a reference around between different native method calls.