title: Java Microstream - Synthetic classes - PersistenceExceptionTypeNotPersistable
body: <p>Using Microstream getting the below exception.
  Being caused by a class with a reference to a static inner class.
  How do I resolve this issue?</p>
  <p>The exception states the following, but the documentation doesn't explain how to implement a <strong>PersistenceTypeResolver</strong></p>
  <blockquote>
  <p>Details: Synthetic classes ($1 etc.) are not reliably persistence since a simple reordering of source code elements would change the name identity of a class. For a type system that has to rely upon resolving types by their identifying name, this would silently cause a potentially fatal error. If handling synthetic classes (e.g. anonymous inner classes) is absolutely necessary, a custom one.microstream.persistence.types.PersistenceTypeResolver can be used to remove the exception and assume  complete responsibility for correctly handling synthetic class names.
  at one.microstream.persistence.types.Persistence.derivePersistentTypeName(Persistence.java:1083)</p>
  </blockquote>
  <pre><code>    public static final AbstractAccompanyingPassenger DUMMY = new AbstractAccompanyingPassenger(MetaDataAccompanyingType.DUMMY) {
          @Override
          public AbstractAccompanyingPassenger clone() {
              return DUMMY;
          }};
  </code></pre>
  <pre><code>Caused by: one.microstream.persistence.exceptions.PersistenceExceptionTypeNotPersistable: Type not persistable: &quot;class net.atpco.metadata.summary.accompanied.MetaDataAccompanying$1&quot;. Details: Synthetic classes ($1 etc.) are not reliably persistence since a simple reordering of source code elements would change the name identity of a class. For a type system that has to rely upon resolving types by their identifying name, this would silently cause a potentially fatal error. If handling synthetic classes (e.g. anonymous inner classes) is absolutely necessary, a custom one.microstream.persistence.types.PersistenceTypeResolver can be used to remove the exception and assume  complete responsibility for correctly handling synthetic class names.
      at one.microstream.persistence.types.Persistence.derivePersistentTypeName(Persistence.java:1083)
      at one.microstream.persistence.types.PersistenceTypeResolver.deriveTypeName(PersistenceTypeResolver.java:17)
      at one.microstream.persistence.types.PersistenceTypeHandlerCreator$Abstract.deriveTypeName(PersistenceTypeHandlerCreator.java:73)
      at one.microstream.persistence.binary.types.BinaryTypeHandlerCreator$Default.internalCreateTypeHandlerGeneric(BinaryTypeHandlerCreator.java:238)
      at one.microstream.persistence.types.PersistenceTypeHandlerCreator$Abstract.createTypeHandlerGeneric(PersistenceTypeHandlerCreator.java:168)
      at one.microstream.persistence.types.PersistenceTypeHandlerEnsurer$Default.ensureTypeHandler(PersistenceTypeHandlerEnsurer.java:199)
      at one.microstream.persistence.internal.PersistenceTypeHandlerProviderCreating.ensureTypeHandler(PersistenceTypeHandlerProviderCreating.java:170)
      at one.microstream.persistence.internal.PersistenceTypeHandlerProviderCreating.provideTypeHandler(PersistenceTypeHandlerProviderCreating.java:78)
      at one.microstream.persistence.types.PersistenceTypeHandlerManager$Default.internalEnsureTypeHandler(PersistenceTypeHandlerManager.java:587)
      at one.microstream.persistence.types.PersistenceTypeHandlerManager$Default.ensureTypeHandler(PersistenceTypeHandlerManager.java:357)
      at one.microstream.persistence.types.PersistenceTypeHandlerManager$Default.ensureTypeHandler(PersistenceTypeHandlerManager.java:333)
      at one.microstream.persistence.binary.types.BinaryStorer$Default.registerGuaranteed(BinaryStorer.java:557)
      at one.microstream.persistence.binary.types.BinaryStorer$Default.registerLazyOptional(BinaryStorer.java:572)
      at one.microstream.persistence.types.PersistenceObjectManager$Default.ensureObjectId(PersistenceObjectManager.java:182)
      at one.microstream.persistence.binary.types.BinaryStorer$Default.register(BinaryStorer.java:591)
      at one.microstream.persistence.binary.types.BinaryStorer$Default.apply(BinaryStorer.java:298)
      at one.microstream.persistence.binary.types.BinaryValueFunctions$9.storeValueFromMemory(BinaryValueFunctions.java:147)
      at one.microstream.persistence.binary.types.Binary.storeFixedSize(Binary.java:1149)
      at one.microstream.persistence.binary.internal.AbstractBinaryHandlerReflective.store(AbstractBinaryHandlerReflective.java:497)
      at one.microstream.persistence.binary.internal.AbstractBinaryHandlerReflective.store(AbstractBinaryHandlerReflective.java:1)
      at one.microstream.persistence.binary.types.BinaryStorer$Default.storeItem(BinaryStorer.java:414)
      at one.microstream.persistence.binary.types.BinaryStorer$Default.storeGraph(BinaryStorer.java:403)
      at one.microstream.persistence.binary.types.BinaryStorer$Default.store(BinaryStorer.java:421)
      at one.microstream.persistence.types.PersistenceManager$Default.store(PersistenceManager.java:274)
      at one.microstream.storage.types.StorageConnection.store(StorageConnection.java:306)
      at one.microstream.cache.CacheStore$Default.write(CacheStore.java:112)
  
  </code></pre>