< prev index next >

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

Print this page


   1 /*
   2  * @test /nodynamiccopyright/
   3  * @summary Value types do not support finalize
   4  * @modules java.base/jvm.internal.value
   5  * @compile/fail/ref=CheckFinalize.out -XDrawDiagnostics -Werror -Xlint:values  CheckFinalize.java
   6  */
   7 @jvm.internal.value.ValueCapableClass
   8 final class CheckFinalize {
   9     @Override
  10     protected void finalize() {} // <-- error
  11 
  12     @jvm.internal.value.ValueCapableClass
  13     final class CheckFinalizeInner {}
  14 
  15     void foo(CheckFinalizeInner cfi, CheckFinalize cf) {
  16         cfi.finalize();          // Error
  17         cf.finalize();           // OK.
  18     }
  19 }
   1 /*
   2  * @test /nodynamiccopyright/
   3  * @summary Value types do not support finalize
   4  * @modules jdk.incubator.mvt
   5  * @compile/fail/ref=CheckFinalize.out --should-stop:ifError=PARSE -XDrawDiagnostics -Werror -Xlint:values  CheckFinalize.java
   6  */
   7 @jdk.incubator.mvt.ValueCapableClass
   8 final class CheckFinalize {
   9     @Override
  10     protected void finalize() {} // <-- error
  11 
  12     @jdk.incubator.mvt.ValueCapableClass
  13     final class CheckFinalizeInner {}
  14 
  15     void foo(CheckFinalizeInner cfi, CheckFinalize cf) {
  16         cfi.finalize();          // Error
  17         cf.finalize();           // OK.
  18     }
  19 }
< prev index next >