The Method objects in the delegateMethods map cannot be serialized, which means that deep copies fail. So here,
we clear the map when serialization occurs. The map is re-build later on demand.
19917
private void writeObject(java.io.ObjectOutputStream out) throws IOException
	{
		if (delegateMethods != null)
		{
			delegateMethods.clear();
		}

		out.defaultWriteObject();
	}
993948
protected synchronized void clear()
                    throws ObjectManagerException
    {
        final String methodName = "clear";
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this, cclass, methodName);

        super.clear();
        inMemoryManagedObjects = new ConcurrentHashMap(concurrency);

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this, cclass, "clear");
    }
374
@Override
  public void clear() {
    // iterate over all keys in originalMap and set them to null in deltaMap
    for (K key : originalMap.keySet()) {
      deltaMap.put(key, ErasureUtils.<Collection<V>>uncheckedCast(removedValue));
    }
  }
177207
@Override
  public void putAll(Map<? extends TypeK, ? extends TypeV> m) {
    for (Map.Entry<? extends TypeK, ? extends TypeV> e : m.entrySet())
      put(e.getKey(), e.getValue());
  }

  /** Removes all of the mappings from this map. */
  @Override
  public void clear() {         // Smack a new empty table down
    Object[] newkvs = new NonBlockingHashMap(MIN_SIZE)._kvs;
    while( !CAS_kvs(_kvs,newkvs) ) // Spin until the clear works
      ;
  }

  /** Returns <tt>true</tt> if this Map maps one or more keys to the specified
   *  value.  <em>Note</em>: This method requires a full internal traversal of the
   *  hash table and is much slower than {@link #containsKey}.
   *  @param val value whose presence in this map is to be tested
   *  @return <tt>true</tt> if this map maps one or more keys to the specified value
   *  @throws NullPointerException if the specified value is null */
  @Override
  public boolean containsValue( final Object val ) {
    if( val == null ) throw new NullPointerException();
    for( TypeV V : values() )
      if( V == val || V.equals(val) )
        return true;
    return false;
  }

  // This function is supposed to do something for Hashtable, and the JCK
  // tests hang until it gets called... by somebody ... for some reason,
  // any reason....
  protected void rehash() {
  }

  /**
   * Creates a shallow copy of this hashtable. All the structure of the
   * hashtable itself is copied, but the keys and values are not cloned.
   * This is a relatively expensive operation.
   *
   * @return  a clone of the hashtable.
   */
  @Override
  public Object clone() {
    try {
      // Must clone, to get the class right; NBHM might have been
      // extended so it would be wrong to just make a new NBHM.
      NonBlockingHashMap<TypeK,TypeV> t = (NonBlockingHashMap<TypeK,TypeV>) super.clone();
      // But I don't have an atomic clone operation - the underlying _kvs
      // structure is undergoing rapid change.  If I just clone the _kvs
      // field, the CHM in _kvs[0] won't be in sync.
      //
      // Wipe out the cloned array (it was shallow anyways).
      t.clear();
      // Now copy sanely
      for( TypeK K : keySet() ) {
        final TypeV V = get(K);  // Do an official 'get'
        t.put(K,V);
      }
      return t;
    } catch (CloneNotSupportedException e) {
      // this shouldn't happen, since we are Cloneable
      throw new InternalError();
    }
  }

  /**
   * Returns a string representation of this map.  The string representation
   * consists of a list of key-value mappings in the order returned by the
   * map's <tt>entrySet</tt> view's iterator, enclosed in braces
   * (<tt>"{}"</tt>).  Adjacent mappings are separated by the characters
   * <tt>", "</tt> (comma and space).  Each key-value mapping is rendered as
   * the key followed by an equals sign (<tt>"="</tt>) followed by the
   * associated value.  Keys and values are converted to strings as by
   * {@link String#valueOf(Object)}.
   *
   * @return a string representation of this map
   */
  @Override
  public String toString() {
    Iterator<Entry<TypeK,TypeV>> i = entrySet().iterator();
    if( !i.hasNext())
      return "{}";

    StringBuilder sb = new StringBuilder();
    sb.append('{');
    for (;;) {
      Entry<TypeK,TypeV> e = i.next();
      TypeK key = e.getKey();
      TypeV value = e.getValue();
      sb.append(key   == this ? "(this Map)" : key);
      sb.append('=');
      sb.append(value == this ? "(this Map)" : value);
      if( !i.hasNext())
        return sb.append('}').toString();
      sb.append(", ");
    }
  }

  // --- keyeq ---------------------------------------------------------------
  // Check for key equality.  Try direct pointer compare first, then see if
  // the hashes are unequal (fast negative test) and finally do the full-on
  // 'equals' v-call.
  private static boolean keyeq( Object K, Object key, int[] hashes, int hash, int fullhash ) {
    return
      K==key ||                 // Either keys match exactly OR
      // hash exists and matches?  hash can be zero during the install of a
      // new key/value pair.
      ((hashes[hash] == 0 || hashes[hash] == fullhash) &&
       // Do not call the users' "equals()" call with a Tombstone, as this can
       // surprise poorly written "equals()" calls that throw exceptions
       // instead of simply returning false.
       K != TOMBSTONE &&        // Do not call users' equals call with a Tombstone
       // Do the match the hard way - with the users' key being the loop-
       // invariant "this" pointer.  I could have flipped the order of
       // operands (since equals is commutative), but I'm making mega-morphic
       // v-calls in a reprobing loop and nailing down the 'this' argument
       // gives both the JIT and the hardware a chance to prefetch the call target.
       key.equals(K));          // Finally do the hard match
  }
