< prev index next > src/java.base/share/classes/jdk/internal/util/ReferencedKeyMap.java
Print this page
/*
! * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
/*
! * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* This class provides management of {@link Map maps} where it is desirable to
* remove entries automatically when the key is garbage collected. This is
* accomplished by using a backing map where the keys are either a
* {@link WeakReference} or a {@link SoftReference}.
* <p>
! * To create a {@link ReferencedKeyMap} the user must provide a {@link Supplier}
* of the backing map and whether {@link WeakReference} or
* {@link SoftReference} is to be used.
*
* {@snippet :
* // Use HashMap and WeakReference
* This class provides management of {@link Map maps} where it is desirable to
* remove entries automatically when the key is garbage collected. This is
* accomplished by using a backing map where the keys are either a
* {@link WeakReference} or a {@link SoftReference}.
* <p>
! * Keys in {@code ReferencedKeyMap} must be
+ * {@linkplain java.util.Objects#hasIdentity identity objects}.
+ * <p>
+ * To create a {@code ReferencedKeyMap} the user must provide a {@link Supplier}
* of the backing map and whether {@link WeakReference} or
* {@link SoftReference} is to be used.
*
* {@snippet :
* // Use HashMap and WeakReference
< prev index next >