< prev index next >

src/java.base/share/classes/java/lang/ref/Cleaner.java

Print this page
*** 216,13 ***
       * the cleaning action is run by the Cleaner's thread.
       *
       * @param obj   the object to monitor
       * @param action a {@code Runnable} to invoke when the object becomes phantom reachable
       * @return a {@code Cleanable} instance
       */
      public Cleanable register(@jdk.internal.RequiresIdentity Object obj, Runnable action) {
!         Objects.requireNonNull(obj, "obj");
          Objects.requireNonNull(action, "action");
          return new CleanerImpl.PhantomCleanableRef(obj, this, action);
      }
  
      /**
--- 216,15 ---
       * the cleaning action is run by the Cleaner's thread.
       *
       * @param obj   the object to monitor
       * @param action a {@code Runnable} to invoke when the object becomes phantom reachable
       * @return a {@code Cleanable} instance
+      * @throws IdentityException if the object is not an
+      *         {@link java.util.Objects#hasIdentity(Object) identity object}
       */
      public Cleanable register(@jdk.internal.RequiresIdentity Object obj, Runnable action) {
!         Objects.requireIdentity(obj, "obj");
          Objects.requireNonNull(action, "action");
          return new CleanerImpl.PhantomCleanableRef(obj, this, action);
      }
  
      /**
< prev index next >