Bug 224402 - [compiler] CCE in compiler: MissingTypeBinding cannot be cast to ProblemReferenceBinding
Summary: [compiler] CCE in compiler: MissingTypeBinding cannot be cast to ProblemRefer...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M7   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-27 11:55 EDT by Markus Keller CLA
Modified: 2008-04-28 11:05 EDT (History)
3 users (show)

See Also:


Attachments
Workaround (1.17 KB, patch)
2008-03-29 10:33 EDT, Philipe Mulet CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2008-03-27 11:55:09 EDT
I20080327-0100

I tried to clean my workspace and do a full build, but it always resulted in thousands of strange compile errors (java.lang.Object not found, etc.).

Compilation was fine again when I switched back to I20080326-1950.

This was in the log:

Error
Thu Mar 27 16:49:17 CET 2008
Problems occurred when invoking code from plug-in: "org.eclipse.core.resources".

java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.lookup.MissingTypeBinding cannot be cast to org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding
	at org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference.findNextTypeBinding(QualifiedTypeReference.java:46)
	at org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference.getTypeBinding(QualifiedTypeReference.java:83)
	at org.eclipse.jdt.internal.compiler.ast.TypeReference.internalResolveType(TypeReference.java:130)
	at org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveType(TypeReference.java:197)
	at org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.resolve(LocalDeclaration.java:138)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:444)
	at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:191)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:403)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1096)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1184)
	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:535)
	at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:686)
	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:441)
	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:362)
	at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.compile(BatchImageBuilder.java:175)
	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:299)
	at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.build(BatchImageBuilder.java:59)
	at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildAll(JavaBuilder.java:253)
	at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:172)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:633)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:170)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:201)
	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:253)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:256)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:309)
	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:341)
	at org.eclipse.core.internal.resources.Workspace.build(Workspace.java:330)
	at org.eclipse.ui.actions.GlobalBuildAction$1.run(GlobalBuildAction.java:181)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Comment 1 Markus Keller CLA 2008-03-27 11:59:44 EDT
Hm, going back to I20080326-1950 did not really help, now get tons of these in the log:

org.eclipse.jdt.internal.compiler.problem.AbortCompilation
	at org.eclipse.jdt.internal.compiler.problem.ProblemHandler.handle(ProblemHandler.java:121)
	at org.eclipse.jdt.internal.compiler.problem.ProblemHandler.handle(ProblemHandler.java:179)
	at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.handle(ProblemReporter.java:1830)
	at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.isClassPathCorrect(ProblemReporter.java:3702)
	at org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(UnresolvedReferenceBinding.java:54)
	at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(BinaryTypeBinding.java:101)
	at org.eclipse.jdt.internal.compiler.lookup.PackageBinding.getType(PackageBinding.java:137)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.findType(Scope.java:1382)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.getTypeOrPackage(Scope.java:2468)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.getType(Scope.java:2169)
	at org.eclipse.jdt.internal.compiler.ast.SingleTypeReference.getTypeBinding(SingleTypeReference.java:44)
	at org.eclipse.jdt.internal.compiler.ast.TypeReference.internalResolveType(TypeReference.java:130)
	at org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveType(TypeReference.java:197)
	at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.resolveTypesFor(SourceTypeBinding.java:1408)
	at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.methods(SourceTypeBinding.java:1106)
	at org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.availableMethods(ReferenceBinding.java:174)
	at org.eclipse.jdt.core.dom.TypeBinding.getDeclaredMethods(TypeBinding.java:233)
	at org.eclipse.jdt.internal.corext.dom.Bindings.findOverriddenMethodInType(Bindings.java:439)
	at org.eclipse.jdt.internal.corext.dom.Bindings.findOverriddenMethodInHierarchy(Bindings.java:456)
	at org.eclipse.jdt.internal.corext.dom.Bindings.findOverriddenMethodInHierarchy(Bindings.java:467)
	at org.eclipse.jdt.internal.corext.dom.Bindings.findOverriddenMethodInHierarchy(Bindings.java:461)
	at org.eclipse.jdt.internal.corext.dom.Bindings.findOverriddenMethodInHierarchy(Bindings.java:461)
	at org.eclipse.jdt.internal.corext.dom.Bindings.findOverriddenMethod(Bindings.java:490)
	at org.eclipse.jdt.internal.ui.javaeditor.OverrideIndicatorManager$1.visit(OverrideIndicatorManager.java:181)
	at org.eclipse.jdt.core.dom.MethodDeclaration.accept0(MethodDeclaration.java:486)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2478)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2548)
	at org.eclipse.jdt.core.dom.TypeDeclaration.accept0(TypeDeclaration.java:483)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2478)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2548)
	at org.eclipse.jdt.core.dom.CompilationUnit.accept0(CompilationUnit.java:213)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2478)
	at org.eclipse.jdt.internal.ui.javaeditor.OverrideIndicatorManager.updateAnnotations(OverrideIndicatorManager.java:174)
	at org.eclipse.jdt.internal.ui.javaeditor.OverrideIndicatorManager.reconciled(OverrideIndicatorManager.java:253)
	at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.reconciled(CompilationUnitEditor.java:1617)
	at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconciled(JavaReconcilingStrategy.java:210)
	at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconciled(JavaCompositeReconcilingStrategy.java:161)
	at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:110)
	at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:77)
	at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:206)
