1 /*
   2  * @test /nodynamiccopyright/
   3  * @summary check that a datum can inherit from DataClass or an abstract datum class
   4  * @compile/fail/ref=RecordsCantHaveExtendsClause.out -XDrawDiagnostics RecordsCantHaveExtendsClause.java
   5  */
   6 
   7 import java.io.Serializable;
   8 
   9 class RecordsCantHaveExtendsClause {
  10 
  11     // even Object which is the implicit super class for records
  12     record R1(int x) extends Object {}
  13 
  14     record R2(int y) {}
  15 
  16     // can't extend other records either
  17     record R3(int y, int x) extends R2(y) {}
  18 
  19     // records can implement interfaces
  20     record R4() implements Serializable, Runnable {
  21         public void run() {}
  22     }
  23 }