title: java.lang.StackOverflowError when trying to optimize Java+Scala with ProGuard
body: <p>I have an applet, which I was writing in Java. Recently, I thought that it would be good to add some Scala code to it (since Scala has good interoperability with Java). Everything works fine, but when I try to optimize the resulting jars using <a href="http://proguard.sourceforge.net/" rel="nofollow" >ProGuard</a>, I have java.lang.StackOverflowError. How can I fix it?</p>
  
  <p>Error:</p>
  
  <pre><code>The following error occurred while executing this line:
  /var/www/parrot/Parrot/build.xml:84: 
  java.lang.StackOverflowError
      at proguard.classfile.util.SimplifiedVisitor.visitProgramClass(SimplifiedVisitor.java:53)
      at proguard.optimize.info.StaticInitializerContainingClassFilter.visitProgramClass(StaticInitializerContainingClassFilter.java:50)
      at proguard.classfile.ProgramClass.accept(ProgramClass.java:280)
      at proguard.classfile.ProgramClass.hierarchyAccept(ProgramClass.java:293)
      at proguard.classfile.ProgramClass.hierarchyAccept(ProgramClass.java:333)
      at proguard.classfile.ProgramClass.hierarchyAccept(ProgramClass.java:333)
      at proguard.classfile.ProgramClass.hierarchyAccept(ProgramClass.java:333)
      ... and so on, several thousand times ...
  </code></pre>
  
  <p>My ant configuration for proguard:</p>
  
  <pre><code>&lt;proguard
      optimizationpasses="${optpass}"
      obfuscate="true"
      verbose="true"
      target="6"
      printseeds="true"
      allowaccessmodification="true"
      overloadaggressively="true"
      mergeinterfacesaggressively="true"
      repackageclasses="def"
      &gt;
  
      &lt;injar file="dist/Parrot.jar" /&gt;
      &lt;injar path="dist/lib/" /&gt;&lt;!-- scala-library.jar is also in this lib directory --&gt;
      &lt;libraryjar path="/home/platon/java/jdk1.6.0_24/jre/lib/" /&gt;
      &lt;outjar file="dist/ParrotOp.jar" filter="!**.SF" /&gt;
  
      &lt;keep access="public" name="launch.parrotApp" /&gt;
  
      &lt;keepclassmembers extends="java.lang.Enum"&gt;
          &lt;method access="public static"
              type="**[]"
              name="values"
              parameters="" /&gt;
          &lt;method access="public static"
              type="**"
              name="valueOf"
              parameters="java.lang.String" /&gt;
      &lt;/keepclassmembers&gt;
  
          &lt;!-- Processing the scala library (as shown in proguard manual) --&gt;
          -dontwarn **$$anonfun$*
          -dontwarn scala.collection.immutable.RedBlack$Empty
          -dontwarn scala.tools.**,plugintemplate.**
  
          -keepclasseswithmembers public class * {
              public static void main(java.lang.String[]);
          }
  
          -keep class * implements org.xml.sax.EntityResolver
  
          -keepclassmembers class * {
              ** MODULE$;
          }
  
          -keepclassmembernames class scala.concurrent.forkjoin.ForkJoinPool {
              long eventCount;
              int  workerCounts;
              int  runControl;
              scala.concurrent.forkjoin.ForkJoinPool$WaitQueueNode syncStack;
              scala.concurrent.forkjoin.ForkJoinPool$WaitQueueNode spareStack;
          }
  
          -keepclassmembernames class scala.concurrent.forkjoin.ForkJoinWorkerThread {
              int base;
              int sp;
              int runState;
          }
  
          -keepclassmembernames class scala.concurrent.forkjoin.ForkJoinTask {
              int status;
          }
  
          -keepclassmembernames class scala.concurrent.forkjoin.LinkedTransferQueue {
              scala.concurrent.forkjoin.LinkedTransferQueue$PaddedAtomicReference head;
              scala.concurrent.forkjoin.LinkedTransferQueue$PaddedAtomicReference tail;
              scala.concurrent.forkjoin.LinkedTransferQueue$PaddedAtomicReference cleanMe;
          }
  
      &lt;/proguard&gt;
  </code></pre>
  
  <p>And by the way - there is nothing fancy about Scala code there, actually it is just as simple as</p>
  
  <pre><code>package scala1
  object Main {
      def sum = 14
  }
  </code></pre>
  
  <p>which is called from java:</p>
  
  <pre><code>System.err.println(scala1.Main.sum());
  </code></pre>