@Test
  public void accessListSize() {
    System.setProperty("jol.magicFieldOffset", "true");

    final AccessListEntry ale1 =
        new AccessListEntry(Address.extract(Bytes32.random()), List.of(Bytes32.random()));

    final List<AccessListEntry> ales = List.of(ale1);

    TransactionTestFixture preparedTx =
        prepareTransaction(
            TransactionType.ACCESS_LIST, 0, Wei.of(500), Wei.ZERO, 0, 0, BlobType.KZG_PROOF, null);
    Transaction txAccessList = preparedTx.accessList(ales).createTransaction(KEYS1);
    BytesValueRLPOutput rlpOut = new BytesValueRLPOutput();
    txAccessList.writeTo(rlpOut);

    txAccessList =
        Transaction.readFrom(new BytesValueRLPInput(rlpOut.encoded(), false)).detachedCopy();
    System.out.println(txAccessList.getSender());
    System.out.println(txAccessList.getHash());
    System.out.println(txAccessList.getSize());

    final var optAL = txAccessList.getAccessList();

    final ClassLayout optionalClassLayout = ClassLayout.parseInstance(optAL);
    System.out.println(optionalClassLayout.toPrintable());
    System.out.println("Optional size: " + optionalClassLayout.instanceSize());

    final ClassLayout listClassLayout = ClassLayout.parseInstance(optAL.get());
    System.out.println(listClassLayout.toPrintable());
    System.out.println(
        "Optional + list size: "
            + (optionalClassLayout.instanceSize() + listClassLayout.instanceSize()));

    assertThat(optionalClassLayout.instanceSize() + listClassLayout.instanceSize())
        .isEqualTo(OPTIONAL_ACCESS_LIST_SHALLOW_SIZE);

    final AccessListEntry ale = optAL.get().get(0);

    long aleSize = sizeOfField(ale, "storageKeys.elementData[");

    System.out.println("AccessListEntry container size: " + aleSize);

    assertThat(aleSize).isEqualTo(ACCESS_LIST_ENTRY_SHALLOW_SIZE);

    final Bytes32 storageKey = ale.storageKeys().get(0);
    final ClassLayout cl4 = ClassLayout.parseInstance(storageKey);
    System.out.println(cl4.toPrintable());
    System.out.println("Single storage key size: " + cl4.instanceSize());

    assertThat(cl4.instanceSize()).isEqualTo(ACCESS_LIST_STORAGE_KEY_SIZE);
  }
Field which value is dynamic and can only be calculated at runtime
ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/PendingTransactionEstimatedMemorySizeTest.java