< prev index next >

test/jdk/java/util/Objects/BasicObjectsTest.java

Print this page
*** 1,7 ***
  /*
!  * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.
--- 1,7 ---
  /*
!  * Copyright (c) 2009, 2021, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.

*** 43,10 ***
--- 43,11 ---
          errors += testCompare();
          errors += testRequireNonNull();
          errors += testIsNull();
          errors += testNonNull();
          errors += testNonNullOf();
+         errors += testNewIdentity();
          if (errors > 0 )
              throw new RuntimeException();
      }
  
      private static int testEquals() {

*** 273,6 ***
--- 274,21 ---
              // expected
              errors += npe.getMessage().equals("supplier") ? 0 : 1;
          }
          return errors;
      }
+ 
+     private static int testNewIdentity() {
+         int errors = 0;
+ 
+         Object o1 = Objects.newIdentity();
+         Object o2 = Objects.newIdentity();
+ 
+         if (o1 == null || o2 == null)
+             errors += 1;
+ 
+         if (o1 == o2)
+             errors += 1;
+ 
+         return errors;
+     }
  }
< prev index next >