changeset 53172:e986cdb5aa99 lworld

8215110: [lworld]: Javac should not generate a null check anymore for checkcast target type being a value type
author sadayapalam
date Mon, 10 Dec 2018 13:33:12 +0530
parents 5e355d28824a
children 128ccaa6d2e3
files src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java test/langtools/tools/javac/valhalla/lworld-values/CastNullCheckTest.java
diffstat 2 files changed, 2 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java	Mon Dec 10 12:07:50 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java	Mon Dec 10 13:33:12 2018 +0530
@@ -2565,9 +2565,6 @@
             tree.expr = translate(tree.expr, tree.type);
         else
             tree.expr = translate(tree.expr);
-        if (Feature.VALUE_TYPES.allowedInSource(source) && types.isValue(tree.type) && !types.isValueBased(tree.type))
-            if (!types.isSameType(tree.expr.type, tree.clazz.type))
-                tree.expr = attr.makeNullCheck(tree.expr);
         result = tree;
     }
 
--- a/test/langtools/tools/javac/valhalla/lworld-values/CastNullCheckTest.java	Mon Dec 10 12:07:50 2018 +0530
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CastNullCheckTest.java	Mon Dec 10 13:33:12 2018 +0530
@@ -25,6 +25,7 @@
 
 /*
  * @test
+ * @bug 8215110
  * @summary Check that casting to a value type involves a null check.
  *
  * @compile -XDallowWithFieldOperator Point.java
@@ -61,7 +62,7 @@
         } catch (NullPointerException npe) {
             caught++;
         }
-        if (caught != 1)
+        if (caught != 2)
             throw new AssertionError("Wrong NPE count: " + caught);
     }
 }