我有一個applet,我正在用Java編寫。最近,我認爲向其中添加一些Scala代碼會很好(因爲Scala與Java具有良好的互操作性)。一切工作正常,但當我嘗試使用ProGuard優化生成的罐子時,我有java.lang.StackOverflowError。我該如何解決它?嘗試使用ProGuard優化Java + Scala時java.lang.StackOverflowError
錯誤:
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 ...
我對proguard的蟻配置:
<proguard
optimizationpasses="${optpass}"
obfuscate="true"
verbose="true"
target="6"
printseeds="true"
allowaccessmodification="true"
overloadaggressively="true"
mergeinterfacesaggressively="true"
repackageclasses="def"
>
<injar file="dist/Parrot.jar" />
<injar path="dist/lib/" /><!-- scala-library.jar is also in this lib directory -->
<libraryjar path="/home/platon/java/jdk1.6.0_24/jre/lib/" />
<outjar file="dist/ParrotOp.jar" filter="!**.SF" />
<keep access="public" name="launch.parrotApp" />
<keepclassmembers extends="java.lang.Enum">
<method access="public static"
type="**[]"
name="values"
parameters="" />
<method access="public static"
type="**"
name="valueOf"
parameters="java.lang.String" />
</keepclassmembers>
<!-- Processing the scala library (as shown in proguard manual) -->
-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;
}
</proguard>
順便說一句 - 有什麼特別之處Scala代碼出現,其實它只是作爲
一樣簡單package scala1
object Main {
def sum = 14
}
這是從java調用:
System.err.println(scala1.Main.sum());
我在我的Android項目中遇到了同樣的問題,但我從來沒有設置過-mergeinterfacesaggressively,所以我有點不知所措。 – 2012-07-09 04:18:49
@ChristopherPerry - 您是否嘗試關閉其他開關並使用簡化的代碼片段?也許還有其他一些事情會阻礙我們。 – Rogach 2012-07-09 11:01:14