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

Print this page


   1 /*
   2  * @test /nodynamiccopyright/
   3  * @summary May not synchronize on value types
   4  * @modules java.base/jvm.internal.value
   5  * @compile/fail/ref=CheckSync.out -XDrawDiagnostics -Werror -Xlint:values  CheckSync.java
   6  */
   7 
   8 /* Note: ATM, value types do not have jlO in their lineage. So they anyway
   9    cannot synchronize using the methods declared on jlO.
  10 */
  11 @jvm.internal.value.DeriveValueType
  12 public final class CheckSync {
  13     @jvm.internal.value.DeriveValueType
  14     final class Val {
  15 
  16         void foo() {
  17             // All calls below are bad.
  18             wait();
  19             wait(10);
  20             wait(10, 10);
  21             notify();
  22             notifyAll();
  23             finalize();
  24             clone();
  25         }
  26     }
  27 
  28     final Val val = new Val();
  29 
  30     void test() throws InterruptedException {
  31         // All calls below are bad.
  32         val.wait();
  33         val.wait(10);
   1 /*
   2  * @test /nodynamiccopyright/
   3  * @summary May not synchronize on value types
   4  * @modules java.base/jvm.internal.value
   5  * @compile/fail/ref=CheckSync.out -XDrawDiagnostics -Werror -Xlint:values  CheckSync.java
   6  */
   7 
   8 /* Note: ATM, value types do not have jlO in their lineage. So they anyway
   9    cannot synchronize using the methods declared on jlO.
  10 */
  11 @jvm.internal.value.ValueCapableClass
  12 public final class CheckSync {
  13     @jvm.internal.value.ValueCapableClass
  14     final class Val {
  15 
  16         void foo() {
  17             // All calls below are bad.
  18             wait();
  19             wait(10);
  20             wait(10, 10);
  21             notify();
  22             notifyAll();
  23             finalize();
  24             clone();
  25         }
  26     }
  27 
  28     final Val val = new Val();
  29 
  30     void test() throws InterruptedException {
  31         // All calls below are bad.
  32         val.wait();
  33         val.wait(10);