MPS 2026.1 Help

Custom Containers

Custom containers are a way to provide your own implementation of standard container types, enabling extensibility of the collections language.

Example: weakHashMap

Provided the following declaration is reachable from the model currently being edited...

custom containers WeakCollections { public container weakHashMap<K, V> specifies map<K, V> { runtime type: WeakHashMap<K, V> factory: <no factory> } public container weakHashSet<E> specifies set<E> { runtime type: WeakSet<E> factory: <no factory> } }

... you can use the weak version of hashmap like this:

map<Object, int> myMap= new weakHashMap<Object, int>;

Custom Containers Declaration

A root node of concept CustomContainers may have one or more declarations.

[public|protected|private] container containerName<TypeVar, ...> specifies container_type<TypeVar, ...> { runtime type: Classifier<TypeVar, ...> factory: expression of type Classifier<> (optional) }

declaration part

allowed contents

containerName

any valid identifier

container_type

one of the existing container types of the collections language

runtime type

Java classifier that represents the implementation of the container

factory

(optional) container creation expression;

the classifier's default constructor used if undefined

06 May 2026