Comment 2 Frederic Fusier CLA 2008-03-27 12:57:51 EDT
I cannot reproduce using I20080327-0100 and perform a Project->Clean..->Clean all projects on a Eclipse 3.4 full-source workspace...
Any hints to help us to reproduce?
Comment 3 Olivier Thomann CLA 2008-03-27 13:03:21 EDT
Looking at the source code, it seems possible to get a CCE, so we should protect this path.
The workspace needs to contain missing types in order to be able to reproduce this issue.
Comment 4 Philipe Mulet CLA 2008-03-27 13:05:14 EDT
Strange though, as this code hasn't changed in a while... so there would be something else to cause some missing types to appear...

Anyway, Markus a testcase is still welcome.
Comment 5 Markus Keller CLA 2008-03-27 13:30:22 EDT
My workspace is 100% error-free. I just tried to compile it again with I20080327-0100 (and I20080327-0100 as Target Platform), and I didn't get the exceptions any more.

However, I got 3 errors like these when the build was done:
 
- The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project	org.eclipse.ui.examples.job		Unknown	Java Problem

- The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files	SlowElementAdapter.java	org.eclipse.ui.examples.job/src/org/eclipse/ui/examples/jobs/views	line 1	Java Problem

I occasionally get into such a state, but I have never found steps to reproduce in a fresh workspace.
Comment 6 Olivier Thomann CLA 2008-03-27 16:15:01 EDT
In fact all check for isValidBinding() are not sufficient anymore to cast into a ProblemReferenceBinding.
Comment 7 Philipe Mulet CLA 2008-03-29 10:32:20 EDT
That was already the case since 3.3, where we had invalid binding for missing binary type.

Normally this code path should always reach the point where a ProblemReferenceBinding is surfaced. This doesn't seem the case always, and working around here may hide the real issue elsewhere.
Comment 8 Philipe Mulet CLA 2008-03-29 10:33:41 EDT
Created attachment 94104 [details]
Workaround
Comment 9 Philipe Mulet CLA 2008-04-09 07:02:35 EDT
Will release the workaround for M7, since it is a trivial fix, but there is no steps to reproduce so this will not be easy to verify.

Markus - can we rely on you to tell whether this is fixed ?

Released for 3.4M7.
Fixed
Comment 10 Markus Keller CLA 2008-04-09 08:19:24 EDT
(In reply to comment #9)
> Markus - can we rely on you to tell whether this is fixed ?

Unfortunately not. I've only had the CCE once, and never since. Usually, compilation works fine, but occasionally I get into the trouble of comment 5 (mostly when I start up with a new build and the changed target platform triggers a full build).
Comment 11 Jerome Lanneluc CLA 2008-04-28 11:05:01 EDT
I have verified for 3.4M7 that the workaround is present in I20080427-2000