Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 226452

Summary: [compiler] suspicious MethodBinding#isOverriding results variation involving interfaces
Product: [Eclipse Project] JDT Reporter: Maxime Daniel <maxime_daniel>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: minor    
Priority: P3    
Version: 3.4   
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard: stalebug

Description Maxime Daniel CLA 2008-04-10 04:27:34 EDT
Detected upon v_852 by walking the compiler AST.

When asking the binding for hashCode on the line marked by 'here' below if it isOverriding, the answer is true.

// X.java
public class X implements I {
	public static void main(String[] args) { 
	  new X().foo(); 
	} 
	public void foo() {
	  System.out.println(hashCode());
	} 
	public int hashCode() {
	  int result = 0;
	  J unique = new J(){};
	  result += unique.hashCode(); // here
	  return result;
	} 
}
interface I {
  public static interface J {
	public int hashCode();
  }
}

If we shuffle the test case a little bit as show below, the answer is false:

// X.java
public class X implements I {
	public static void main(String[] args) { 
	  new X().foo(); 
	} 
	public void foo() {
	  System.out.println(hashCode());
	} 
	public int hashCode() {
	  int result = 0;
	  J unique = new J(){};
	  result += unique.hashCode(); // here
	  return result;
	} 
}
// I.java
public interface I {
  public static interface J {
	public int hashCode();
  }
}

(assuming we compile in a single pass - no binaries involved). While the current behavior of @Overriding does not allow us to check this from the outside (see bug 167262), we would probably want to align behaviors here (upon the former one).
Comment 1 Eclipse Genie CLA 2020-05-12 07:59:17 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.