In Netbeans, I used some scala code (jar) written by someone else and included it into a java project project along with Scala-library.jar. It worked nicely without hiccups.
Now when I try to do the same using eclipse, I get the following build error
Internal compiler error: java.lang.ClassCastException:
org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding cannot be cast to
org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding at
org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.initializeTypeVariable(BinaryTypeBinding.java:944) DemoApp.java /demo/ line 0 Java Problem
On Googling, I found that others have had this problem but not seen any fixes.
If any of you have seen this error and figured how to fix it, please share it here.
Let me know if any other information is needed. Unfortunately, I do not have the source of the Scala code that I used, just the jar. If you need the code of DemoApp.java, I can paste it here, but that is not very useful: it just references an object in the Scala code.
Details: scala-2.8.0.r22602-b20100720020114
Thanks.
Ok. I finally found the solution!
Thanks to this SO question
The problem seems to be Scala 2.8 compiler (apparantly). This issue is not there in 2.9.
One of the fixes suggested was to use Scala 2.9, but that is not always possible. So here is the right solution.
The problem lies in the
Listtype of Scala. I found that I was returning (exposing) aListin the Scala code somewhere, which was causing the problem with Java in Eclpise.To fix the problem, do not return
List. ReturnArrayor some Java type.