| Summary: | Incorrect cycle detected in type hierarchy | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Tobias Riemenschneider <tobys> | ||||
| Component: | Core | Assignee: | Stephan Herrmann <stephan.herrmann> | ||||
| Status: | VERIFIED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | manoj.palat, pouiller.gitblit, register.eclipse, stephan.herrmann, wHack23 | ||||
| Version: | 4.7.1a | ||||||
| Target Milestone: | 4.7.3 | ||||||
| Hardware: | PC | ||||||
| OS: | Windows 7 | ||||||
| See Also: |
https://git.eclipse.org/r/110811 https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=a2ee843b668ecf9aca7c99300671ad9c2845690b https://git.eclipse.org/r/116554 https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=b1c2a63442229d51e669de6df7b1c9d0e7e3af64 |
||||||
| Whiteboard: | regression | ||||||
| Attachments: |
|
||||||
ecj 4.7.1 still accepts the program.
Starting from 4.7.1a we get:
----------
1. ERROR in /tmp/OuterClass.java (at line 3)
public class OuterClass<T> extends ArrayList<OuterClass.InnerTypedClass<T>> {
^^^^^^^^^^
The hierarchy of the type OuterClass is inconsistent
----------
2. WARNING in /tmp/OuterClass.java (at line 3)
public class OuterClass<T> extends ArrayList<OuterClass.InnerTypedClass<T>> {
^^^^^^^^^^
The serializable class OuterClass does not declare a static final serialVersionUID field of type long
----------
3. ERROR in /tmp/OuterClass.java (at line 7)
public static class InnerTypedClass<T> implements InnerInterface {}
^^^^^^^^^^^^^^
Cycle detected: a cycle exists in the type hierarchy between OuterClass.InnerTypedClass<T> and OuterClass<T>
----------
3 problems (2 errors, 1 warning)
Should search the commit that caused this to change, but unfortunately there's a huge number of commits between .1 and .1a
I bisected this to commit 68640a1ceae6bddcdd1ba7a60e1aa3feddb7585a on behalf of: Bug 520874: [compiler] difference in behavior in single static import and on-demand Fix to report nested types being part of a inheritance cycle. Maybe the change was intended after all? @Jay? The problem goes away with the pending fix in bug 526681 :) *** This bug has been marked as a duplicate of bug 526681 *** After bug 526681 was proven invalid by reasoning according to JLS ยง8.1.4, this bug remains to be investigated. According to 8.1.4 we have InnerTypedClass<T> implements OuterClass.InnerInterface => InnerTypedClass depends on OuterClass, InnerInterface OuterClass<T> extends ArrayList<OuterClass.InnerTypedClass<T>> => OuterClass depends on ArrayList I see nothing in JLS that would let a type argument participate in cycle detection, but it seems that is what ecj is doing. (In reply to Stephan Herrmann from comment #4) > I see nothing in JLS that would let a type argument participate in cycle > detection, but it seems that is what ecj is doing. TypeReference.resolveTypeArgument() was already trying to prevent this (PauseHierarchyCheck) but in nested invocations we were resetting the flag too soon. => Only reset what we actually set in the first place. I re-purposed the existing gerrit for this bug and made the test from bug 52668 a negative test: https://git.eclipse.org/r/#/c/110811/ Bug 495953 also has an example of a bogus cycle reported when type variables are reported. (In reply to Till Brychcy from comment #6) > Bug 495953 also has an example of a bogus cycle reported when type variables > are reported. I meant "where type variables are involved." Gerrit change https://git.eclipse.org/r/110811 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=a2ee843b668ecf9aca7c99300671ad9c2845690b (In reply to Eclipse Genie from comment #8) > Gerrit change https://git.eclipse.org/r/110811 was merged to [master]. > Commit: > http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/ > ?id=a2ee843b668ecf9aca7c99300671ad9c2845690b Released to master for 4.8 M4 Bug stays open for back port. New Gerrit change created: https://git.eclipse.org/r/116554 (In reply to Eclipse Genie from comment #10) > New Gerrit change created: https://git.eclipse.org/r/116554 Tests fail due to bug 530634 Gerrit change https://git.eclipse.org/r/116554 was merged to [R4_7_maintenance]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=b1c2a63442229d51e669de6df7b1c9d0e7e3af64 (In reply to Eclipse Genie from comment #12) > Gerrit change https://git.eclipse.org/r/116554 was merged to > [R4_7_maintenance]. > Commit: > http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/ > ?id=b1c2a63442229d51e669de6df7b1c9d0e7e3af64 Released for 4.7.3 Verified for Eclipse Oxygen.3 (4.7.3) with Build id: M20180207-1700 *** Bug 454053 has been marked as a duplicate of this bug. *** |
Created attachment 271633 [details] Example code triggering the defect. When switching from Eclipse Neon to Eclipse Oxygen JDT starts complaining about a detected cycle in the type hierarchy. Eclipse Neon as well as Oracle JDK 1.7, 1.8 and 9) are fine with the classes (with respect to compilation and execution). The defect occurs when we have a typed class OuterClass with a static inner interface InnerInterface and a typed static inner class InnerTypedClass implementing InnerInterface and OuterClass extends another class that is typed with InnerTypedClass (see attachment).