本文整理汇总了Java中sun.jvm.hotspot.runtime.VM.Flag方法的典型用法代码示例。如果您正苦于以下问题:Java VM.Flag方法的具体用法?Java VM.Flag怎么用?Java VM.Flag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.jvm.hotspot.runtime.VM
的用法示例。
在下文中一共展示了VM.Flag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doit
import sun.jvm.hotspot.runtime.VM; //导入方法依赖的package包/类
public void doit(Tokens t) {
int tokens = t.countTokens();
if (tokens != 0 && tokens != 1) {
usage();
} else {
String name = tokens > 0 ? t.nextToken() : null;
boolean nonDefault = false;
if (name != null && name.equals("-nd")) {
name = null;
nonDefault = true;
}
VM.Flag[] flags = VM.getVM().getCommandLineFlags();
if (flags == null) {
out.println("Command Flag info not available (use 1.4.1_03 or later)!");
} else {
boolean printed = false;
for (int f = 0; f < flags.length; f++) {
VM.Flag flag = flags[f];
if (name == null || flag.getName().equals(name)) {
if (nonDefault && flag.getOrigin() == 0) {
// only print flags which aren't their defaults
continue;
}
out.println(flag.getName() + " = " + flag.getValue() + " " + flag.getOrigin());
printed = true;
}
}
if (name != null && !printed) {
out.println("Couldn't find flag: " + name);
}
}
}
}
示例2: printVMFlags
import sun.jvm.hotspot.runtime.VM; //导入方法依赖的package包/类
private void printVMFlags() {
VM.Flag[] flags = VM.getVM().getCommandLineFlags();
System.out.print("Non-default VM flags: ");
for (VM.Flag flag : flags) {
if (flag.getOrigin() == 0) {
// only print flags which aren't their defaults
continue;
}
if (flag.isBool()) {
String onoff = flag.getBool() ? "+" : "-";
System.out.print("-XX:" + onoff + flag.getName() + " ");
} else {
System.out.print("-XX:" + flag.getName() + "="
+ flag.getValue() + " ");
}
}
System.out.println();
System.out.print("Command line: ");
String str = Arguments.getJVMFlags();
if (str != null) {
System.out.print(str + " ");
}
str = Arguments.getJVMArgs();
if (str != null) {
System.out.print(str);
}
System.out.println();
}