简体   繁体   English

netbeans 中的“无法编译的源代码”运行时异常

[英]"Uncompilable source code" RuntimeException in netbeans

I'm trying to help another developer who is using Netbeans.我正在尝试帮助另一个使用 Netbeans 的开发人员。 When he runs or debugs some code of his in Netbeans (6.9.1) he gets an "Uncompilable source code" RuntimeException .当他在 Netbeans (6.9.1) 中运行或调试他的一些代码时,他得到一个“不可编译的源代码” RuntimeException I'm pretty experienced in Java but am more used to IntelliJ, and haven't used Netbeans at all.我在 Java 方面很有经验,但更习惯于 IntelliJ,根本没有使用过 Netbeans。

I've done it a bit of googling and it seems Netbeans will compile code even with errors, and then throw the RuntimeException at the errors.我已经做了一些谷歌搜索,似乎 Netbeans 即使有错误也会编译代码,然后在错误处抛出RuntimeException (Fairly bad behaviour IMO, but I guess some will find it useful.) I've got him to completely rebuild the project with no compile errors, but the RuntimeException seems to still occur. (IMO 的行为相当糟糕,但我想有些人会发现它很有用。)我让他完全重建项目,没有编译错误,但RuntimeException似乎仍然发生。 I assume he's got some bad cached class data somewhere deep within Netbeans.我假设他在 Netbeans 深处的某个地方有一些不好的缓存类数据。

2 questions: 2个问题:

  1. What is the best way to clear the cache so we can find out where the uncompilable code is?清除缓存以便我们找出不可编译代码的最佳方法是什么?
  2. Is there any way of turning off this behaviour so the code won't run/debug unless everything will compile, so these RuntimeException's won't be injected into the code?有没有办法关闭这种行为,这样代码就不会运行/调试,除非一切都能编译,所以这些 RuntimeException 不会被注入到代码中?

I've googled a fair bit, but haven't found the answer to either of these questions yet.我在谷歌上搜索了很多,但还没有找到这些问题的答案。


Update: More information:更新:更多信息:

  1. Turning off the "compile on save" option makes the problem go away.关闭“保存时编译”选项会使问题消失。 Turning CoS back on again brings the exception back.再次打开 CoS 会使异常恢复。 Unfortunately this isn't a fix, as CoS is a very useful option.不幸的是,这不是解决办法,因为 CoS 是一个非常有用的选项。
  2. http://netbeans.org/bugzilla/show_bug.cgi?id=182009 seems the closest bug report, but it has been closed as "RESOLVED INCOMPLETE". http://netbeans.org/bugzilla/show_bug.cgi?id=182009似乎是最接近的错误报告,但它已被关闭为“已解决不完整”。 Unfortunately the bug is hard to reproduce - the exception is happening in Java library code, when it calls a third-party library, so there isn't anything at the point the exception is thrown we can change.不幸的是,这个错误很难重现——异常发生在 Java 库代码中,当它调用第三方库时,所以在抛出异常时没有任何东西可以改变。 And the code will work for weeks, and then suddenly start throwing this error with no obvious reason why.并且代码会工作数周,然后突然开始抛出这个错误,没有明显的原因。
  3. We've tried manually deleting the entire build directory - still not a fix.我们已经尝试手动删除整个构建目录 - 仍然没有修复。

We finally got a solution, but still don't quite know why the situation occurs. 我们终于找到了解决方案,但仍然不知道为什么会发生这种情况。 When you have Compile On Save activated, Netbeans generates a second set of class files for debugging etc. These are stored in $USER/.netbeans/var/cache/index/s*/java/*/classes 激活“保存时编译”后,Netbeans将生成第二组类文件以进行调试等。这些文件存储在$USER/.netbeans/var/cache/index/s*/java/*/classes

Somehow (not sure how) this directory can get corrupted or fail to update. 该目录可能以某种方式(不确定如何)损坏或无法更新。

If you close netbeans, delete $USER/.netbeans/var/cache/index and all subdirectories and restart netbeans this clears the cache. 如果关闭netbeans,则删除$USER/.netbeans/var/cache/index和所有子目录,然后重新启动netbeans,这将清除缓存。 If you have no compile errors, your problem ought to go away at this point. 如果没有编译错误,则此时您的问题应该消失。

