diff src/share/vm/c1/c1_GraphBuilder.cpp @ 24170:0b85ccd62409 jdk8u131-b01

8168699: Validate special case invocations Reviewed-by: kevinw, vlivanov
author coleenp
date Tue, 13 Dec 2016 14:37:04 -0500
parents d109bda16490
children 719853999215
line wrap: on
line diff
--- a/src/share/vm/c1/c1_GraphBuilder.cpp	Tue Dec 13 10:07:12 2016 -0800
+++ b/src/share/vm/c1/c1_GraphBuilder.cpp	Tue Dec 13 14:37:04 2016 -0500
@@ -1823,6 +1823,20 @@
                 log->identify(target),
                 Bytecodes::name(code));
 
+  // invoke-special-super
+  if (bc_raw == Bytecodes::_invokespecial && !target->is_object_initializer()) {
+    ciInstanceKlass* sender_klass =
+          calling_klass->is_anonymous() ? calling_klass->host_klass() :
+                                          calling_klass;
+    if (sender_klass->is_interface()) {
+      int index = state()->stack_size() - (target->arg_size_no_receiver() + 1);
+      Value receiver = state()->stack_at(index);
+      CheckCast* c = new CheckCast(sender_klass, receiver, copy_state_before());
+      c->set_invokespecial_receiver_check();
+      state()->stack_at_put(index, append_split(c));
+    }
+  }
+
   // Some methods are obviously bindable without any type checks so
   // convert them directly to an invokespecial or invokestatic.
   if (target->is_loaded() && !target->is_abstract() && target->can_be_statically_bound()) {