use of org.openjdk.jol.info.FieldLayout 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);
}
Aggregations