Community
Participate
Working Groups
The following stack trace pops up in 'Problems view' in RC2, for a pretty large project. Tried to gradually exclude the problematic files from the classpath, but then usually stuck at another one. One common pattern I found in those files is anonymous inner classes within constructor calls: interface I { void foo(); } class C { I i; C(I i) { this.i = i;} ..... }; void bar() { C c = new C(new I() { void foo() { ....} }); } I didn't get the error in RC1. ----------------------------------- Internal compiler error java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.lookup.MemberTypeBinding at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:477) at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:465) at org.eclipse.jdt.internal.compiler.Compiler.accept(Compiler.java:190) at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:99) at org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(UnresolvedReferenceBinding.java:43) at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(BinaryTypeBinding.java:85) at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveTypeFor(BinaryTypeBinding.java:742) at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.getField(BinaryTypeBinding.java:598) at org.eclipse.jdt.internal.compiler.lookup.Scope.findField(Scope.java:743) at org.eclipse.jdt.internal.compiler.lookup.MethodScope.findField(MethodScope.java:337) at org.eclipse.jdt.internal.compiler.lookup.BlockScope.getBinding(BlockScope.java:439) at org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference.resolveType(QualifiedNameReference.java:840) at org.eclipse.jdt.internal.compiler.ast.AllocationExpression.resolveType(AllocationExpression.java:290) at org.eclipse.jdt.internal.compiler.ast.AllocationExpression.resolveType(AllocationExpression.java:290) at org.eclipse.jdt.internal.compiler.ast.AllocationExpression.resolveType(AllocationExpression.java:290) at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:291) at org.eclipse.jdt.internal.compiler.ast.Expression.resolve(Expression.java:829) at org.eclipse.jdt.internal.compiler.ast.Block.resolve(Block.java:101) at org.eclipse.jdt.internal.compiler.ast.IfStatement.resolve(IfStatement.java:225) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:415) at org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration.resolveStatements(ConstructorDeclaration.java:435) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:393) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1063) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1112) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:305) at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:504) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:329) at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:240) at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:213) at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.build(BatchImageBuilder.java:50) at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildAll(JavaBuilder.java:213) at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:136) at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:593) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1038) at org.eclipse.core.runtime.Platform.run(Platform.java:775) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:168) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:202) at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:231) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1038) at org.eclipse.core.runtime.Platform.run(Platform.java:775) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:234) at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:253) at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:282) at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:139) at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:200) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:76)
If you could provide a complete test case even if it is big, it would be great.
Getting a test case might be the only way to get it fixed for 3.1.
Lowering severity. It cannot be a blocker without good steps to reproduce at this stage.
Found a case if a project has a large number of source files (> 1000). In separate files & with AbstractImageBuilder.MAX_AT_ONCE set to 1. class A { Object foo(B b) { return b.i; } } class B { I.InnerType i; } interface I { interface InnerType {} } Turn off auto-builds & touch both A.java & I.java, then manually build causes the following stack trace: java.lang.ClassCastException: o.e.j.i.c.lookup.MemberTypeBinding at o.e.j.i.c.lookup.LookupEnvironment.createBinaryTypeFrom (LookupEnvironment.java:476) at o.e.j.i.c.lookup.LookupEnvironment.createBinaryTypeFrom (LookupEnvironment.java:465) at o.e.j.i.c.Compiler.accept(Compiler.java:190) at o.e.j.i.c.lookup.LookupEnvironment.askForType(LookupEnvironment.java:99) at o.e.j.i.c.lookup.UnresolvedReferenceBinding.resolve (UnresolvedReferenceBinding.java:43) at o.e.j.i.c.lookup.BinaryTypeBinding.resolveType(BinaryTypeBinding.java:85) at o.e.j.i.c.lookup.BinaryTypeBinding.resolveTypeFor (BinaryTypeBinding.java:742) at o.e.j.i.c.lookup.BinaryTypeBinding.getField(BinaryTypeBinding.java:598) at o.e.j.i.c.lookup.Scope.findField(Scope.java:749)
Fix is to LookupEnvironment.createBinaryType public BinaryTypeBinding createBinaryTypeFrom(IBinaryType binaryType, PackageBinding packageBinding, boolean needFieldsAndMethods, AccessRestriction accessRestriction) { BinaryTypeBinding binaryBinding = new BinaryTypeBinding (packageBinding, binaryType, this); // resolve any array bindings which reference the unresolvedType ReferenceBinding cachedType = packageBinding.getType0 (binaryBinding.compoundName[binaryBinding.compoundName.length - 1]); if (cachedType != null) { // update reference to unresolved binding after having read classfile (knows whether generic for raw conversion) if (cachedType instanceof UnresolvedReferenceBinding) { ((UnresolvedReferenceBinding) cachedType).setResolvedType(binaryBinding, this); } else { if (cachedType.isBinaryBinding()) // sanity check... at this point the cache should ONLY contain unresolved types return (BinaryTypeBinding) cachedType; // it is possible with a large number of source files (exceeding AbstractImageBuilder.MAX_AT_ONCE) that a member type can be in the cache as an UnresolvedType, // but because its enclosingType is resolved while its created (call to BinaryTypeBinding constructor), its replaced with a source type return null; } } packageBinding.addType(binaryBinding); setAccessRestriction(binaryBinding, accessRestriction); binaryBinding.cachePartsFrom(binaryType, needFieldsAndMethods); return binaryBinding; }
*** Bug 99892 has been marked as a duplicate of this bug. ***
Kent isolated it. This issue is a consequence of fix for bug 97108. Basically, it needs to get fixed for RC4, since we may have issues on large source workspaces, and it isn't 1.5 specific. Kent - pls send patch to reporter to assess it fixes the problem; and attach a CVS patch. Dirk - can you vote for it ?
Dani - can you vote for it ?
Created attachment 23647 [details] Patch to LookupEnvironment
One question that will come up is whether its ok to answer null... If you check the senders of createBinaryTypeFrom(), you'll see the return value is not used or is checked to see if its null. We could change the return type of the method, but that would be more a change than is necessary at this point.
I can confirm, that the project I tried to compile under Eclipse 3.1 is pretty big. It is about 4k classes in one source folder.
+1 for 3.1 RC4. Agree with Kent to keep the changes at a minimum at this point.
+1 for RC4.
(In reply to comment #9) > Created an attachment (id=23647) [edit] > Patch to LookupEnvironment > Great news: it does fix it!(at least, I run the patched JDT core with self-hosting eclipse, and no stack trace in the Problems view with the same big project). Although I've already spent some time isolating&cleaning the test project before I send you as a test case(not really obfuscating,just to calm down boss;),it feels much better this way, thanks!
I relplaced jdt.core jar in my Eclipse 3.1 RC3 with patched one sent by Kent to me yesterday and it solved the problem. No more nasty errors in Java Builder. Unfortunately I got another error "Error in JDT Core during AST creation". I'm creating new issue in bugzilla right now. This new error refers other classes than the previous one.
Kent - pls provide a regression test
Added IncrementalTests testMemberTypeCollisionWithBinary(). Released change into HEAD for RC4.
Verified for Build id: I20050624-0010. (Checked that the regression test case failed with I20050617-1618, raising a problem similar to the problem which triggered the bug; checked that the same regression test case passed with I20050624-0010.)
Verified.
Verified ages ago -sorry for the late update.