JDK-8272564 : Incorrect attribution of method invocations of Object methods on interfaces
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 18
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2021-08-17
  • Updated: 2022-09-16
  • Resolved: 2021-10-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 18
18 b18Fixed
Related Reports
CSR :  
Relates :  
Relates :  
Description
Consider code like:
---
interface I {
     public String toString();
}
interface J extends I {}

I i = null;
i.toString(); //attributed as I.toString();
J j = null;
j.toString(); //attributed as j.toString();
---

This does not seem quite right - the method is inherited in "J" from "I", not from Object.

Moreover, calling `Elements.getAllMembers()` will return "toString" from "I" in the result, but calling `Trees.isAccessible(..., "toString", "I");` will return false, because it will appear that the method is implemented in j.l.Object.
Comments
Changeset: a5080eff Author: Jan Lahoda <jlahoda@openjdk.org> Date: 2021-10-05 10:17:24 +0000 URL: https://git.openjdk.java.net/jdk/commit/a5080effc7ec7e260e84e3169c36c5217f18d231
05-10-2021