Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

netbeans 7.0 and scala results in stackoverflow

I'm experiencing some rather annoying problems with scala. The problem is, that I can compile small scala project perfectly, but when the projects are bigger, the compiler crashes with an StackOverflowException. Clearly, I have to increase the stack size for the compiler, however, that's probably my main problem here, I don't know how.

I'm starting netbeans with these parameters:

netbeans_default_options="-J-client -J-Xmx512m -J-Xss8m -J-Xms512m -J-XX:PermSize=128m -J-XX:MaxPermSize=512m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true"

So, as far as I'm aware, -J-Xss8m should increase the thread stack size to 8 mb. However, that doesn't seem to affect the compiler. So I tried to pass the same parameter to the compiler directly, using the compiler flags, which I can set in netbeans, resulting in this:

-deprecation -J-Xss8m

But again, that doesn't help, I'm still getting the exception. I searched through the netbeans documentation, but all I found was the netbeans startup parameters, which I had already set. I hope somebody here can give me further information on how to handle this problem.

Further information: So, after a day I finally had the chance to try everything out on a different machine. I used the same settings and same compiler, but to my surprise, I didn't get the same result. Meaning, on his machine the compiler compiles the whole code without any exception. The only difference between mine computer and his is, that his has more RAM and CPU power, but that shouldn't make the deal since we both use netbeans with the same startup options.

By now, I even tried out the RC of the 2.9 scala compiler, it didn't help much. Also, I checked if I have the correct scala plugin installed, since there might be problems when using the 2.8 plugin with the 2.9 compiler and vice versa. However, I'm using the 2.9 plugin and 2.9 compiler, so that's fine.

like image 457
Shelling Avatar asked Aug 03 '11 12:08

Shelling


1 Answers

The problem of giving the Scala compiler more stack space is similar to specifying more heap space. Both of these options must be specified as custom JVM arguments when running the Scala compiler. However Netbeans lacks any sort of documentation on how to do it, so here it is.

The way to specify custom JVM arguments for the Scala compiler with Netbeans is by customizing build.xml for each project.

  1. Open nbproject/build-impl.xml in the project's folder.
  2. Search for "scalac" and you will find the following target: -init-macrodef-scalac.
  3. Copy the whole target definition, paste it into your build.xml, and save it.
  4. Close nbproject/build-impl.xml, from now on you will work with build.xml.
  5. In the target you just copied, locate the <scalac> tag, the nesting will be as follows: target.macrodef.sequential.scalac
  6. Add a custom "jvmargs" attribute to the scalac tag, it will look as follows: <scalac jvmargs="-Xss2048k -Xmx2000m" ... >
  7. Save the build.xml. Now whenever you compile your project with netbeans, the compiler will be run with the custom jvm arguments.
like image 58
Lex Avatar answered Sep 17 '22 12:09

Lex