< prev index next >

langtools/test/tools/javac/valhalla/minimalvalues/CheckFinal.java

Print this page


   1 /*
   2  * @test /nodynamiccopyright/
   3  * @summary Value types and their instance fields must be final
   4  * @modules java.base/jvm.internal.value
   5  * @compile/fail/ref=CheckFinal.out -XDrawDiagnostics -Werror -Xlint:values CheckFinal.java
   6  */
   7 
   8 @jvm.internal.value.ValueCapableClass
   9 class CheckFinal {  // <- error
  10     int x;          // <- error
  11     void f(int x) { // <- ok
  12         int y;      // <- ok
  13         @jvm.internal.value.ValueCapableClass
  14         final class CheckLocalFinal {
  15             int x; // <- error.
  16         }
  17     }
  18     final Object o = new Object() { int i; }; // <- ok
  19     static int xs; // OK.
  20 }
   1 /*
   2  * @test /nodynamiccopyright/
   3  * @summary Value types and their instance fields must be final
   4  * @modules jdk.incubator.mvt
   5  * @compile/fail/ref=CheckFinal.out -XDrawDiagnostics -Werror -Xlint:values CheckFinal.java
   6  */
   7 
   8 @jdk.incubator.mvt.ValueCapableClass
   9 class CheckFinal {  // <- error
  10     int x;          // <- error
  11     void f(int x) { // <- ok
  12         int y;      // <- ok
  13         @jdk.incubator.mvt.ValueCapableClass
  14         final class CheckLocalFinal {
  15             int x; // <- error.
  16         }
  17     }
  18     final Object o = new Object() { int i; }; // <- ok
  19     static int xs; // OK.
  20 }
< prev index next >