Bug 176118 - Missing library classes kill Intellisense without Error
Summary: Missing library classes kill Intellisense without Error
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 M6   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 183508 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-03-01 18:26 EST by Sam Hendley CLA
Modified: 2007-04-24 13:03 EDT (History)
5 users (show)

See Also:


Attachments
TestCase (1.81 KB, application/zip)
2007-03-01 18:28 EST, Sam Hendley CLA
no flags Details
Proposed patch (1016 bytes, patch)
2007-03-20 15:13 EDT, Kent Johnson CLA
no flags Details | Diff
Patch for tests (1.16 KB, patch)
2007-03-20 16:30 EDT, Kent Johnson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sam Hendley CLA 2007-03-01 18:26:14 EST
I have found what I consider to be a bug in how Eclipse 3.2.1 handles libraries with missing classes. What I've been able to determine is that when a library class references a missing class the intellisense and other code aware editor features stop functioning (Add unimplemented methods as an example).

Ideally the editor features would just continue despite the broken library so the other, valid, classes can be found but I know that might be difficult. I think at a minimum an Error should be posted to the error log so that the user has some idea of whats going wrong and what classes he needs to find or fake to fix it.

The reason this problem came up is that RIM's library is missing at least one class referenced in an interface that is implemented in the "MainScreen" class. This means that while we are developing we have no smart editor functions inside any Screen based Class (which is quite a few of them). I have no intention of ever trying to implement the interface with the issue (which I couldn't anyways because I am missing a class) but since the classes I have to use are dependent on it it still breaks my dev environment.

I have produced a minimal test case with comments detailing some of these problems but I don't see any place to attach a file, ill commit this bug and then add the project (only 5 files).
Comment 1 Sam Hendley CLA 2007-03-01 18:28:24 EST
Created attachment 60122 [details]
TestCase

Comments in Test.java should show the issues
Comment 2 Dani Megert CLA 2007-03-02 04:06:36 EST
Looks like a duplicate of bug 164266.
Comment 3 Philipe Mulet CLA 2007-03-02 11:30:41 EST
Kent - shouldn't this be supported using our missing binary type support ?
Comment 4 Sam Hendley CLA 2007-03-02 11:38:22 EST
Just an update, there is an error log if the missing classes are directly related to the current class. I was seeing some "Java model errors" for a class I was extended over. The situation in this case the missing classes were inner classes of Screen. When I tried to do the intellisense I would get two error messages for these two missing classes. It was what I was hoping could be done in the other situation as it made patching the library much easier.
Thanks.

class A extends Screen{}
lib: 
class Screen{
   class innerClass1{}
   class innerClass2{}
   class missingClass1{}
   class missingClass2{}
}
Comment 5 Kent Johnson CLA 2007-03-05 15:13:03 EST
Philippe - our missing binary type support doesn't kick in, because the referenced types are found as source types & not binary types.

We would need to change the o.e.jdt.internal.core.SearchableEnvironment & NameLookup to find binary types instead of source types for any referenced types that are not currently being modified in working copies.

