Bug 87490 - Internal compiler error
Summary: Internal compiler error
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows NT
: P3 major (vote)
Target Milestone: 3.1 M6   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 87003 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-03-09 08:35 EST by Martin Börlin CLA
Modified: 2005-03-31 10:06 EST (History)
3 users (show)

See Also:


Attachments
Test case (1.81 KB, application/octet-stream)
2005-03-10 17:46 EST, Olivier Thomann CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Börlin CLA 2005-03-09 08:35:50 EST
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
Comment 1 Olivier Thomann CLA 2005-03-09 10:19:50 EST
Could you please attach your project for further investigation?
Comment 2 Martin Börlin CLA 2005-03-09 12:17:18 EST
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!
Comment 3 Olivier Thomann CLA 2005-03-09 12:22:01 EST
No, we have a bug. Could you please try to isolate a test case that would
reproduce this issue?
Comment 4 Philipe Mulet CLA 2005-03-09 13:33:29 EST
I would really encourage you to spend a few minutes trying to isolate a
testcase, if not the bug will remain.
Comment 5 Philipe Mulet CLA 2005-03-10 15:26:57 EST
Are you using static imports in your code ?
Comment 6 Martin Börlin CLA 2005-03-10 15:39:33 EST
(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
Comment 7 Philipe Mulet CLA 2005-03-10 15:50:48 EST
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;
}
Comment 8 Olivier Thomann CLA 2005-03-10 17:46:20 EST
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.
Comment 9 Philipe Mulet CLA 2005-03-10 18:30:54 EST
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.
Comment 10 Philipe Mulet CLA 2005-03-10 18:31:07 EST
fixed
Comment 11 Martin Börlin CLA 2005-03-11 02:14:10 EST
Glad to see you fixed this!
Comment 12 Philipe Mulet CLA 2005-03-15 16:53:48 EST
*** Bug 87003 has been marked as a duplicate of this bug. ***
Comment 13 David Audel CLA 2005-03-31 10:06:29 EST
Verified in I20050330-0500