Java 搜索中的类文件名必须以 .class 异常结尾
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6816/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Class file name must end with .class exception in Java Search
提问by Matt Sheppard
I was hoping someone could help me out with a problem I'm having using the java search function in Eclipse on a particular project.
我希望有人可以帮助我解决我在 Eclipse 中在特定项目中使用 java 搜索功能时遇到的问题。
When using the java search on one particular project, I get an error message saying Class file name must end with .class
(see stack trace below). This does not seem to be happening on all projects, just one particular one, so perhaps there's something I should try to get rebuilt?
在一个特定项目上使用 java 搜索时,我收到一条错误消息Class file name must end with .class
(请参阅下面的堆栈跟踪)。这似乎并没有发生在所有项目中,只是一个特定的项目,所以也许我应该尝试重建一些东西?
I have already tried Project -> Clean
... and Closing Eclipse, deleting all the built class files and restarting Eclipse to no avail.
我已经尝试过Project -> Clean
......并关闭Eclipse,删除所有构建的类文件并重新启动Eclipse无济于事。
The only reference I've been able to find on Google for the problem is at http://www.crazysquirrel.com/computing/java/eclipse/error-during-java-search.jspx, but unfortunately his solution (closing, deleting class files, restarting) did not work for me.
我能够在谷歌上找到的唯一参考是在http://www.crazysquirrel.com/computing/java/eclipse/error-during-java-search.jspx,但不幸的是他的解决方案(关闭,删除类文件,重新启动)对我不起作用。
If anyone can suggest something to try, or there's any more info I can gather which might help track it's down, I'd greatly appreciate the pointers.
如果有人可以提出一些尝试的建议,或者我可以收集更多信息来帮助追踪它,我将不胜感激。
Version: 3.4.0
Build id: I20080617-2000
Also just found this thread - http://www.myeclipseide.com/PNphpBB2-viewtopic-t-20067.html- which indicates the same problem may occur when the project name contains a period. Unfortunately, that's not the case in my setup, so I'm still stuck.
也刚刚发现这个线程 - http://www.myeclipseide.com/PNphpBB2-viewtopic-t-20067.html- 这表明当项目名称包含句点时可能会出现同样的问题。不幸的是,在我的设置中不是这种情况,所以我仍然被卡住了。
Caused by: java.lang.IllegalArgumentException: Class file name must end with .class
at org.eclipse.jdt.internal.core.PackageFragment.getClassFile(PackageFragment.java:182)
at org.eclipse.jdt.internal.core.util.HandleFactory.createOpenable(HandleFactory.java:109)
at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1177)
at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.locateMatches(JavaSearchParticipant.java:94)
at org.eclipse.jdt.internal.core.search.BasicSearchEngine.findMatches(BasicSearchEngine.java:223)
at org.eclipse.jdt.internal.core.search.BasicSearchEngine.search(BasicSearchEngine.java:506)
at org.eclipse.jdt.core.search.SearchEngine.search(SearchEngine.java:551)
at org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine.internalSearch(RefactoringSearchEngine.java:142)
at org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine.search(RefactoringSearchEngine.java:129)
at org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeProcessor.initializeReferences(RenameTypeProcessor.java:594)
at org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeProcessor.doCheckFinalConditions(RenameTypeProcessor.java:522)
at org.eclipse.jdt.internal.corext.refactoring.rename.JavaRenameProcessor.checkFinalConditions(JavaRenameProcessor.java:45)
at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.checkFinalConditions(ProcessorBasedRefactoring.java:225)
at org.eclipse.ltk.core.refactoring.Refactoring.checkAllConditions(Refactoring.java:160)
at org.eclipse.jdt.internal.ui.refactoring.RefactoringExecutionHelper$Operation.run(RefactoringExecutionHelper.java:77)
at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:39)
at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:709)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800)
at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:4650)
at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:92)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Thanks McDowell, closing and opening the project seems to have fixed it (at least for now).
感谢 McDowell,关闭和打开项目似乎已经解决了它(至少现在是这样)。
采纳答案by McDowell
Two more general-purpose mechanisms for fixing some of Eclipse's idiosyncrasies:
用于修复 Eclipse 的一些特性的两个更通用的机制:
- Close and open the project
- Delete the project (but not from disk!) and reimport it as an existing project
- 关闭并打开项目
- 删除项目(但不是从磁盘!)并将其重新导入为现有项目
Failing that, bugs.eclipse.orgmight provide the answer.
如果做不到这一点,bugs.eclipse.org可能会提供答案。
If the workspace is caching something broken, you may be able to delete it by poking around in workspace/.metadata/.plugins. Most of that stuff is fairly transient (though backup and watch for deleted preferences).
如果工作区正在缓存损坏的内容,您可以通过在workspace/.metadata/.plugins 中查看来删除它。大多数东西都是相当短暂的(尽管备份并注意已删除的首选项)。
回答by McDowell
Got this error to the other day. Tried deleting the all .class-files and resources from my output folder manually. Didn't work. Restarted my computer (WinXP). Didn't work. Closed my project in Eclipse and opened it again. Worked!!!Hopes this solves someones problem out there. The search facilities and truly essential to Eclipse.
前几天得到这个错误。尝试手动从我的输出文件夹中删除所有 .class 文件和资源。没用。重新启动我的计算机(WinXP)。没用。在 Eclipse 中关闭我的项目并再次打开它。工作了!!!希望这能解决某人的问题。搜索工具和 Eclipse 真正必不可少的功能。
回答by Olivier Dagenais
Comment #9 to bug 269820explains how to delete the search index, which appears to be the solution to a corrupt index whose symptoms are the dreaded
错误 269820 的评论#9解释了如何删除搜索索引,这似乎是解决损坏索引的方法,该索引的症状是可怕的
An internal error occurred during: "Items filtering".
Class file name must end with .class
期间发生内部错误:“项目过滤”。
类文件名必须以 .class 结尾
message box.
消息框。
How to delete the search index:
如何删除搜索索引:
- Close Eclipse
- Delete <workspace>/.metadata/.plugins/org.eclipse.jdt.core/*.index
- Delete <workspace>/.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt
- Start Eclipse again
- 关闭日食
- 删除 <workspace>/.metadata/.plugins/org.eclipse.jdt.core/*.index
- 删除 <workspace>/.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt
- 再次启动 Eclipse
回答by Olivier Dagenais
I also encountered this issue recently, the below scenario worked for me.
我最近也遇到了这个问题,下面的场景对我有用。
- Close Eclipse
- Delete
<workspace>/.metadata/.plugins/org.eclipse.jdt.core/*.index
- Delete
<workspace>/.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt
- Start Eclipse again
- 关闭日食
- 删除
<workspace>/.metadata/.plugins/org.eclipse.jdt.core/*.index
- 删除
<workspace>/.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt
- 再次启动 Eclipse
回答by Rick
Closing the projects didn't do the trick for me. I started eclipse with the -clean flag and that worked for some reason.
关闭项目对我没有帮助。我用 -clean 标志开始 eclipse 并且由于某种原因起作用。
回答by LoganMzz
Just
只是
- Close project
- Clear manually output folder(s)
- Open project
- 关闭项目
- 清除手动输出文件夹
- 打开项目
(Eclipse 3.5 SR2, Build id: 20100218-1602)
(Eclipse 3.5 SR2,构建 ID:20100218-1602)