I do find it odd that the PackageFragment for a package in a prereq project is picked up a source package & not a binary package.
Comment 6 Kent Johnson CLA 2007-03-19 16:03:42 EDT
Jerome - Can o.e.jdt.internal.core.SearchableEnvironment & NameLookup find binary types instead of source types in cases like this one ?
Comment 7 Jerome Lanneluc CLA 2007-03-20 12:43:08 EDT
(In reply to comment #6)
> Jerome - Can o.e.jdt.internal.core.SearchableEnvironment & NameLookup find
> binary types instead of source types in cases like this one ?
> 
Note this comment applies to bug 164266. Moving this comment there.
Comment 8 Jerome Lanneluc CLA 2007-03-20 14:12:14 EDT
For this sepcific bug, I'm getting which might explain the silent failure.
(Kent back to you.)

!ENTRY org.eclipse.jdt.core 4 4 2007-03-20 19:09:48.806
!MESSAGE Could not retrieve declared methods
!STACK 0
org.eclipse.jdt.internal.compiler.problem.AbortCompilation
	at org.eclipse.jdt.internal.compiler.problem.ProblemHandler.handle(ProblemHandler.java:97)
	at org.eclipse.jdt.internal.compiler.problem.ProblemHandler.handle(ProblemHandler.java:153)
	at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.handle(ProblemReporter.java:1727)
	at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.isClassPathCorrect(ProblemReporter.java:3520)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.cacheMissingBinaryType(LookupEnvironment.java:178)
	at org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(UnresolvedReferenceBinding.java:46)
	at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(BinaryTypeBinding.java:131)
	at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveTypesFor(BinaryTypeBinding.java:893)
	at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.methods(BinaryTypeBinding.java:874)
	at org.eclipse.jdt.core.dom.TypeBinding.getDeclaredMethods(TypeBinding.java:266)
	at org.eclipse.jdt.internal.corext.dom.Bindings.findOverriddenMethodInType(Bindings.java:423)
	at org.eclipse.jdt.internal.corext.dom.Bindings.findOverriddenMethodInHierarchy(Bindings.java:440)
	at org.eclipse.jdt.internal.corext.dom.Bindings.findOverriddenMethod(Bindings.java:483)
	at org.eclipse.jdt.internal.ui.javaeditor.OverrideIndicatorManager$1.visit(OverrideIndicatorManager.java:179)
	at org.eclipse.jdt.core.dom.MethodDeclaration.accept0(MethodDeclaration.java:486)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2476)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2546)
	at org.eclipse.jdt.core.dom.TypeDeclaration.accept0(TypeDeclaration.java:483)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2476)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2546)
	at org.eclipse.jdt.core.dom.CompilationUnit.accept0(CompilationUnit.java:213)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2476)
	at org.eclipse.jdt.internal.ui.javaeditor.OverrideIndicatorManager.updateAnnotations(OverrideIndicatorManager.java:172)
	at org.eclipse.jdt.internal.ui.javaeditor.OverrideIndicatorManager.reconciled(OverrideIndicatorManager.java:251)
	at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.reconciled(CompilationUnitEditor.java:1572)
	at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:137)
	at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.initialReconcile(JavaReconcilingStrategy.java:176)
	at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.initialReconcile(CompositeReconcilingStrategy.java:114)
	at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.initialReconcile(JavaCompositeReconcilingStrategy.java:122)
	at org.eclipse.jface.text.reconciler.MonoReconciler.initialProcess(MonoReconciler.java:103)
	at org.eclipse.jdt.internal.ui.text.JavaReconciler.initialProcess(JavaReconciler.java:332)
	at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:170)
Comment 9 Jerome Lanneluc CLA 2007-03-20 14:19:46 EDT
Sam, to clarify: the code assist (what you call intellisense) failing silently is fixed in the 3.3 stream. However the "Add uninplemented methods" silent failure is still present in the 3.3 stream and is due to the stack trace I just reported.
Comment 10 Kent Johnson CLA 2007-03-20 14:23:13 EDT
The exception is thrown because there is no referenceContext for the
ProblemHandler.
Comment 11 Kent Johnson CLA 2007-03-20 14:59:16 EDT
The ProblemHandler's referenceContext comes from the LookupEnvironment's unitBeingCompleted.

We null out the LookupEnvironment's unitBeingCompleted at the end of Compiler.resolve(), which is called during the reconcile loop.

We need to leave it set to the last unit since the binary types can be accessed thru the dom afterwards.
Comment 12 Kent Johnson CLA 2007-03-20 15:13:23 EDT
Created attachment 61447 [details]
Proposed patch

Do we want to release this change for M6 or wait for M7?
Comment 13 Kent Johnson CLA 2007-03-20 16:30:22 EDT
Created attachment 61459 [details]
Patch for tests

Need to fixup expected results for bug 173338

ASTConverter15Test test0239() & test0240()
Comment 14 Philipe Mulet CLA 2007-03-21 12:49:50 EDT
I think the fix is good.
If we recontribute for M6, and tests are fine, then I would put it in.
Comment 15 Kent Johnson CLA 2007-03-21 13:21:59 EDT
Released to HEAD
Comment 16 Frederic Fusier CLA 2007-03-21 13:59:52 EDT
Adding missing comment to have this bug in our verification list:
Released for 3.3 M6
Comment 17 Jerome Lanneluc CLA 2007-03-22 13:18:57 EDT
Kent could you please backport this fix in R3_2_maintenance ?
Comment 18 Kent Johnson CLA 2007-03-22 15:53:51 EDT
Backported to R3_2_maintenance
Comment 19 Kent Johnson CLA 2007-04-24 13:03:34 EDT
*** Bug 183508 has been marked as a duplicate of this bug. ***