Bug 485775 - [compiler] Doesn't report cycle inheritance problem which is detected by Oracle JDK
Summary: [compiler] Doesn't report cycle inheritance problem which is detected by Orac...
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.5.1   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2016-01-13 11:19 EST by leokom leokom CLA
Modified: 2022-06-06 13:00 EDT (History)
4 users (show)

See Also:


Attachments
File with no cycle detected by ecj (295 bytes, application/gzip)
2016-08-04 12:17 EDT, Jean-Marie HENAFF CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description leokom leokom CLA 2016-01-13 11:19:53 EST
Let's have 2 classes:

public class First implements Second.SecondInterf {
    interface FirstInterf {

    }
}

public class Second implements First.FirstInterf {
    interface SecondInterf {

    }
}

javac First.java reports error: cyclic inheritance involving Second

While Eclipse compiler silently allows such cycle.
Probably Eclipse compiler should have validation for such situation synchronous with the JDK (because otherwise code that compiles well in Eclipse fails to compile under standalone JDK).

Related discussion on stackoverflow about why Java prohibits such cycle:
http://stackoverflow.com/a/7998053/1429367
Spec:
https://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#jls-8.1.4
Comment 1 Jean-Marie HENAFF CLA 2016-08-04 12:17:34 EDT
Created attachment 263457 [details]
File with no cycle detected by ecj
Comment 2 Jean-Marie HENAFF CLA 2016-08-04 12:20:35 EDT
Reproduced on Linux with latest integration and nightly build (N20160730).

I've attached source files to reproduce the case.

Note that removing the imports make the compilation fail.
Comment 3 Stephan Herrmann CLA 2016-08-04 12:58:44 EDT
Well, the example in comment 0 is rejected by all versions of ecj.
This is in line with javac's behavior and the accepted answer on SO.

The attached project, OTOH, uses imports and simple type references, and hence I don't see X mentioned in its hierarchy. => This program does not violate JLS as quoted in the SO answer.

However, the corresponding JLS section has since been changed from

  as a qualifier of a superclass or superinterface name

to

  as a qualifier in the fully qualified form of a superclass or superinterface name

This change was effective as of Java 7 and should be adopted by ecj.
Comment 4 Stephan Herrmann CLA 2016-08-04 13:01:26 EDT
Also javac 6 accepts the attached example, demonstrating that this was an intented change.
Comment 5 Manoj N Palat CLA 2018-05-17 03:24:39 EDT
bulk move out of 4.8
Comment 6 Manoj N Palat CLA 2018-08-16 00:09:30 EDT
Bulk move out of 4.9
Comment 7 Eclipse Genie CLA 2022-06-06 13:00:32 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.

If you have further information on the current state of the bug, please add it. 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.