use of org.openjdk.jol.info.ClassLayout in project reactor-core by reactor.
the class QueueDrainSubscriberTest method objectPadding.
@Test
public void objectPadding() {
ClassLayout layout = ClassLayout.parseClass(QueueDrainSubscriber.class);
AtomicReference<FieldLayout> wip = new AtomicReference<>();
AtomicReference<FieldLayout> requested = new AtomicReference<>();
layout.fields().forEach(f -> {
if ("wip".equals(f.name()))
wip.set(f);
else if ("requested".equals(f.name()))
requested.set(f);
});
final FieldLayout fieldAfterRequested = layout.fields().tailSet(requested.get()).stream().skip(1).filter(fl -> fl.name().length() >= 4).findFirst().get();
assertThat(layout.fields().headSet(wip.get())).as("wip pre-padding").hasSize(15).allSatisfy(fl -> assertThat(fl.name()).startsWith("p"));
assertThat(layout.fields().subSet(wip.get(), requested.get()).stream().skip(1)).as("wip-requested padding").hasSize(15).allSatisfy(fl -> assertThat(fl.name()).startsWith("p").endsWith("a"));
assertThat(layout.fields().subSet(requested.get(), fieldAfterRequested).stream().skip(1)).as("requested post-padding").hasSize(15).allSatisfy(fl -> assertThat(fl.name()).startsWith("q").isNotEqualTo("queue"));
assertThat(wip.get().offset()).as("wip offset").isEqualTo(136);
assertThat(requested.get().offset()).as("requested offset").isEqualTo(wip.get().offset() + 128);
System.out.println(wip.get());
System.out.println(requested.get());
System.out.println(fieldAfterRequested);
}
use of org.openjdk.jol.info.ClassLayout in project yyl_example by Relucent.
the class JolExample method main.
public static void main(String[] args) {
A a = new A();
ClassLayout aLayout = ClassLayout.parseInstance(a);
System.out.println("**** Fresh object");
System.out.println(aLayout.toPrintable());
synchronized (a) {
System.out.println("**** With the lock");
System.out.println(aLayout.toPrintable());
}
B b = new B();
System.out.println(ClassLayout.parseInstance(b).toPrintable());
Object o = new Object();
System.out.println(ClassLayout.parseInstance(o).toPrintable());
int[] ints = new int[0];
System.out.println(ClassLayout.parseInstance(ints).toPrintable());
Object[] objects = { true, 0.0D, new Object(), null };
System.out.println(ClassLayout.parseInstance(objects).toPrintable());
}
Aggregations