59026
public synchronized void setDelegateMap(PropertyMap delegateMap)
    {
        if (!isCompatibleClass(delegateMap.getMapClass()))
            throw new IllegalArgumentException("The delegate map type (" + delegateMap.getMapClass() + " is an incompatible type with " + _mapClass);

        _delegateMap = delegateMap;
    }
899311
@Override
	public byte[] serializeAttributes(final MemcachedBackupSession sessions, final ConcurrentMap<String, Object> attributes) {
		if (attributes == null) {
        	throw new NullPointerException();
        }

        final ByteArrayOutputStream bos = new ByteArrayOutputStream();
        try {
        	// This performs a deep serialization of the target instance.
            // It's serialized to a string as flexjson doesn't like writing to
            // an OutputStreamWriter: it throws the exception "Stepping back two steps is not supported".
            // See https://github.com/moresandeep/memcached-session-manager/commit/db2faaa0a846e16d65ac0b14819689c67bf92c68#commitcomment-512505
        	final String serResult = serializer.deepSerialize(attributes);
        	if (LOG.isDebugEnabled()) {
        	    LOG.debug("JSON Serialised object: " + serResult);
        	}
        	return serResult.getBytes(); // converts to bytes
        } catch (final Exception e) {
        	LOG.warn("Caught Exception deserializing JSON " + e);
        	throw new IllegalArgumentException();
        } finally {
        	close(bos);
        }
	}
112716
@Override
    public void serialize(List<Field> auditFields, Object object,
            String objectName,  DeIdentify deidentify) {
        visited.clear();
       toFields(auditFields, object, objectName, deidentify);
    }
975840
private synchronized void writeObject(ObjectOutputStream oos)
        throws IOException
    {
        if (_control != null)
        {
            //
            // If the implementation class is marked as transient/stateless, then reset the
            // reference to it prior to serialization.  A new instance will be created by
            // ensureControl() upon first use after deserialization.
            // If the implementation class is not transient, then invoke the ImplInitializer
            // resetServices method to reset all contextual service references to null, as
            // contextual services should never be serializated and always reassociated on 
            // deserialization.
            //
            ControlImplementation implAnnot = (ControlImplementation)_implClass.getAnnotation(ControlImplementation.class);
            assert implAnnot != null;
            if (implAnnot.isTransient())
            {
                _control = null;
            }
            else
            {
                getImplInitializer().resetServices(this, _control);
                _hasServices = false;
            }
        }

        oos.defaultWriteObject();
    }
1199394
private String _serializeStruct(Struct struct, Map<Object, String> done, String id) throws ConverterException {
	StringBuilder sb = new StringBuilder(goIn() + "<STRUCT ID=\"" + id + "\">");

	Iterator<Key> it = struct.keyIterator();

	deep++;
	while (it.hasNext()) {
	    Key key = it.next();
	    // <ENTRY NAME="STRING" TYPE="STRING">hello</ENTRY>
	    String value = _serialize(struct.get(key, null), done);
	    sb.append(goIn() + "<ENTRY NAME=\"" + key.toString() + "\" TYPE=\"" + type + "\">");
	    sb.append(value);
	    sb.append(goIn() + "</ENTRY>");
	}
	deep--;

	sb.append(goIn() + "</STRUCT>");
	type = "STRUCT";
	return sb.toString();
    }
