src/macosx/classes/com/apple/laf/AquaUtils.java

Print this page

        

*** 175,194 **** protected abstract T create(); } abstract static class RecyclableSingleton<T> { final T get() { ! final AppContext appContext = AppContext.getAppContext(); ! SoftReference<T> ref = (SoftReference<T>) appContext.get(this); ! if (ref != null) { ! final T object = ref.get(); ! if (object != null) return object; ! } ! final T object = getInstance(); ! ref = new SoftReference<T>(object); ! appContext.put(this, ref); ! return object; } void reset() { AppContext.getAppContext().remove(this); } --- 175,185 ---- protected abstract T create(); } abstract static class RecyclableSingleton<T> { final T get() { ! return AppContext.getSoftReferenceValue(this, () -> getInstance()); } void reset() { AppContext.getAppContext().remove(this); }