code: public static <K, V> Map<K, V> checkedMap(Map<K, V> m,
                                                Class<K> keyType,
                                                Class<V> valueType) {
          return new CheckedMap<>(m, keyType, valueType);
      }
docs: Returns a dynamically typesafe view of the specified map.
  Any attempt to insert a mapping whose key or value have the wrong
  type will result in an immediate {@link ClassCastException}.
  Similarly, any attempt to modify the value currently associated with
  a key will result in an immediate {@link ClassCastException},
  whether the modification is attempted directly through the map
  itself, or through a {@link Map.Entry} instance obtained from the
  map's {@link Map#entrySet() entry set} view.
  
  <p>Assuming a map contains no incorrectly typed keys or values
  prior to the time a dynamically typesafe view is generated, and
  that all subsequent access to the map takes place through the view
  (or one of its collection views), it is <i>guaranteed</i> that the
  map cannot contain an incorrectly typed key or value.
  
  <p>A discussion of the use of dynamically typesafe views may be
  found in the documentation for the {@link #checkedCollection
  checkedCollection} method.
  
  <p>The returned map will be serializable if the specified map is
  serializable.
  
  <p>Since {@code null} is considered to be a value of any reference
  type, the returned map permits insertion of null keys or values
  whenever the backing map does.
  
  @param <K> the class of the map keys
  @param <V> the class of the map values
  @param m the map for which a dynamically typesafe view is to be
  returned
  @param keyType the type of key that {@code m} is permitted to hold
  @param valueType the type of value that {@code m} is permitted to hold
  @return a dynamically typesafe view of the specified map
  @since 1.5