我们使用InstallAnywhere来创建安装程序。最近使用它创建的安装程序启动失败并出现StackOverFlow错误(在静默安装中)。错误堆栈有数千行,如下所示。
java.lang.StackOverflowError
at com.zerog.ia.installer.util.VariableManager.substitute(Unknown Source)
at com.zerog.ia.installer.util.VariableFacade.substitute(Unknown Source)
at com.zerog.ia.installer.util.VariableFacade.substitute(Unknown Source)
at com.zerog.ia.installer.util.magicfolders.MagicFolder.getPath(Unknown Source)
at com.zerog.ia.installer.util.magicfolders.MagicFolder.toString(Unknown Source)
at com.zerog.ia.installer.util.VariableManager.getValueOfVariable(Unknown Source)
at com.zerog.ia.installer.util.IAVariableStringResolver.getValueOfVariable(Unknown Source)
at com.zerog.ia.installer.util.VariableManager.substitute(Unknown Source)
VariableManager.substitute是非常常见的API,它接受一个字符串参数并返回替换(评估)的值。如何在真正的JVM进程中看到传递给它的参数?
答案 0 :(得分:1)
解决方案是使用btrace script.
安装程序进程是Java进程,可以通过JVM工具查询,如(jps,jstack)
将以下btrace脚本复制到btrace控制台
package com.sun.btrace.samples;
import com.sun.btrace.BTraceUtils;
import com.sun.btrace.Profiler;
import com.sun.btrace.annotations.*;
import com.sun.btrace.*;
@BTrace class Profiling {
@Property
Profiler swingProfiler = BTraceUtils.Profiling.newProfiler();
@OnMethod(
clazz="com.zerog.ia.installer.util.VariableFacade",
method="/.*substitute.*/")
void entry( String probeMethod) {
BTraceUtils.print("Entry" );
BTraceUtils.println(BTraceUtils.timestamp() );
BTraceUtils.println(probeMethod);
}
@OnMethod(
clazz="com.zerog.ia.installer.*",
method="/.*/")
void entry2( @ProbeMethodName(fqn=true) String probeMethod ) {
BTraceUtils.print("Entry" );
BTraceUtils.println(BTraceUtils.timestamp() );
BTraceUtils.println(probeMethod);
}
@OnMethod(clazz = "com.zerog.ia.installer.*", method = "/.*/", location = @Location(Kind.RETURN))
void onPrepareReturn(AnyType arg) {
if (arg != null) {
BTraceUtils.println(arg);
}
}
}
观察日志输出。
Btrace是一个非常强大的工具,可以快速检查JVM内部。在Btrace Kenai project
了解详情来自@ J.B的编辑评论 Btrace is now at github