In principle this should not be necessary. Does your project have the
Scala nature?
> Second, invoking methods with array arguments and/or return types
> produces errors in the highlighting. Nevertheless the whole thing
> compiles, since it is valid java code. This is annoying even in a toy
> project such as this, but it is extremely annoying when using scala
> code from lots of places in the above mentioned 100kLOC of java code.
> Is this related to this issue
> http://groups.google.com/group/scala-ide-user/browse_thread/thread/2d03aa2dc82ad678
> ? Any idea when/if this will be fixed?
It looks like the same issue. I can't promise it will be in the next
beta, but we'll keep it in mind.
In general, it's almost impossible to support a true Java view for
Scala code, in the way the Eclipse Java presentation compiler expects
it. There are simply too many cases where there's no direct
translation of a Scala entity to a Java entity (for example, traits).
In such cases, you'll notice these incompatibilities: the builder will
work fine, but the presentation compiler will show red underlines. The
'presentation compiler' is the lightweight Java compiler that is used
for 'report error as you type', code completion, etc. If you have
Scala sources in your project, we 'interface' with the Java
presentation compiler by trying to offer a Java view from Scala source
code.
A better way would be, when possible, to depend on binary Scala
libraries: since the translation is already done to bytecode, you'll
see exactly what the builder will see.
> Third, apparently that generic classes using primitive types as type
> arguments do not translate to java as I would expect. Does this have
> something to do with @Specialized, and what's the best way around this
> issue?
Probably not, it's more likely to be an issue in our structure builder
for the Java presentation compiler. I think there's a ticket for this
issue as well, and I know Mirco looked into it but it wasn't easy.
cheers,
iulian
> Here are the relevant methods in the library and the use from java:
>
> package scalalibrary
>
> object Library {
>
> def makeArray : Array[Byte] = Array(1,2,3,4)
>
> def length(a:Array[Byte]) = a.length
>
> def tryMakeInt() : Option[Int] = Some(1)
>
> def tryMakeString() : Option[String] = None
> }
>
> ---
>
> mport scalalibrary.*;
>
> public class Consumer {
> public static void main(String[] args) {
>
> byte[] bytes = Producer.makeArray(); // produces highlighting
> error, but compiles
>
> int a = Producer.length(bytes); // produces highlighting error,
> but compiles
>
> scala.Option<String> w = Producer.tryMakeString(); // this
> works
>
> scala.Option<Integer> x = Producer.tryMakeInt(); // this
> doesn't
> }
> }
>
--
« Je déteste la montagne, ça cache le paysage »
Alphonse Allais