Class SharedObject.Reference<T extends SharedObject>

java.lang.Object
com.ibm.icu.impl.coll.SharedObject.Reference<T>
All Implemented Interfaces:
AutoCloseable
Enclosing class:
SharedObject

public static final class SharedObject.Reference<T extends SharedObject> extends Object implements AutoCloseable
  • Field Details

  • Constructor Details

    • Reference

      public Reference(T so)
    • Reference

      public Reference(SharedObject.Reference<T> ref)
      Copy constructor. Previously this class implemented Cloneable and had clone() method. Cloning an object with a final field which require modification is tricky (need to use reflection to force updating the field) and discouraged. The new implementation uses this copy constructor instead of clone().
      Parameters:
      ref - A Reference object pointing a SharedObject. This constructor automatically increment reference count of the SharedObject.
  • Method Details

    • readOnly

      public T readOnly()
    • copyOnWrite

      public T copyOnWrite()
    • close

      public void close() throws Exception
      It's recommended to implement AutoCloseable in a class utilizing Java Cleaner. Although it's currently not used by ICU4J implementation, this design allow ICU4J developer to use try-with-resource statement to close the resource automatically.
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception