Private method check in linkResolver is incorrect

XMLWordPrintable

    • 11
    • b15
    • Verified

        As discussed in JDK-8210768 this assertion in linkResolver has two problems:

          // For private method invocation we should only find the method in the resolved class.
          // If that is not the case then we have a found a supertype method that we have nestmate
          // access to.
          if (resolved_method->is_private() && resolved_method->method_holder() != resolved_klass) {
            ResourceMark rm(THREAD);
            DEBUG_ONLY(bool is_nestmate = InstanceKlass::cast(link_info.current_klass())->has_nestmate_access_to(InstanceKlass::cast(resolved_klass), THREAD);)
            assert(is_nestmate, "was only expecting nestmates to get here!");

        First the nestmate access check should be between the current class and the resolved_method->method_holder() not the resolved class.

        Second, we are only assured to have found a nestmate if normal access checking is enabled.

        But on further examination of this and a related test case the entire check regarding private methods is incorrect and needs to be removed as it violates the JVMS method resolution rules.

              Assignee:
              David Holmes
              Reporter:
              David Holmes
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: