我有一个applet,我用Java编写。最近,我认为向它添加一些Scala代码会很好(因为Scala与Java具有良好的互操作性)。一切正常,但当我尝试使用ProGuard优化生成的jar时,我有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());
答案 0 :(得分:2)
有一个与此相关的已知问题;见this troubleshooting link。
然而,链接正在谈论复杂的代码。您的代码看起来很简单。
答案 1 :(得分:1)
我玩过proguard配置,发现如果我将“mergeinterfacesaggressively”设置为“false”,一切都会开始工作。
我会通知图书馆老板这个,我希望这个问题可以帮助别人。