[scala] Mixing Scala and Java in the same project

View: New views
7 Messages — Rating Filter:   Alert me  

[scala] Mixing Scala and Java in the same project

by Seth Tisue :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I posted before about how I have a fairly large (about 150 KLOC)
codebase that now contains a mixture of interdependent Scala and Java,
and how I was building it with a complicated Ant setup that invoked
scalac and javac many times, in alternation.

Since the new Scala/Java mixing support was announced, I've been trying
to get it to work with my project.  You pass all of your source (both
Java and Scala) to scalac, then you run javac with just your Java
sources.  Or, if you're using Eclipse, you include both the Scala
builder and the Java builder in your project.

I encountered and reported a series of bugs along the way (both
compile-time problems and run-time problems), but the good news is,
nearly all of them were fixed promptly by EPFL (thank you all!), and the
remaining few are minor and easily worked around.  So as of yesterday,
my app now works when compiled the new way -- all tests pass and the GUI
seems to work).  Hooray!

What puzzles me is, even though I found quite a few bugs, I seem to be
almost the only one reporting such bugs.  Is no one else even trying out
this new mixing support...?  If you've thought about trying it, now
would be a good time, since
- it's in much better shape than it was a month ago, in fact, good
  enough shape to work with a pretty large codebase with many
  dependencies in both directions between the two languages
- 2.7.2 is coming soon and if there are any more bugs lurking it would
  be great to have the bug reports come in before 2.7.2 ships

Check it out,

--
Seth Tisue / http://tisue.net
lead developer, NetLogo: http://ccl.northwestern.edu/netlogo/

Re: [scala] Mixing Scala and Java in the same project

by Miles Sabin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Aug 19, 2008 at 3:57 PM, Seth Tisue <seth@...> wrote:
> Since the new Scala/Java mixing support was announced, I've been trying
> to get it to work with my project.  You pass all of your source (both
> Java and Scala) to scalac, then you run javac with just your Java
> sources.  Or, if you're using Eclipse, you include both the Scala
> builder and the Java builder in your project.

Careful here, if you're using the very latest nightly build (or the
soon-to-be-released 2.7.2) then please *don't* included the Java
builder in your .project file. See my posting in this thread,

  http://www.nabble.com/eclipse-plug-in-nightly-build-no-class-files-td19046123.html

Cheers,


Miles

Re: [scala] Mixing Scala and Java in the same project

by Ilya Sergey (JetBrains) :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Seth,

I also used nightly builds to compile our cross-language Java/Scala
project. And I also find several bugs, and as I know, all of them but
one were fixed after my reports.

With best regards,
Ilya

2008/8/19 Seth Tisue <seth@...>:

>
> I posted before about how I have a fairly large (about 150 KLOC)
> codebase that now contains a mixture of interdependent Scala and Java,
> and how I was building it with a complicated Ant setup that invoked
> scalac and javac many times, in alternation.
>
> Since the new Scala/Java mixing support was announced, I've been trying
> to get it to work with my project.  You pass all of your source (both
> Java and Scala) to scalac, then you run javac with just your Java
> sources.  Or, if you're using Eclipse, you include both the Scala
> builder and the Java builder in your project.
>
> I encountered and reported a series of bugs along the way (both
> compile-time problems and run-time problems), but the good news is,
> nearly all of them were fixed promptly by EPFL (thank you all!), and the
> remaining few are minor and easily worked around.  So as of yesterday,
> my app now works when compiled the new way -- all tests pass and the GUI
> seems to work).  Hooray!
>
> What puzzles me is, even though I found quite a few bugs, I seem to be
> almost the only one reporting such bugs.  Is no one else even trying out
> this new mixing support...?  If you've thought about trying it, now
> would be a good time, since
> - it's in much better shape than it was a month ago, in fact, good
>  enough shape to work with a pretty large codebase with many
>  dependencies in both directions between the two languages
> - 2.7.2 is coming soon and if there are any more bugs lurking it would
>  be great to have the bug reports come in before 2.7.2 ships
>
> Check it out,
>
> --
> Seth Tisue / http://tisue.net
> lead developer, NetLogo: http://ccl.northwestern.edu/netlogo/
>
> !DSPAM:52,48aae12e183932051017194!
>
>

Re: [scala] Mixing Scala and Java in the same project

by Seth Tisue :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>>>>> "Seth" == Seth Tisue <seth@...> writes:

 Seth> Or, if you're using Eclipse, you include both the Scala builder
 Seth> and the Java builder in your project.

oops... actually just the Scala builder, see
http://www.nabble.com/eclipse-plug-in-nightly-build-no-class-files-td19046123.html

--
Seth Tisue / http://tisue.net
lead developer, NetLogo: http://ccl.northwestern.edu/netlogo/

Re: [scala] Mixing Scala and Java in the same project

by Martin Odersky :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks to Seth and Ilya for their careful bug reporting! I believe
there are still some minor glitches, and a major one. I expect that
some of the remaining minor glitches can be fixed, and hope the others
will have workarounds.

There's one major problem left, at the moment. I don't think we can
guarantee yet that
when you do

scalac *.scala *.java
javac *.java

that all Scala classfiles will work correctly. The problem is that the
mapping Java->Scala seems to be (lmostly) good enough for the type
checker, but not necessarily good enough for the Java code generator.
So, to be safe, you should follow the sequence above by another Scala
compilation:

scalac *.scala

That's just to be safe. Please continue to send tickets for cases
where the two-step sequence
(scalac/javac) is not sufficient and we will try to fix them ASAP.

Cheers

 -- Martin

Re: [scala] Mixing Scala and Java in the same project

by Andrés Testi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It would be nice to have Scala Source to Java Source compilation, to
allow Scala in compilers like GWT.

- Andrés

2008/8/19 martin odersky <martin.odersky@...>:

> Thanks to Seth and Ilya for their careful bug reporting! I believe
> there are still some minor glitches, and a major one. I expect that
> some of the remaining minor glitches can be fixed, and hope the others
> will have workarounds.
>
> There's one major problem left, at the moment. I don't think we can
> guarantee yet that
> when you do
>
> scalac *.scala *.java
> javac *.java
>
> that all Scala classfiles will work correctly. The problem is that the
> mapping Java->Scala seems to be (lmostly) good enough for the type
> checker, but not necessarily good enough for the Java code generator.
> So, to be safe, you should follow the sequence above by another Scala
> compilation:
>
> scalac *.scala
>
> That's just to be safe. Please continue to send tickets for cases
> where the two-step sequence
> (scalac/javac) is not sufficient and we will try to fix them ASAP.
>
> Cheers
>
>  -- Martin
>

[scala] Re: Mixing Scala and Java in the same project

by Ismael Juma :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Andrés Testi <andres.a.testi <at> gmail.com> writes:
> It would be nice to have Scala Source to Java Source compilation, to
> allow Scala in compilers like GWT.

Some work is being done on this. See:

https://lampsvn.epfl.ch/trac/scala/browser/scala/branches/jvm-src/

Regards,
Ismael