NB: $USER is your user directory - on Windows 7 this is usually c:\\Users\\username , I guess on Unix it will be ~username . 注意:$ USER是您的用户目录-在Windows 7上通常是c:\\Users\\username ,我猜在Unix上是~username

If you get this problem please vote for, comment on, or add information to: http://netbeans.org/bugzilla/show_bug.cgi?id=182009 如果遇到此问题,请投票,评论或向以下网站添加信息: http : //netbeans.org/bugzilla/show_bug.cgi?id=182009

我在NB 7.0.1中遇到了同样的有线问题,我的Hammer-IQ解决方案是在源代码中打错字,运行NB并出现此错误(尽管有错误消息),然后成功删除了缓存的类。

I experienced this issue on Linux Mint Nadia with Netbeans 7.2.1, but was stumped as to where the cache location might be - mine was actually located at 我在使用Netbeans 7.2.1的Linux Mint Nadia上遇到了此问题,但对于缓存位置可能在哪里感到困惑-我的实际位置在

/home/USER/.cache/netbeans/7.2.1

rather than in the .netbeans folder. 而不是在.netbeans文件夹中。

If you're not sure where the cache is located on your particular setup, just go to the help > about menu in Netbeans and it'll tell you the correct path. 如果不确定特定设置中的缓存位于何处,只需转到Netbeans中的help> about菜单,它将告诉您正确的路径。

意识到原因是其他发布的解决方案中的缓存不良后,我通过将文件复制到另一个目录,从NetBeans中删除它,然后再次添加来解决了此问题。

In fact, you neednt delete whole of index folder. 实际上,您无需删除整个索引文件夹。 When you open netbeans and your project folder is active. 当您打开netbeans并且您的项目文件夹处于活动状态时。 Netbeans starts scanning files and creates temporary project folders (in index folder) for all active projects. Netbeans开始扫描文件,并为所有活动项目创建临时项目文件夹(在索引文件夹中)。 If you check index\\segments file(its a text file and can be viewed in notepad/(text editor)), you will be able to identify the folders that represent your project. 如果您检查index \\ segments文件(它是一个文本文件,可以在记事本/(文本编辑器)中查看),则可以识别代表您的项目的文件夹。 You can then delete those folders and restart netbeans. 然后,您可以删除这些文件夹并重新启动netbeans。

*Active project means those projects that were open before Netbeans was shutdown. *活动项目是指在关闭Netbeans之前打开的那些项目。

Had the same problem on Windows 7 with Netbeans 12.在带有 Netbeans 12 的 Windows 7 上遇到了同样的问题。

Cache is here:缓存在这里:

C:\Users\<Username>\AppData\Local\NetBeans\Cache

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 RuntimeException:无法编译的源代码 - RuntimeException: Uncompilable source code RuntimeException:无法编译的源代码-找不到符号 - RuntimeException: Uncompilable source code - cannot find symbol java.lang.RuntimeException:无法编译的源代码 - 是什么导致了这种情况? - java.lang.RuntimeException: Uncompilable source code - what can cause this? 线程“ main”中的异常java.lang.RuntimeException:无法编译的源代码 - Exception in thread “main” java.lang.RuntimeException: Uncompilable source code Java-RuntimeException-不可编译的源代码-错误的树类型 - Java- RuntimeException- Uncompilable source code - Erroneous tree type 错误:“无法编译的源代码” - Error: “Uncompilable source code” 无法编译的源代码错误? - Uncompilable source code Error? 线程“主”中的Java异常java.lang.RuntimeException:无法编译的源代码-错误的树类型: - Java Exception in thread “main” java.lang.RuntimeException: Uncompilable source code - Erroneous tree type: 线程“ main”中的错误异常java.lang.RuntimeException:无法编译的源代码-错误的树类型: <any> - Error Exception in thread “main” java.lang.RuntimeException: Uncompilable source code - Erroneous tree type: <any> 调用方法时发生错误-java.lang.RuntimeException:无法编译的源代码-错误的树类型: <any> - Error when invoking method - java.lang.RuntimeException: Uncompilable source code - Erroneous tree type: <any>
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM