gpt4 book ai didi

java - Java 搜索中的类文件名必须以 .class 异常结尾

转载 作者:IT老高 更新时间:2023-10-28 13:52:26 24 4
gpt4 key购买 nike

我希望有人可以帮助我解决在特定项目中使用 Eclipse 中的 java 搜索功能时遇到的问题。

在一个特定项目上使用 java 搜索时,我收到一条错误消息,提示 Class 文件名必须以 .class 结尾(请参阅下面的堆栈跟踪)。似乎并非所有项目都发生这种情况,只是一个特定的项目,所以也许我应该尝试重建一些东西?

我已经尝试过Project -> Clean... 和Closing Eclipse,删除所有构建的类文件并重新启动Eclipse 无济于事。

我在 Google 上找到的关于该问题的唯一引用资料是 http://www.crazysquirrel.com/computing/java/eclipse/error-during-java-search.jspx ,但不幸的是他的解决方案(关闭、删除类文件、重新启动)对我不起作用。

如果有人可以提出一些尝试的建议,或者我可以收集更多信息来帮助追踪它,我将非常感谢您的指点。

Version: 3.4.0
Build id: I20080617-2000

也刚刚找到这个帖子 - 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)

感谢 McDowell,关闭和打开项目似乎已经修复了它(至少现在是这样)。

最佳答案

评论#9 to bug 269820解释如何删除搜索索引,这似乎是解决索引损坏的方法,其症状是可怕的

An internal error occurred during: "Items filtering".
Class file name must end with .class

消息框。

如何删除搜索索引:

  1. 关闭 Eclipse
  2. 删除 /.metadata/.plugins/org.eclipse.jdt.core/*.index
  3. 删除 /.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt
  4. 再次启动 Eclipse

关于java - Java 搜索中的类文件名必须以 .class 异常结尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6816/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com