Bug 271303

Summary: [1.5][compiler] Override and package visibility issue
Product: [Eclipse Project] JDT Reporter: Yannick Welsch <welsch>
Component: CoreAssignee: Kent Johnson <kent_johnson>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jarthana, Olivier_Thomann, srikanth_sankaran
Version: 3.4.2   
Target Milestone: 3.5 M7   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Proposed patch and testcase none

Description Yannick Welsch CLA 2009-04-06 08:03:28 EDT
The jdt compiler raises an error for a legal (JLS-conform) Java program:


Code to reproduce error:

------------- A.java ---------------
package p1;

public class A {
    void m() {}
}

------------- B.java ---------------
package p2;

public class B extends p1.A {
    void m() {}
}

------------- C.java ---------------
package p1;

public class C extends p2.B {
    @Override void m() {}
}


This gives the following error:


1. ERROR in p1/C.java (at line 4)
	@Override void m() {}
	               ^^^
The method m() of type C must override or implement a supertype method


According to the JLS(3) sections 8.4.8.1 and 8.4.8.3, the method m in C overrides the method m in A.


The javac (1.6.0_07) compiler does not raise an error and is in this respect spec-conform.
Comment 1 Kent Johnson CLA 2009-04-06 13:47:45 EDT
Created attachment 131026 [details]
Proposed patch and testcase
Comment 2 Kent Johnson CLA 2009-04-06 15:23:26 EDT
Fix and test released for 3.5M7
Comment 3 Jay Arthanareeswaran CLA 2009-04-28 06:42:46 EDT
Verified for 3.5M7 using build I20090426-2000