< prev index next >

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

Print this page


   1 /*
   2  * @test /nodynamiccopyright/
   3  * @summary null cannot be casted to and compared with value types.
   4  * @modules  java.base/jvm.internal.value
   5  * @compile/fail/ref=CheckNullCastable.out -XDrawDiagnostics -Werror  -Xlint:values  CheckNullCastable.java
   6  */
   7 @jvm.internal.value.ValueCapableClass
   8 final class CheckNullCastable {
   9     void foo(CheckNullCastable cnc) {
  10         CheckNullCastable cncl = (CheckNullCastable) null;
  11         if (cnc != null) {};
  12         if (null != cnc) {};
  13     }
  14 }
   1 /*
   2  * @test /nodynamiccopyright/
   3  * @summary null cannot be casted to and compared with value types.
   4  * @modules jdk.incubator.mvt
   5  * @compile/fail/ref=CheckNullCastable.out --should-stop:ifError=PARSE -XDrawDiagnostics -Werror  -Xlint:values  CheckNullCastable.java
   6  */
   7 @jdk.incubator.mvt.ValueCapableClass
   8 final class CheckNullCastable {
   9     void foo(CheckNullCastable cnc) {
  10         CheckNullCastable cncl = (CheckNullCastable) null;
  11         if (cnc != null) {};
  12         if (null != cnc) {};
  13     }
  14 }
< prev index next >