test/tools/javac/valhalla/minimalvalues/CheckIdentityHash01.java

Print this page


   1 /*
   2  * @test /nodynamiccopyright/
   3  * @summary Value types do not support identityHashCode
   4  * @modules java.base/jvm.internal.value
   5  * @compile/fail/ref=CheckIdentityHash01.out -XDrawDiagnostics -Werror -Xlint:values  CheckIdentityHash01.java
   6  */
   7 
   8 import static java.lang.System.*;
   9 @jvm.internal.value.DeriveValueType
  10 final class CheckIdentityHash01 {
  11     void test(CheckIdentityHash01 v) {
  12 
  13         identityHashCode(v);      // <- error
  14         identityHashCode(this);   // <- error
  15 
  16         System system = null;
  17         system.identityHashCode(v);      // <- error
  18         system.identityHashCode(this);   // <- error
  19 
  20         System.identityHashCode(v);      // <- error
  21         System.identityHashCode(this);   // <- error
  22 
  23         java.lang.System.identityHashCode(v);    // <- error
  24         java.lang.System.identityHashCode(this); // <- error
  25     }
  26 }
   1 /*
   2  * @test /nodynamiccopyright/
   3  * @summary Value types do not support identityHashCode
   4  * @modules java.base/jvm.internal.value
   5  * @compile/fail/ref=CheckIdentityHash01.out -XDrawDiagnostics -Werror -Xlint:values  CheckIdentityHash01.java
   6  */
   7 
   8 import static java.lang.System.*;
   9 @jvm.internal.value.ValueCapableClass
  10 final class CheckIdentityHash01 {
  11     void test(CheckIdentityHash01 v) {
  12 
  13         identityHashCode(v);      // <- error
  14         identityHashCode(this);   // <- error
  15 
  16         System system = null;
  17         system.identityHashCode(v);      // <- error
  18         system.identityHashCode(this);   // <- error
  19 
  20         System.identityHashCode(v);      // <- error
  21         System.identityHashCode(this);   // <- error
  22 
  23         java.lang.System.identityHashCode(v);    // <- error
  24         java.lang.System.identityHashCode(this); // <- error
  25     }
  26 }