本文整理汇总了Java中org.openjdk.jol.info.ClassLayout.parseInstance方法的典型用法代码示例。如果您正苦于以下问题:Java ClassLayout.parseInstance方法的具体用法?Java ClassLayout.parseInstance怎么用?Java ClassLayout.parseInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openjdk.jol.info.ClassLayout
的用法示例。
在下文中一共展示了ClassLayout.parseInstance方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.openjdk.jol.info.ClassLayout; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
out.println(VM.current().details());
TimeUnit.SECONDS.sleep(6);
final A a = new A();
ClassLayout layout = ClassLayout.parseInstance(a);
out.println("**** Fresh object");
out.println(layout.toPrintable());
synchronized (a) {
out.println("**** With the lock");
out.println(layout.toPrintable());
}
out.println("**** After the lock");
out.println(layout.toPrintable());
}
示例2: main
import org.openjdk.jol.info.ClassLayout; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
out.println(VM.current().details());
final A a = new A();
ClassLayout layout = ClassLayout.parseInstance(a);
out.println("**** Fresh object");
out.println(layout.toPrintable());
synchronized (a) {
out.println("**** With the lock");
out.println(layout.toPrintable());
}
out.println("**** After the lock");
out.println(layout.toPrintable());
}
示例3: main
import org.openjdk.jol.info.ClassLayout; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
out.println(VM.current().details());
PrintWriter pw = new PrintWriter(System.out, true);
Object o = new Object();
ClassLayout layout = ClassLayout.parseInstance(o);
long lastAddr = VM.current().addressOf(o);
pw.printf("Fresh object is at %x%n", lastAddr);
int moves = 0;
for (int i = 0; i < 100000; i++) {
long cur = VM.current().addressOf(o);
if (cur != lastAddr) {
moves++;
pw.printf("*** Move %2d, object is at %x%n", moves, cur);
out.println(layout.toPrintable());
lastAddr = cur;
}
// make garbage
for (int c = 0; c < 10000; c++) {
sink = new Object();
}
}
pw.close();
}
示例4: main
import org.openjdk.jol.info.ClassLayout; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
out.println(VM.current().details());
final A a = new A();
ClassLayout layout = ClassLayout.parseInstance(a);
out.println("**** Fresh object");
out.println(layout.toPrintable());
Thread t = new Thread(new Runnable() {
@Override
public void run() {
synchronized (a) {
try {
TimeUnit.SECONDS.sleep(10);
} catch (InterruptedException e) {
return;
}
}
}
});
t.start();
TimeUnit.SECONDS.sleep(1);
out.println("**** Before the lock");
out.println(layout.toPrintable());
synchronized (a) {
out.println("**** With the lock");
out.println(layout.toPrintable());
}
out.println("**** After the lock");
out.println(layout.toPrintable());
System.gc();
out.println("**** After System.gc()");
out.println(layout.toPrintable());
}
示例5: main
import org.openjdk.jol.info.ClassLayout; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
out.println(VM.current().details());
final A a = new A();
ClassLayout layout = ClassLayout.parseInstance(a);
out.println("**** Fresh object");
out.println(layout.toPrintable());
out.println("hashCode: " + Integer.toHexString(a.hashCode()));
out.println();
out.println("**** After identityHashCode()");
out.println(layout.toPrintable());
}
示例6: layout
import org.openjdk.jol.info.ClassLayout; //导入方法依赖的package包/类
public static ClassLayout layout(Object instance) {
return ClassLayout.parseInstance(instance);
}