2

The following obviously incorrect code (inspired by @dexter's answer to a question of mine):

Class<? extends Exception>[] exceptions;

try {
    // some stuff here
} catch (exceptions[0] e) {
    // some more stuff here
}

causes Eclipse to frequently pop up a dialog box titled "Problem Occurred" with the following message:

'Building workspace' has encountered a problem.
Errors occurred during the build.

The dialog offers the following 'Details':

Errors occurred during the build.
    Errors running builder 'Java Builder' on project 'test'.
    org.eclipse.jdt.internal.compiler.lookup.ArrayBinding cannot be cast to
    org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding

Eclipse does place red squiggles under exceptions[0], but if I mouse over them, it doesn't have any error associated with them. Instead, it also places a red (x) in the very top of the margin and squiggles the first letter of the first line in the file (the p in package ...) and if I mouse over that, I get:

Internal compiler error: java.lang.ClassCastException:
    org.eclipse.jdt.internal.compiler.lookup.ArrayBinding cannot be cast to
    org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding at
    org.eclipse.jdt.internal.compiler.ast.TryStatement.verifyDuplicationAndOrder
    (TryStatement.java:1191)

Is this a bug in Eclipse? If so, what's the best place to report it?

Also (to make this question it useful to someone who runs into the same issue), is there a good way to locate the source of such a build error, if it's buried somewhere deep in the code? The only information I get from the error messages is the project name in the details of the dialog, which may not be too helpful if there are many other problems with the project (taking over someone else's work, for example). Are there other places, where I can find more information about the exact location of this error, like at least a file-name?

Community
  • 1
  • 1
Markus A.
  • 12,349
  • 8
  • 52
  • 116

3 Answers3

5

Here's a trick:

In my case the bug marked an X on one file user.java

So I opened up the file, highlighted everything and cut it, then saved so the X went away.

Then I pasted it back in.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
Otobong Jerome
  • 401
  • 6
  • 5
3

Yes it looks like an Eclipse bug which you would report at https://bugs.eclipse.org/bugs/ Looking at existing bugs this class cast error has happened before but there are no open bugs for this error.

Looking at the jdt plugins there are a lot of debug options that can be turned on, I'm not sure which ones would be useful here.

greg-449
  • 109,219
  • 232
  • 102
  • 145
  • Ehhh... Six thousand error categories... Should I post this under "Eclipse itself: Java Development Tools" or "Language IDEs: Java"? :) – Markus A. Apr 30 '14 at 17:07
  • JDT I think, look at [this](https://bugs.eclipse.org/bugs/show_bug.cgi?id=239273) existing report for a similar error – greg-449 Apr 30 '14 at 17:11
  • It asks me to select the version. When I click on "Help -> About Eclipse -> (Eclipse logo)", it shows "3.9.1.v20130911-1000" for the "Eclipse Java Development Tools", but the bug reporting system only offers 3.8.2 and older or 4.2 and newer. Do you know if there is a different version that they are looking for (I'm using Kepler SR1)? – Markus A. Apr 30 '14 at 17:14
  • Kepler SR1 is 4.3.1 - which should be on the Help > About dialog. – greg-449 Apr 30 '14 at 17:19
1

A partial answer to help others who run into this problem and are having trouble tracking down the cause:

In Eclipse, open the "Problems" view via "Window -> Show View -> Problems". Expand the "Errors"-section in the view. This list contains all errors found in all projects that are currently part of the build process.

Most errors in the list will have a light-bulb with a small red [x] in the corner as their icon. Some will have a big red (x). One of those with the big red (x) will say "Internal compiler error: ...". If you double-click that entry, it will take you to the file that causes the error.

In my case, the "Errors"-list contains a second entry with a big red (x) right after the one labelled "Internal compiler error: ...". That one is the actual problem that causes the error, so double-clicking that will not only open the right file, but also jump to the offending location. (Not sure if this second entry will always be there, though...)

Markus A.
  • 12,349
  • 8
  • 52
  • 116