### Question:
DirectSerializationMetadata { public static SerializationMetadata extractMetadata(List<Field> fields) { if (fields.isEmpty()) return EmptyObjectMetadata; Offsets offsets = minMaxOffsets(fields); long totalSize = OBJECT_HEADER_SIZE + offsets.max - offsets.min + 1; return new SerializationMetadata(offsets.min, padToObjectAlignment(totalSize) - OBJECT_HEADER_SIZE); }  static SerializationMetadata extractMetadata(List<Field> fields); static SerializationMetadata extractMetadataForPartialCopy(List<Field> fields);  }### Answer:
@Test public void primitives1Metadata() { unsafeClassHeaderSize64BitCompressedOops(new Primitives1()); SerializationMetadata serializationMetadata = extractMetadata(Introspect.fields(Primitives1.class)); assertEquals(OBJECT_HEADER_SIZE, serializationMetadata.start); assertEquals(4, serializationMetadata.length); }
@Test public void primitives2Metadata() { unsafeClassHeaderSize64BitCompressedOops(new Primitives2()); SerializationMetadata serializationMetadata = extractMetadata(Introspect.fields(Primitives2.class)); assertEquals(OBJECT_HEADER_SIZE, serializationMetadata.start); assertEquals(12, serializationMetadata.length); }
@Test public void primitives3Metadata() { unsafeClassHeaderSize64BitCompressedOops(new Primitives3()); SerializationMetadata serializationMetadata = extractMetadata(Introspect.fields(Primitives3.class)); assertEquals(OBJECT_HEADER_SIZE, serializationMetadata.start); assertEquals(12, serializationMetadata.length); }
@Test public void primitives4Metadata() { unsafeClassHeaderSize64BitCompressedOops(new Primitives4()); SerializationMetadata serializationMetadata = extractMetadata(Introspect.fields(Primitives4.class)); assertEquals(OBJECT_HEADER_SIZE, serializationMetadata.start); assertEquals(4, serializationMetadata.length); }
@Test public void primitives5Metadata() { unsafeClassHeaderSize64BitCompressedOops(new Primitives5()); SerializationMetadata serializationMetadata = extractMetadata(Introspect.fields(Primitives5.class)); assertEquals(OBJECT_HEADER_SIZE, serializationMetadata.start); assertEquals(12, serializationMetadata.length); }
@Test public void primitives6Metadata() { unsafeClassHeaderSize64BitCompressedOops(new Primitives6()); SerializationMetadata serializationMetadata = extractMetadata(Introspect.fields(Primitives6.class)); assertEquals(OBJECT_HEADER_SIZE, serializationMetadata.start); assertEquals(28, serializationMetadata.length); }