Bug 8980 - Unpredictable error catching on overridden methods with less visibility
Summary: Unpredictable error catching on overridden methods with less visibility
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.0 M3   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-02-01 16:14 EST by Charles Oliver Nutter CLA
Modified: 2002-02-07 07:29 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Charles Oliver Nutter CLA 2002-02-01 16:14:19 EST
In one project of mine, Eclipse seemed to compile all code correctly, where 
Sun's JDK 1.3.1_02 compiler caught an error described below.

According to the Java Language Spec, section 8.4.6.3:

The access modifier (ยง6.6) of an overriding or hiding method must provide at 
least as much access as the overridden or hidden method, or a compile-time 
error occurs. 

In my case, the error was when a method that was public in the superclass was 
overridden with default access. I altered the overrides to be public as well, 
and the command-line errors went away.

Unfortunately, when I changed them back to reproduce it later, it caught the 
error. Hence its unpredictable nature.

A bug like this could cause some serious issues when the JVM tries to access 
the subclass that has quietly reduced the visibility of an overridden method.

This was running Eclipse 2.O-pre, build 20011219. I have not tried it on a more 
recent build, because it would not duplicate on this one. It might be worth a 
look.
Comment 1 Philipe Mulet CLA 2002-02-01 18:29:57 EST
For the following test case, I am getting the expected error:

class X {
  public void foo(){}
}

class Y extends X {
  void foo(){}
}

Report for 1 markers:
Marker 1:
  Resource: /Crap/src/X.java, Line: 15
  Message: Cannot reduce the visibility of the inherited method from X
  Marker type: org.eclipse.jdt.core.problem
  Priority: Normal

Please provide a reproduceable test case for us to investigate any further.
Comment 2 Philipe Mulet CLA 2002-02-07 07:29:32 EST
Cannot reproduce, closing, please reopen if you can reproduce it.