public static void setDisableCloseableReferencesForBitmaps(
      @CloseableRefType int bitmapCloseableRefType) {
    sBitmapCloseableRefType = bitmapCloseableRefType;
  }
A smart pointer-like class for Java.

<p>This class allows reference-counting semantics in a Java-friendlier way. A single object can
have any number of CloseableReferences pointing to it. When all of these have been closed, the
object either has its {@link Closeable#close} method called, if it implements {@link Closeable},
or its designated {@link ResourceReleaser#release}, if it does not.

<p>Callers can construct a CloseableReference wrapping a {@link Closeable} with:

<pre>
Closeable foo;
CloseableReference c = CloseableReference.of(foo);
</pre>

<p>Objects that do not implement Closeable can still use this class, but must supply a {@link
ResourceReleaser}:

<pre>{@code
Object foo;
ResourceReleaser<Object> fooReleaser;
CloseableReference c = CloseableReference.of(foo, fooReleaser);
}</pre>

<p>When making a logical copy, callers should call {@link #clone}:

<pre>
CloseableReference copy = c.clone();
</pre>

<p>When each copy of CloseableReference is no longer needed, close should be called:

<pre>
copy.close();
c.close();
</pre>

<p>As with any Closeable, try-finally semantics may be needed to ensure that close is called.

<p>Do not rely upon the finalizer; the purpose of this class is for expensive resources to be
released without waiting for the garbage collector. The finalizer will log an error if the close
method has not been called.
fbcore/src/main/java/com/facebook/common/references/CloseableReference.java