Community
Participate
Working Groups
Created attachment 79189 [details] eclipse log file containing the complete exception stacktrace When using the "Open Type" dialog (CTRL+SHIFT+T) to open a class file from a class folder a ClassCastException occurs. The UI does not react to the request to open the type and an exception is logged: java.lang.ClassCastException: org.eclipse.core.internal.resources.Folder cannot be cast to org.eclipse.core.resources.IFile at org.eclipse.jdt.internal.core.ClassFile.buildStructure(ClassFile.java:87) at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:229)
What Eclipse build are you using ?
Version: 3.3.0 Build id: I20070621-1340
Looking at the code, I don't see how this can happen. Do you have detailed steps to reproduce this problem ? A small workspace reproducing the problem would be ideal.
Created attachment 79211 [details] eclipse java project to reproduce the ClassCastException In order to reproduce the ClassCastException do the following steps: 1. create a new empty workspace 2. unzip this attachment to your filesystem 3. import the contents through File/Import/"Existing Projects into Workspace" 4. open the "Open Type" dialog (CTRL-SHIFT-T) and open the type "TestCCE" -> the logfile is written to your workspace, nothing else happens
If you restart your workbench after importing the project the exception does not happen again, but the following error message is displayed in a dialog: "Type 'TestCCE' could not be found in 'P2/lib2.jar'. Make sure all workspaces and resources are refreshed." In order to reproduce the ClassCastException again you have to create a new workspace and import the project into that workspace.
(In reply to comment #4) Thanks for the test case Tobias. I cannot reproduce the ClassCastException but I'm always getting the Type "'TestCCE' could not be found in 'P2/lib2.jar'" dialog. Investigating...
Note that in 3.4 M2, the problem doesn't exist any longer as it was fixed in bug 138184.
However looking more at the code, I now found a path that can lead to this ClassCastException. I'm writing a JUnit test to prove that.
Actually it is possible to reproduce the ClassCastException consistently by following these steps: 1. create a new empty workspace 2. unzip the attachment from comment 4 to your filesystem 3. import the contents through File/Import/"Existing Projects into Workspace" 4. expand P2, then Referenced Libraries (but don't expand further) 5. open the "Open Type" dialog (CTRL-SHIFT-T) and open the type "TestCCE" -> the logfile is written to your workspace, nothing else happens Even if you restart and follow steps 4 then 5, then ClassCastException still occurs
(In reply to comment #9) This is using 3.3 of course.
Created attachment 79221 [details] Proposed fix and regression test
Fix and test released for 3.4M3 in HEAD.
Pls backport to 3.3.x
Created attachment 79284 [details] Proposed fix for 3.3 maintenance Since the 3.4 M3 fix is too complicated and too risky for a backporting, this fix takes a different approach: it ensures that a PackageFragmentRoot is created during 'search all type names' (and not a JarPackageFragmentRoot as it would do in 3.3).
Created attachment 79376 [details] Proposed regression test for 3.3 maintenance
Fix and test released for 3.3.2 in R3_3_maintenance
Verified for 3.4M3 using I20071029-0010 build.
Since there is no workaround, this fix needs to be included in 3.3.2. Philippe please approve.
Verified for 3.3.2 using M20080123-0800 build