Community
Participate
Working Groups
In a project I get the following error located in one specific java file. If I remove (move from file system) the java file from the project, save/compile the project and then add the file to the project again the error is gone and the java file compiles (a *.class file is generated) until I recompile the whole project, then the error is back... The error appears in both Eclipse 3.1M4 and 3.1M5a The java file is compile-able using javac in a command prompt. Severity Description Resource In Folder Location Creation Time 2 Internal compiler error java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.lookup.FieldBinding at org.eclipse.jdt.internal.compiler.lookup.Scope.getType (Scope.java:2132) at org.eclipse.jdt.internal.compiler.ast.SingleTypeReference.getTypeBinding (SingleTypeReference.java:39) at org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveType (TypeReference.java:124) at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.resolveTypesFor (SourceTypeBinding.java:1122) at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.getMethods (SourceTypeBinding.java:798) at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.getExactMethod (SourceTypeBinding.java:730) at org.eclipse.jdt.internal.compiler.lookup.Scope.findExactMethod (Scope.java:646) at org.eclipse.jdt.internal.compiler.lookup.Scope.getMethod (Scope.java:2054) at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType (MessageSend.java:312) at org.eclipse.jdt.internal.compiler.ast.Assignment.resolveType (Assignment.java:180) at org.eclipse.jdt.internal.compiler.ast.Expression.resolve (Expression.java:779) at org.eclipse.jdt.internal.compiler.ast.Statement.resolveCase (Statement.java:132) at org.eclipse.jdt.internal.compiler.ast.SwitchStatement.resolve (SwitchStatement.java:256) at org.eclipse.jdt.internal.compiler.ast.Block.resolve(Block.java:101) at org.eclipse.jdt.internal.compiler.ast.IfStatement.resolve (IfStatement.java:227) at org.eclipse.jdt.internal.compiler.ast.Block.resolveUsing (Block.java:115) at org.eclipse.jdt.internal.compiler.ast.TryStatement.resolve (TryStatement.java:502) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatement s(AbstractMethodDeclaration.java:411) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements (MethodDeclaration.java:160) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve (AbstractMethodDeclaration.java:389) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve (TypeDeclaration.java:1019) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve (TypeDeclaration.java:1068) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve (CompilationUnitDeclaration.java:281) at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:510) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:335) at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile (AbstractImageBuilder.java:225) at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile (AbstractImageBuilder.java:175) at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.build (BatchImageBuilder.java:49) at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildAll (JavaBuilder.java:212) at org.eclipse.jdt.internal.core.builder.JavaBuilder.build (JavaBuilder.java:135) at org.eclipse.core.internal.events.BuildManager$2.run (BuildManager.java:581) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:1015) at org.eclipse.core.runtime.Platform.run(Platform.java:757) at org.eclipse.core.internal.events.BuildManager.basicBuild (BuildManager.java:160) at org.eclipse.core.internal.events.BuildManager.basicBuild (BuildManager.java:198) at org.eclipse.core.internal.events.BuildManager$1.run (BuildManager.java:227) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:1015) at org.eclipse.core.runtime.Platform.run(Platform.java:757) at org.eclipse.core.internal.events.BuildManager.basicBuild (BuildManager.java:230) at org.eclipse.core.internal.events.BuildManager.basicBuildLoop (BuildManager.java:249) at org.eclipse.core.internal.events.BuildManager.build (BuildManager.java:278) at org.eclipse.core.internal.events.AutoBuildJob.doBuild (AutoBuildJob.java:138) at org.eclipse.core.internal.events.AutoBuildJob.run (AutoBuildJob.java:199) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:67) MNPParser.java BypassIncoming/Java/com/tele2/www/bypass/incoming/soap line 0 den 9 mars 2005 14:10:14
Could you please attach your project for further investigation?
I'm afraid my project is confidential because of business reasons... :-( I investigated this problem further and pin pointed the lines of code Eclipse "didn't like". I have no idea why it didn't like them but I found a work around by changing a method argument type to another type. You can close this bug report as far as I'm concerned. Many thanks!
No, we have a bug. Could you please try to isolate a test case that would reproduce this issue?
I would really encourage you to spend a few minutes trying to isolate a testcase, if not the bug will remain.
Are you using static imports in your code ?
(In reply to comment #5) > Are you using static imports in your code ? Actually, I am. Or was... I don't have the code in front of me right now but I did do some static imports for a static enum from another class. I will try to see if I can reproduce this error by adding these static imports again tomorrow. Cheers -Martin
I tried something like that, in vain... but maybe you can find a common pattern: import static p.ST.foo; public class X { foo bar; } package p; public class ST { static int foo; }
Created attachment 18675 [details] Test case I reproduced the problem with a small test case. Steps to reproduce: 1) Unzip the attachment on your disk 2) Create a project that points to the project you just extracted 3) Do a full build 4) This should work. 5) Add a space in Y.java and recompile. You should end up with the following stack trace: Exception in thread "Text Viewer Hover Presenter" java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.lookup.FieldBinding at org.eclipse.jdt.internal.compiler.lookup.Scope.getType(Scope.java:2132) at org.eclipse.jdt.internal.compiler.ast.SingleTypeReference.getTypeBinding(SingleTypeReference.java:39) at org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveType(TypeReference.java:141) at org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveSuperType(TypeReference.java:104) at org.eclipse.jdt.internal.compiler.lookup.ClassScope.findSupertype(ClassScope.java:1051) at org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectSuperInterfaces(ClassScope.java:790) at org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectTypeHierarchy(ClassScope.java:847) at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.connectTypeHierarchy(CompilationUnitScope.java:243) at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.completeTypeBindings(LookupEnvironment.java:249) at org.eclipse.jdt.internal.codeassist.SelectionEngine.select(SelectionEngine.java:713) at org.eclipse.jdt.internal.core.Openable.codeSelect(Openable.java:140) at org.eclipse.jdt.internal.core.CompilationUnit.codeSelect(CompilationUnit.java:300) at org.eclipse.jdt.internal.core.CompilationUnit.codeSelect(CompilationUnit.java:294) at org.eclipse.jdt.internal.ui.text.java.hover.AbstractJavaEditorTextHover.getHoverInfo(AbstractJavaEditorTextHover.java:108) at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo(BestMatchHover.java:102) at org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInfo(JavaEditorTextHoverProxy.java:69) at org.eclipse.jface.text.TextViewerHoverManager$4.run(TextViewerHoverManager.java:160) It is not exactly the same one, but I believe this is the same problem.
Glad you reproduced it olivier. Made a fix, Kent pls verify it. Added StaticImportTest#test028. Martin - if you take next nightly build, you should be able to prove it addresses your problem.
fixed
Glad to see you fixed this!
*** Bug 87003 has been marked as a duplicate of this bug. ***
Verified in I20050330-0500