This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
See setup in bug #177536 for background. Assuming that the "Uncompilable source code" throwable were in fact thrown during code execution (in this case it probably would not be), it is inappropriate to use RuntimeException for this purpose. For example, Functions contains: @IgnoreJRERequirement public static boolean isMustangOrAbove() { try { System.console(); return true; } catch(LinkageError e) { return false; } } This works correctly when the code is compiled against JDK 6 and run on JDK 5 or 6. But when the code is compiled by the NetBeans internal javac running on JDK 5, we get java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) .... Caused by: java.lang.RuntimeException: Uncompilable source code at hudson.Functions.isMustangOrAbove(Functions.java:754) at hudson.node_monitors.TemporarySpaceMonitor.install(TemporarySpaceMonitor.java:77) ... 17 more In other words, the RE is being thrown right past the catch block and breaks surrounding code which is otherwise written to deal with the situation gracefully. The NB-generated classes should instead throw LinkageError for uncompilable source code, just like the JRE would do if the source code were compilable against some alternate classpath but fails to link against the current runtime. (Ideally generated code would throw an appropriate subtype: for example, in this case a NoSuchMethodError would be perfect. NoClassDefFoundError would be appropriate for missing types, etc. But just throwing plain LinkageError would be a good start.)
Well, although LE may be appropriate for un-resolvable method, it is not appropriate, IMO, for code like "1+;" (there is no linkage problem in this statement, and the LE would be throw when the execution would reach the point of such a statement). Using both LE and RE would be quite confusing for users (and the rest of the IDE too). So I am not sure if throwing LE is a good idea.
For syntax errors, just throw whatever subclass of LinkageError is most appropriate - probably ClassFormatError, maybe VerifyError. These are all assignable to LinkageError even though they do not involve class -> class dependencies as such, i.e. LinkageError really means "some fatal problem loading classes", which is exactly what should be used for erroneous code.
Makes sense to me.