1 /*
   2  * @test /nodynamiccopyright/
   3  * @summary Value types may not declare fields of its own type either directly or indirectly.
   4  * @modules java.base/jvm.internal.value
   5  * @compile/fail/ref=CheckCyclicMembership.out -XDrawDiagnostics -Werror -Xlint:values CheckCyclicMembership.java
   6  */
   7 @jvm.internal.value.DeriveValueType
   8 final class CheckCyclicMembership {
   9     class InnerRef {
  10         CheckCyclicMembership ccm;
  11     }
  12     @jvm.internal.value.DeriveValueType final class InnerValue {
  13         final CheckCyclicMembership ccm = new CheckCyclicMembership(); // Error.
  14     }
  15     final CheckCyclicMembership ccm = new CheckCyclicMembership(); // Error.
  16     final int i = 10;
  17     final String s = "blah";
  18     final InnerRef ir = new InnerRef(); // OK.
  19     final InnerValue iv = new InnerValue(); // Error.
  20 }