Bug 35899 - "hierarchy of type ... inconsistent" error message wronge
Summary: "hierarchy of type ... inconsistent" error message wronge
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: All All
: P3 minor (vote)
Target Milestone: 3.0 M5   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-03-31 19:59 EST by Eitan Mendelowitz CLA
Modified: 2003-11-20 09:59 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 Eitan Mendelowitz CLA 2003-03-31 19:59:50 EST
Eclipse is marking a number of classes (all derived in a chain) by underlining the class name in red.  On MouseOver the box reads "The hierarchy or type XXX is inconsistent"  (where XXX is the class).  However the classes themselves are not marked in the package explorer (no red x's on the classes or the packages).  Further the classes seem to work fine.

I have no idea what is causing the error message but either eclipse is in error or the message should really be a warning (since the .java files still compile).

This behavior has been observered on Mac OS and Windows (I can't comment on the other platforms).
Comment 1 Philipe Mulet CLA 2003-04-01 04:24:36 EST
Can you provide a testcase which would reproduce this ?
Comment 2 Eitan Mendelowitz CLA 2003-04-07 19:41:29 EDT
Thank you for your quick response (and sorry for my slow response - its been a bad week).

Unfortunately, are code base is quite large and we are not ready to release it (although we do plan on open sourcing it when we are done).

Can you tell me what the error is supposed to mean?  (ie when the error is supposed to be generated?)  Maybe I can try to replicate the error after knowing what is supposed to be happening and looking at our code.
Comment 3 Philipe Mulet CLA 2003-04-08 05:06:54 EDT
Inconsistent hierarchies are diagnosed when some superclass/superinterface 
links are not resolvable. Could be a classpath problem ?
Comment 4 Eitan Mendelowitz CLA 2003-04-08 20:52:43 EDT
Hmm.  Currently the class that exhibits this problem is in the same package as its parent.  If I put the class in another package and import the origional package the problem disappears.

I still can't figure out what it is about this class in particular that is cuasing the problem (but I'm looking).
Comment 5 Philipe Mulet CLA 2003-04-15 03:26:29 EDT
Could you attach this testcase for investigation ?
Comment 6 Kent Johnson CLA 2003-04-21 09:34:08 EDT
Any chance one of the supertypes is a secondary type?

ie. is it a non-public type B defined in another file A.java such as:

p1/A.java

package p1;
class B {}

If so try moving the type B to its own file named p1/B.java.
Comment 7 Eitan Mendelowitz CLA 2003-04-21 11:58:17 EDT
>Any chance one of the supertypes is a secondary type?

Unfortunatly not.  I've been trying to replicate the problem in simpler code but I can't seem to do 
it.

The classes look like this.

package p1
public abstract class A 

package p2
public interface B 
Comment 8 Eitan Mendelowitz CLA 2003-04-21 12:05:34 EDT
I'm not sure why but my submission was cut off.  Here is the rest of the the classes.

package P1
imports P2.*
public class C extends a implements b

package P1
public class D extends C

"D" is the one that gets underlined in red and the error message.  When I've replicated the 
sturcture I don't get any error message.  I've been trying to find the root by removing methods 
from our code but I havne't been able to figure it out yet.



Comment 9 Kent Johnson CLA 2003-04-22 09:51:08 EDT
So how many types are there in the problematic hierarchy?

Are there any secondary types or member types in the hierarchy?

Are all the types public & located in their own files?

If you copy the types into a separate project (in the same source folders, 
packages, files), is the problem reproduceable?
Comment 10 Kent Johnson CLA 2003-04-24 13:33:04 EDT
Eitan: Can you provide any other info?
Comment 11 Kent Johnson CLA 2003-05-06 15:44:37 EDT
Please reopen when you can provide more information.
Comment 12 Eitan Mendelowitz CLA 2003-05-06 15:57:36 EDT
I'm still trying to replicate the problem on something other than our entire code base.  Thanks for 
your contimuned interest/atttention.
Comment 13 Eitan Mendelowitz CLA 2003-05-06 17:59:47 EDT
Ok, I figured it out -FINALLY.  The problem arises when a class uses a derived class internally.  It 
sounds fishy but it is allowed by Java (at least it compiles and runs)  Eclipse underlines any derived 
class in red (but doesn't mark the class with a "x")

Here is a code snippet that replicates the problem.  Class B is the one with the erroneous red 
underline.

---
public class ClassA {
  public ClassA() {
  }
  private class ClassC extends ClassB {
  }
}

public class ClassB extends ClassA {
  public ClassB(){}
}
Comment 14 Kent Johnson CLA 2003-05-07 13:42:16 EDT
Found the problem... thanks Eitan.

Here's a stack trace:

Thread [org.eclipse.jdt.internal.ui.text.JavaReconciler] (Suspended (breakpoint 
at line 221 in LookupEnvironment))

LookupEnvironment.completeTypeBindings(CompilationUnitDeclaration, boolean) 
line: 221
CompilationUnitProblemFinder.accept(ISourceType[], PackageBinding) line: 109
LookupEnvironment.askForType(PackageBinding, char[]) line: 106
PackageBinding.getTypeOrPackage(char[]) line: 173
CompilationUnitScope(Scope).getTypeOrPackage(char[], int) line: 1321
ClassScope.findSupertype(TypeReference) line: 789
ClassScope.connectSuperclass() line: 582
ClassScope.connectTypeHierarchy() line: 675
CompilationUnitScope.connectTypeHierarchy() line: 252
LookupEnvironment.completeTypeBindings() line: 170
CompilationUnitProblemFinder(Compiler).resolve(CompilationUnitDeclaration, 
ICompilationUnit, boolean, boolean, boolean) line: 583
CompilationUnitProblemFinder.process(CompilationUnitDeclaration, 
ICompilationUnit, IProblemRequestor, IProgressMonitor) line: 219
WorkingCopy.generateInfos(OpenableElementInfo, IProgressMonitor, Map, 
IResource) line: 174


LookupEnvironment.completeTypeBindings(CompilationUnitDeclaration, boolean) is 
being called when it shouldn't... this is the method comment:

/*
* Used by other compiler tools which do not start by calling 
completeTypeBindings().
*
* 1. Connect the type hierarchy for the type bindings created for parsedUnits.
* 2. Create the field bindings
* 3. Create the method bindings
*/

We end up trying to connect the hierarchy of type A & as a result its member 
type C WHILE we are in the middle of connecting the hierarchy of type B.

This does not happen during a normal compile loop since we do not connect the 
member types of type A until type B is finished.

CompilationUnitProblemFinder.accept should instead call 
LookupEnvironment.completeTypeBindings(CompilationUnitDeclaration parsedUnit) 
since CompilationUnitProblemFinder.process calls 
LookupEnvironment.completeTypeBindings(). I released this change.

There are 15 other senders that should be double checked to see if they're 
also 'broken' (such as the MatchLocator)... moving to Jerome.
Comment 15 Kent Johnson CLA 2003-10-23 12:32:44 EDT
This was taken care of a while ago.
Comment 16 David Audel CLA 2003-11-20 09:59:01 EST
Verified.