- private static final class Proxy implements Externalizable {
- @Serial
- private static final long serialVersionUID = 1L;
-
- private byte[] serialized;
-
- // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
- // be able to create instances via reflection.
- @SuppressWarnings("checkstyle:RedundantModifier")
- public Proxy() {
- // For Externalizable
- }
-
- Proxy(final byte[] serialized) {
- this.serialized = requireNonNull(serialized);
- }
-
- @Override
- public void writeExternal(final ObjectOutput out) throws IOException {
- out.writeInt(serialized.length);
- out.write(serialized);
- }
-
- @Override
- public void readExternal(final ObjectInput in) throws IOException {
- serialized = new byte[in.readInt()];
- in.readFully(serialized);
- }
-
- @Serial
- private Object readResolve() {
- // TODO: consider caching instances here
- return new MemberName(new String(serialized, StandardCharsets.UTF_8), serialized);
- }
- }
-
- @Serial