From 24b184b66531c1f38aedcbdf2e1f4c98828a05aa Mon Sep 17 00:00:00 2001
From: Paul Sandoz <psandoz@openjdk.org>
Date: Thu, 5 May 2016 11:39:23 -0700
Subject: [PATCH] 8155258: VarHandle implementation improvements

Relax return type check for call to linked method handle invocation

Reviewed-by: shade, vlivanov
---
 hotspot/src/share/vm/opto/doCall.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/hotspot/src/share/vm/opto/doCall.cpp b/hotspot/src/share/vm/opto/doCall.cpp
index 1e8c1a465dc..ce7e6d1df5d 100644
--- a/hotspot/src/share/vm/opto/doCall.cpp
+++ b/hotspot/src/share/vm/opto/doCall.cpp
@@ -415,8 +415,12 @@ static bool check_inlined_mh_linker_info(ciMethod* symbolic_info, ciMethod* reso
   if (symbolic_info->arg_size() != (resolved_method->arg_size() + has_appendix)) {
     return false; // Total size of arguments on stack mismatch.
   }
-  if (!check_type(symbolic_info->return_type(), resolved_method->return_type())) {
-    return false; // Return value size or type mismatch encountered.
+  if (!symbolic_info->return_type()->is_void()) {
+    // Only check the return type if the symbolic method is not void
+    // i.e. the return value of the resolved method can be dropped
+    if (!check_type(symbolic_info->return_type(), resolved_method->return_type())) {
+      return false; // Return value size or type mismatch encountered.
+    }
   }
 
   switch (symbolic_info->intrinsic_id()) {