Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 489940 - [compiler] wrong error when overriding default interface method in 1.5 project
Summary: [compiler] wrong error when overriding default interface method in 1.5 project
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.6   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-18 09:58 EDT by Markus Keller CLA
Modified: 2020-03-14 19:25 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2016-03-18 09:58:53 EDT
4.6 M6, source: bug 489878

- create a Java project with 1.5 compiler compliance
- add org.eclipse.jface from 4.6 M6 to the build path
- create this class:

package p;

import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.Viewer;

public class MyArrayContentProvider extends ArrayContentProvider {
    @Override
    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        super.inputChanged(viewer, oldInput, newInput);
    }
}

There's a compile error "The method inputChanged(Viewer, Object, Object) of type MyArrayContentProvider must override a superclass method".

I don't get this compile error with Javac:
C:\java\jdk8\bin\javac.exe -bootclasspath C:\java\jdk1.5.0_22\jre\lib\rt.jar -source 5 -target 5 -version -g -Xlint -cp C:\e\w\master\git\eclipse.platform.ui\bundles\org.eclipse.jface\bin -d C:\e\w\master\zz1.5\sunbin -sourcepath C:\e\w\master\zz1.5\src C:\e\w\master\zz1.5\src\p\MyArrayContentProvider.java

The checks before "this.scope.problemReporter().methodMustOverride(..)" in org.eclipse.jdt.internal.compiler.ast.MethodDeclaration#resolveStatements() should accept the method if it's a default method.
Comment 1 Stephan Herrmann CLA 2016-03-18 20:35:24 EDT
It's hard to find the exact JLS as of Java 5 these days, but this seems to match:

"... If a method declaration is annotated with the annotation @Override, but the method does not in fact override any method declared in a superclass, a compile-time error will occur.... Note that if a method overrides a method from 
a superinterface but not from a superclass, using @Override will cause a compile-time error. "


Counting a default method (which doesn't exist in Java 5) as a "method declared in a superclass" sound quite far fetched, if you ask me. Note, that JLS doesn't speak of abstract vs. concrete methods, just about where it is declared. A default method is concrete but it is still declared in an interface.

The error is not *wrong* by any interpretation of JLS that I can see.


Why, to begin with, should we explicitly support combining source code 1.5 with 1.8 super types? To me this doesn't sound like a healthy exercise.
Comment 2 Eclipse Genie CLA 2020-03-14 19:25:25 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.