This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Re: Eclipse 3.5 mixed Scala/Java: errors in Java editor but still compiles?

2 replies
Zach Cox
Joined: 2009-07-17,
User offline. Last seen 42 years 45 weeks ago.

On Fri, Jul 17, 2009 at 2:24 PM, Naftoli Gugenheim wrote:
> Is JDT generally fine with identifiers containing '$'?

Surprisingly enough it does seem to be happy with identifiers
containing $, the following displays no errors in the Java editor and
even code-complete works fine:

package com.pongr.mixedtest;

public class Dollar$ {
public static String billYall() {
return "Wu Tang C.R.E.A.M.";
}
}

package com.pongr.mixedtest;

public class Test {
public static void main(String[] args) {
System.out.println(Dollar$.billYall());
}
}

Does anyone know why the Eclipse Java editor complains when trying to
access a Scala object from Java?

> On Fri, Jul 17, 2009 at 1:04 PM, Zach Cox wrote:
>>
>> Hi - I'm starting to work Scala into a large Java project and just
>> doing some basic tests.  I just did a fresh install of Eclipse 3.5 and
>> the 2.7.5.final Scala plugin (on Ubuntu 9.04 with Java 1.6.0.14).  I
>> created a new Scala project and then created a Scala object and a Java
>> class as follows:
>>
>>
>> package com.pongr.mixedtest
>>
>> object MyObject {
>>  def get() = "from scala object"
>> }
>>
>>
>> package com.pongr.mixedtest;
>>
>> public class Test {
>>        public static void main(String[] args) {
>>                System.out.println(MyObject$.MODULE$.get());
>>        }
>> }
>>
>>
>> Eclipse compiles everything just fine and running Test prints "from
>> scala object" to the console, as expected.  But in the Eclipse editor
>> for Test.java, the MyObject$.MODULE$ part is red-underlined with the
>> error "MyObject$.MODULE$ cannot be resolved".
>>
>> This isn't a deal-breaker since everything still compiles & runs but
>> it is slightly annoying to see the error in the Java editor.  Can I
>> tweak the Eclipse install somehow to get rid of these types of error
>> messages in the Java editor?  Or do I just need to leave comments in
>> the code like "ignore the cannot be resolved error on the next line"?
>>
>> Thanks,
>> Zach
>
>

milessabin
Joined: 2008-08-11,
User offline. Last seen 33 weeks 3 days ago.
Re: Eclipse 3.5 mixed Scala/Java: errors in Java editor but st

On Sat, Jul 18, 2009 at 4:19 AM, Zach Cox wrote:
> Does anyone know why the Eclipse Java editor complains when trying to
> access a Scala object from Java?

It's because the JDT component which is responsible for the squigglies
in the Java editor doesn't know enough about Scala objects yet. Expect
this to be fixed in 2.8.0.

Cheers,

Miles

Zach Cox
Joined: 2009-07-17,
User offline. Last seen 42 years 45 weeks ago.
Re: Eclipse 3.5 mixed Scala/Java: errors in Java editor but st

OK thanks Miles. Really looking forward to 2.8.0!

On Sat, Jul 18, 2009 at 6:21 AM, Miles Sabin wrote:
> On Sat, Jul 18, 2009 at 4:19 AM, Zach Cox wrote:
>> Does anyone know why the Eclipse Java editor complains when trying to
>> access a Scala object from Java?
>
> It's because the JDT component which is responsible for the squigglies
> in the Java editor doesn't know enough about Scala objects yet. Expect
> this to be fixed in 2.8.0.
>
> Cheers,
>
>
> Miles
>
> --
> Miles Sabin
> tel: +44 (0)7813 944 528
> skype:  milessabin
> http://www.chuusai.com/
> http://twitter.com/milessabin
>

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland