< prev index next >

src/java.base/share/classes/java/util/Objects.java

Print this page
*** 25,10 ***
--- 25,11 ---
  
  package java.util;
  
  import jdk.internal.util.Preconditions;
  import jdk.internal.vm.annotation.ForceInline;
+ import jdk.internal.misc.Unsafe;
  
  import java.util.function.Supplier;
  
  /**
   * This class consists of {@code static} utility methods for operating

*** 423,6 ***
--- 424,16 ---
      public static
      int checkFromIndexSize(int fromIndex, int size, int length) {
          return Preconditions.checkFromIndexSize(fromIndex, size, length, null);
      }
  
+     /**
+      * Return the size of the object in the heap.
+      *
+      * @param o an object
+      * @return the objects's size
+      * @since Valhalla
+      */
+     public static long getObjectSize(Object o) {
+         return Unsafe.getUnsafe().getObjectSize(o);
+     }
  }
< prev index next >