Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bug in Eclipse? org.eclipse.jdt.internal.compiler.lookup.ArrayBinding cannot be cast to org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding

Tags:

java

eclipse

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?

like image 337
Markus A. Avatar asked Nov 25 '25 16:11

Markus A.


1 Answers

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.

like image 63
Otobong Jerome Avatar answered Nov 28 '25 05:11

Otobong Jerome



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!