---
spec: JVMS
title: "The Java Virtual Machine Specification"
edition: "Java SE 10 Edition"
java_version: 10
chapter: "Chapter 5. Loading, Linking, and Initializing"
section: "5.4.3.4"
heading: "5.4.3.4. Interface Method Resolution"
parent: "5.4.3. Resolution"
source: https://docs.oracle.com/javase/specs/jvms/se10/html/jvms-5.html#jvms-5.4.3.4
id: "5.4.3.4"
url: https://jvm.obfuscated.software/jvms/se10/5.4.3.4.html
raw: https://jvm.obfuscated.software/jvms/se10/5.4.3.4.md
---

# 5.4.3.4. Interface Method Resolution

To resolve an unresolved symbolic reference from D to an interface method in an interface C, the symbolic reference to C given by the interface method reference is first resolved ([§5.4.3.1](5.4.3.1.md)). Therefore, any exception that can be thrown as a result of failure of resolution of an interface reference can be thrown as a result of failure of interface method resolution. If the reference to C can be successfully resolved, exceptions relating to the resolution of the interface method reference itself can be thrown.

When resolving an interface method reference:

1. If C is not an interface, interface method resolution throws an `IncompatibleClassChangeError`.
2. Otherwise, if C declares a method with the name and descriptor specified by the interface method reference, method lookup succeeds.
3. Otherwise, if the class `Object` declares a method with the name and descriptor specified by the interface method reference, which has its `ACC_PUBLIC` flag set and does not have its `ACC_STATIC` flag set, method lookup succeeds.
4. Otherwise, if the maximally-specific superinterface methods ([§5.4.3.3](5.4.3.3.md)) of C for the name and descriptor specified by the method reference include exactly one method that does not have its `ACC_ABSTRACT` flag set, then this method is chosen and method lookup succeeds.
5. Otherwise, if any superinterface of C declares a method with the name and descriptor specified by the method reference that has neither its `ACC_PRIVATE` flag nor its `ACC_STATIC` flag set, one of these is arbitrarily chosen and method lookup succeeds.
6. Otherwise, method lookup fails.

The result of interface method resolution is determined by whether method lookup succeeds or fails:

- If method lookup fails, interface method resolution throws a `NoSuchMethodError`.

- If method lookup succeeds and the referenced method is not accessible ([§5.4.4](5.4.4.md)) to D, interface method resolution throws an `IllegalAccessError`.

- Otherwise, let `<`E, `L_1>` be the class or interface in which the referenced interface method `m` is actually declared, and let `L_2` be the defining loader of D.

  Given that the return type of `m` is T_r, and that the formal parameter types of `m` are T_{f1}, ..., T_{fn}, then:

  If T_r is not an array type, let T_0 be T_r; otherwise, let T_0 be the element type ([§2.4](2.4.md)) of T_r.

  For *i* = 1 to *n*: If T_{fi} is not an array type, let T_i be T_{fi}; otherwise, let T_i be the element type ([§2.4](2.4.md)) of T_{fi}.

  The Java Virtual Machine must impose the loading constraints T_i^{L_1} = T_i^{L_2} for *i* = 0 to *n* ([§5.3.4](5.3.4.md)).

The clause about accessibility is necessary because interface method resolution may pick a `private` method of interface C. (Prior to Java SE 8, the result of interface method resolution could be a non-`public` method of class `Object` or a `static` method of class `Object`; such results were not consistent with the inheritance model of the Java programming language, and are disallowed in Java SE 8 and above.)
