4632N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 4632N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4632N/A * This code is free software; you can redistribute it and/or modify it 4632N/A * under the terms of the GNU General Public License version 2 only, as 4632N/A * published by the Free Software Foundation. Oracle designates this 4632N/A * particular file as subject to the "Classpath" exception as provided 4632N/A * by Oracle in the LICENSE file that accompanied this code. 4632N/A * This code is distributed in the hope that it will be useful, but WITHOUT 4632N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 4632N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 4632N/A * version 2 for more details (a copy is included in the LICENSE file that 4632N/A * You should have received a copy of the GNU General Public License version 4632N/A * 2 along with this work; if not, write to the Free Software Foundation, 4632N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 4632N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 4632N/A * or visit www.oracle.com if you need additional information or have any 4632N/A * This keeps track of data that needs to be cleaned up once a 4632N/A * a) The native memory that is the glyph image cache. 4632N/A * b) removing the "desc" key from the strike's map. 4632N/A * This is safe to do because this disposer is invoked only when the 4632N/A * reference object has been cleared, which means the value indexed by 4632N/A * this key is just an empty reference object. 4632N/A * It is possible that a new FontStrike has been created that would 4632N/A * be referenced by the same (equals) key. If it is placed in the map 4632N/A * before this disposer is executed, then we do not want to remove that 4632N/A * object. We should only remove an object where the value is null. 4632N/A * So we first verify that the key still points to a cleared reference. 4632N/A * Updates to the map thus need to be synchronized. 4632N/A * A WeakHashmap will automatically clean up, but we might maintain a 4632N/A * reference to the "desc" key in the FontStrike (value) which would 4632N/A * prevent the keys from being discarded. And since the strike is the only 4632N/A * place is likely we would maintain such a strong reference, then the map 4632N/A * entries would be removed much more promptly than we need.