208481
private Map<String, Object> deserialized() {
        // Written as a loop to prevent the need for locking
        DeserializationState deserState;
        while (!(deserState = _deserState.get()).isDeserialized()) {
            Map<String, Object> deserialized = JsonHelper.fromJson(deserState.json, new TypeReference<Map<String, Object>>() {});
            deserialized.putAll(deserState.overrides);
            DeserializationState newDeserState = new DeserializationState(deserialized);
            _deserState.compareAndSet(deserState, newDeserState);
        }
        return deserState.deserialized;
    }
225422
public static void deepCopy(Object from, Object to) {
		if (from == null) throw new IllegalArgumentException("from must not be null");
		if (to == null) throw new IllegalArgumentException("to must not be null");
		if (from.getClass() != to.getClass()) throw new IllegalArgumentException("from and to must have exactly same class, from has " + from.getClass() + " to has " + to.getClass());

		try {
			_deepCopy(from, to, new ArrayList(), new ArrayList());
		} catch (IllegalAccessException | IllegalArgumentException x) {
			throw new RuntimeException(x);
		}
	}
816266
V removeMapping(final Object o) {
        if (!(o instanceof Map.Entry)) {
            throw new IllegalArgumentException();
        }

        @SuppressWarnings("unchecked") final Entry<? extends CharSequence, V> e = (Map.Entry<? extends CharSequence, V>) o;
        final CharSequence key = keyCheck(e.getKey());
        final V value = e.getValue();
        final TrieNode<V> currentNode = findPreviousNode(key);

        if (currentNode == null) {
			/* Node not found for the given key */
            return null;
        }

        final TrieNode<V> node = currentNode.children.get(key.charAt(key
                .length() - 1));

        if (node == null || !node.inUse) {
			/* Node not found for the given key or is not in use */
            return null;
        }

        final V removed = node.value;

        if (removed != value && (removed == null || !removed.equals(value))) {
			/*
			 * Value in the map differs from the value given in the entry so do
			 * nothing and return null.
			 */
            return null;
        }

        node.unset();
        --size;
        ++modCount;

        if (node.children.isEmpty()) {
			/* Since there are no children left, we can compact the trie */
            compact(key);
        }

        return removed;
    }
942822
private void writeObject(ObjectOutputStream out) throws IOException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, "writeObject : " + this);

        throw new NotSerializableException("This entity manager is not serializable");
    }
83206
@Override
	protected void unserializeFrom(RawDataBuffer in)
    {
        super.unserializeFrom(in);
        sessionId = new IntegerID(in.readInt());
        consumerId = new IntegerID(in.readInt());
        message = MessageSerializer.unserializeFrom(in, false);
        donePrefetching = in.readBoolean();
    }
100047
function serialize (layersCollection, dataviewsCollection) {
  // Named map templates include both http, cartodb and torque layers
  // so we need to iterate through all the layers in the collection to
  // get the indexes rights. Templates are not aware of Google Maps
  // base layers, so we have to ignore them to get indexes right.
  var layers = layersCollection.filter(function (layer) {
    return !LayerTypes.isGoogleMapsBaseLayer(layer);
  });

  return {
    buffersize: {
      mvt: 0
    },
    styles: _getStylesFromLayers(layers)
  };
}
998874
private void deserializeMethod(ObjectInput stream) throws IOException, ClassNotFoundException {
        MethodValues method = null;
        if (SERIALIZATION_V2 == getDeserializationVersion()) {
            method = MethodValues.find(readByteArray(stream));
        } else {
            method = MethodValues.find((String) stream.readObject());
        }
        if (null == method) {
            throw new IOException("Missing method");
        }
        setMethod(method);
    }
492495
private Object saveMap(FacesContext context, Map<Serializable, Object> map) {

        if (map.isEmpty()) {
            if (!component.initialStateMarked()) {
                // only need to propagate the component's delta status when
                // delta tracking has been disabled.  We're assuming that
                // the VDL will reset the status when the view is reconstructed,
                // so no need to save the state if the saved state is the default.
                return new Object[] { component.initialStateMarked() };
            }
            return null;
        }

        Object[] savedState = new Object[map.size() * 2 + 1];

        int i=0;

        for(Map.Entry<Serializable, Object> entry : map.entrySet()) {
            Object value = entry.getValue();
            savedState[i * 2] = entry.getKey();
            if (value instanceof Collection
                  || value instanceof StateHolder
                  || value instanceof Map
                  || !(value instanceof Serializable)) {
                value = saveAttachedState(context,value);
            }
            savedState[i * 2 + 1] = value;
            i++;
        }
        if (!component.initialStateMarked()) {
            savedState[savedState.length - 1] = component.initialStateMarked();
        }
        return savedState;

    }