JDK-8154539 : Examine the desktop module's use of sun.misc.SoftCache
  • Type: Sub-task
  • Component: client-libs
  • Affected Version: 9
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2016-04-19
  • Updated: 2016-05-26
  • Resolved: 2016-05-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b120Fixed
Related Reports
Relates :  
Relates :  
Description
The desktop module has a single remaining dependency on jdk.unsupported, for use of sun.misc.SoftCache. SoftCache
is not a critical API, as defined by JEP 260, nor is it used widely inside or outside the JDK.  In fact, the desktop module
is the only user of it.

jdeps -v java.desktop/* | grep unsupported 
   sun.awt.SunToolkit                                                                   -> sun.misc.SoftCache       JDK internal API (jdk.unsupported)
   sun.awt.image.MultiResolutionToolkitImage                            -> sun.misc.SoftCache       JDK internal API (jdk.unsupported)
   sun.awt.image.MultiResolutionToolkitImage$ObserverCache -> sun.misc.SoftCache       JDK internal API (jdk.unsupported)

If the desktop module needs the functionality provided by SoftCache, then it should be moved to an appropriate internal
package in the desktop module.
Comments
Proposed fix: http://cr.openjdk.java.net/~alexsch/8154539/webrev.00 Fix review thread: http://mail.openjdk.java.net/pipermail/awt-dev/2016-May/011244.html
11-05-2016

For now, it might be best to just move sun.misc.SoftCache to a package in the desktop module. Further refactoring, or cleanup, then then be done from there. [~alexsch] is this something that you can do ?
09-05-2016

> You can write a simple Map<K, SoftReference<V>> in a few lines of code. Is there a new API which provides soft cache in JDK 9? What about JSR 107: JCACHE - Java Temporary Caching API ? https://jcp.org/en/jsr/detail?id=107
28-04-2016

Wow JDK-4242721 is really old. You can write a simple Map<K, SoftReference<V>> in a few lines of code. JEP 260 completion should not be blocked on this minor issue. It may be necessary to move sun.misc.SoftCache to the desktop module, for now, and it can be refactored in the future, at leisure.
28-04-2016

See the open enhancement: JDK-4242721 Wanted: java.util.Cache class The cache from JDK-4242721 is useful to reuse in the current fix.
28-04-2016

The usage of sun.misc.SoftCache in the desktop module appears to be straight forward, put(), get(), contains(). It could probably be implemented much more easily from scratch, and just remove sun.misc.SoftCache. Maybe Map<K, SoftReference<V>>.
19-04-2016