14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test NullCheckDroppingsTest 26 * @bug 8054492 27 * @summary "Casting can result in redundant null checks in generated code" 28 * @library /testlibrary /../../test/lib /testlibrary/com/oracle/java/testlibrary 29 * @modules java.base/sun.misc 30 * java.management 31 * @build NullCheckDroppingsTest 32 * @run main ClassFileInstaller sun.hotspot.WhiteBox 33 * sun.hotspot.WhiteBox$WhiteBoxPermission 34 * @run main ClassFileInstaller com.oracle.java.testlibrary.Platform 35 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI 36 * -Xmixed -XX:-BackgroundCompilation -XX:-TieredCompilation -XX:CompileThreshold=1000 37 * -XX:CompileCommand=exclude,NullCheckDroppingsTest::runTest NullCheckDroppingsTest 38 */ 39 40 import sun.hotspot.WhiteBox; 41 import sun.hotspot.code.NMethod; 42 import com.oracle.java.testlibrary.Platform; 43 44 import java.lang.reflect.Method; 45 import java.lang.invoke.MethodHandle; 46 import java.lang.invoke.MethodHandles; 47 import java.lang.invoke.MethodType; 48 import java.util.function.BiFunction; 49 50 public class NullCheckDroppingsTest { 51 52 private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); 53 54 static final BiFunction<Class, Object, Object> fCast = (c, o) -> c.cast(o); 55 56 static final MethodHandle SET_SSINK; 57 static final MethodHandle MH_CAST; 58 59 static { 60 try { 61 SET_SSINK = MethodHandles.lookup().findSetter(NullCheckDroppingsTest.class, "ssink", String.class); 62 MH_CAST = MethodHandles.lookup().findVirtual(Class.class, | 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test NullCheckDroppingsTest 26 * @bug 8054492 27 * @summary "Casting can result in redundant null checks in generated code" 28 * @library /testlibrary /../../test/lib /testlibrary/com/oracle/java/testlibrary 29 * @modules java.base/sun.misc 30 * java.management 31 * @build NullCheckDroppingsTest 32 * @run main ClassFileInstaller sun.hotspot.WhiteBox 33 * sun.hotspot.WhiteBox$WhiteBoxPermission 34 * @run main ClassFileInstaller jdk.test.lib.Platform 35 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI 36 * -Xmixed -XX:-BackgroundCompilation -XX:-TieredCompilation -XX:CompileThreshold=1000 37 * -XX:CompileCommand=exclude,NullCheckDroppingsTest::runTest NullCheckDroppingsTest 38 */ 39 40 import sun.hotspot.WhiteBox; 41 import sun.hotspot.code.NMethod; 42 import jdk.test.lib.Platform; 43 44 import java.lang.reflect.Method; 45 import java.lang.invoke.MethodHandle; 46 import java.lang.invoke.MethodHandles; 47 import java.lang.invoke.MethodType; 48 import java.util.function.BiFunction; 49 50 public class NullCheckDroppingsTest { 51 52 private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); 53 54 static final BiFunction<Class, Object, Object> fCast = (c, o) -> c.cast(o); 55 56 static final MethodHandle SET_SSINK; 57 static final MethodHandle MH_CAST; 58 59 static { 60 try { 61 SET_SSINK = MethodHandles.lookup().findSetter(NullCheckDroppingsTest.class, "ssink", String.class); 62 MH_CAST = MethodHandles.lookup().findVirtual(Class.class, |