< prev index next >

src/hotspot/share/interpreter/linkResolver.cpp

Print this page
@@ -1052,14 +1052,14 @@
        if (fd.constants()->pool_holder()->major_version() >= 53) {
          Method* m = link_info.current_method();
          assert(m != nullptr, "information about the current method must be available for 'put' bytecodes");
          bool is_initialized_static_final_update = (byte == Bytecodes::_putstatic &&
                                                     fd.is_static() &&
-                                                    !m->is_static_initializer());
+                                                    !m->is_class_initializer());
          bool is_initialized_instance_final_update = ((byte == Bytecodes::_putfield || byte == Bytecodes::_nofast_putfield) &&
                                                       !fd.is_static() &&
-                                                      !m->is_object_initializer());
+                                                      !m->is_object_constructor());
  
          if (is_initialized_static_final_update || is_initialized_instance_final_update) {
            ResourceMark rm(THREAD);
            stringStream ss;
            ss.print("Update to %s final field %s.%s attempted from a different method (%s) than the initializer method %s ",

@@ -1192,10 +1192,12 @@
    } else {
      resolved_method = resolve_interface_method(link_info, Bytecodes::_invokespecial, CHECK_NULL);
    }
  
    // check if method name is <init>, that it is found in same klass as static type
+   // Since this method is never inherited from a super, any appearance here under
+   // the wrong class would be an error.
    if (resolved_method->name() == vmSymbols::object_initializer_name() &&
        resolved_method->method_holder() != resolved_klass) {
      ResourceMark rm(THREAD);
      stringStream ss;
      ss.print("%s: method '", resolved_klass->external_name());

@@ -1723,23 +1725,24 @@
    return;
  }
  
  void LinkResolver::resolve_invoke(CallInfo& result, Handle& recv,
                                    const methodHandle& attached_method,
-                                   Bytecodes::Code byte, TRAPS) {
+                                   Bytecodes::Code byte, bool check_null_and_abstract, TRAPS) {
    Klass* defc = attached_method->method_holder();
    Symbol* name = attached_method->name();
    Symbol* type = attached_method->signature();
    LinkInfo link_info(defc, name, type);
+   Klass* recv_klass = recv.is_null() ? defc : recv->klass();
    switch(byte) {
      case Bytecodes::_invokevirtual:
-       resolve_virtual_call(result, recv, recv->klass(), link_info,
-                            /*check_null_and_abstract=*/true, CHECK);
+       resolve_virtual_call(result, recv, recv_klass, link_info,
+                            check_null_and_abstract, CHECK);
        break;
      case Bytecodes::_invokeinterface:
-       resolve_interface_call(result, recv, recv->klass(), link_info,
-                              /*check_null_and_abstract=*/true, CHECK);
+       resolve_interface_call(result, recv, recv_klass, link_info,
+                              check_null_and_abstract, CHECK);
        break;
      case Bytecodes::_invokestatic:
        resolve_static_call(result, link_info, ClassInitMode::dont_init, CHECK);
        break;
      case Bytecodes::_invokespecial:
< prev index next >