JDK-8147544 : Remove sun.misc.ManagedLocalsThread from java.desktop
  • Type: Sub-task
  • Component: client-libs
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2016-01-18
  • Updated: 2016-04-28
  • Resolved: 2016-04-04
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 b116Fixed
Related Reports
Relates :  
Description
JDK-8056152 added a new constructor to java.lang.Thread to constructing Threads that do not
inherit inheritable thread-local initial values. All usages of sun.misc.ManagedLocalsThread in
the base module were also replaced with this new constructor. Given there is now a supported API
for creating such threads, other areas of the JDK should be updated to use it, where applicable. If all
usages are replaced, then sun.misc.ManagedLocalsThread can be removed. 

jdk/src/java.desktop$ find . -name "*.java" -exec grep ManagedLocalsThread {} \; -print
import sun.misc.ManagedLocalsThread;
        Thread th = new ManagedLocalsThread(runnable);
./share/classes/javax/swing/JTable.java
import sun.misc.ManagedLocalsThread;
                    Thread timerThread = new ManagedLocalsThread(threadGroup,
./share/classes/javax/swing/TimerQueue.java
import sun.misc.ManagedLocalsThread;
                new ManagedLocalsThread(runnablePrinting).start();
./share/classes/javax/swing/text/JTextComponent.java
import sun.misc.ManagedLocalsThread;
            worker = new ManagedLocalsThread(workerRunnable, "text-layout");
./share/classes/javax/swing/text/LayoutQueue.java
import sun.misc.ManagedLocalsThread;
            this.loadThread = new ManagedLocalsThread(this, name);
./share/classes/javax/swing/plaf/basic/BasicDirectoryModel.java
import sun.misc.ManagedLocalsThread;
            thread = new ManagedLocalsThread(ThreadGroupUtils.getRootThreadGroup(), this, name);
./share/classes/sun/java2d/opengl/OGLRenderQueue.java
import sun.misc.ManagedLocalsThread;
                Thread thread = new ManagedLocalsThread(
./share/classes/sun/java2d/loops/GraphicsPrimitive.java
import sun.misc.ManagedLocalsThread;
            Thread t = new ManagedLocalsThread(rootTG, disposerInstance, name);
./share/classes/sun/java2d/Disposer.java
import sun.misc.ManagedLocalsThread;
            Thread thread = new ManagedLocalsThread(
./share/classes/sun/awt/AWTAutoShutdown.java
import sun.misc.ManagedLocalsThread;
            Thread t = new ManagedLocalsThread(appContext.getThreadGroup(),
./share/classes/sun/awt/AppContext.java
import sun.misc.ManagedLocalsThread;
class ImageFetcher extends ManagedLocalsThread {
./share/classes/sun/awt/image/ImageFetcher.java
import sun.misc.ManagedLocalsThread;
                    Thread immThread = new ManagedLocalsThread(imm, threadName);
./share/classes/sun/awt/im/InputMethodManager.java
import sun.misc.ManagedLocalsThread;
        new ManagedLocalsThread(new Runnable()
        new ManagedLocalsThread(new Runnable()
./share/classes/sun/applet/AppletViewer.java
import sun.misc.ManagedLocalsThread;
        handler = new ManagedLocalsThread(appletGroup, this, "thread " + nm);
                          setLoaderThread(new ManagedLocalsThread(this));
./share/classes/sun/applet/AppletPanel.java
import sun.misc.ManagedLocalsThread;
class AppContextCreator extends ManagedLocalsThread {
./share/classes/sun/applet/AppletClassLoader.java
import sun.misc.ManagedLocalsThread;
        printerJobThread = new ManagedLocalsThread(this, "printerJobThread");
./share/classes/sun/print/PrintJob2D.java
import sun.misc.ManagedLocalsThread;
class ServiceNotifier extends ManagedLocalsThread {
./share/classes/sun/print/ServiceNotifier.java
import sun.misc.ManagedLocalsThread;
                        fileCloser = new ManagedLocalsThread(rootTG,
./share/classes/sun/font/SunFontManager.java
import sun.misc.ManagedLocalsThread;
                    t = new ManagedLocalsThread(rootTG,
./share/classes/sun/font/CreatedFontTracker.java
import sun.misc.ManagedLocalsThread;
class EventDispatchThread extends ManagedLocalsThread {
./share/classes/java/awt/EventDispatchThread.java
import sun.misc.ManagedLocalsThread;
        Thread thread = new ManagedLocalsThread(this, name);
./share/classes/java/awt/image/renderable/RenderableImageProducer.java
import sun.misc.ManagedLocalsThread;
        audiothread = new ManagedLocalsThread(this);
./share/classes/com/sun/media/sound/SoftAudioPusher.java
import sun.misc.ManagedLocalsThread;
        Thread thread = new ManagedLocalsThread(runnable);
./share/classes/com/sun/media/sound/JSSecurityManager.java
import sun.misc.ManagedLocalsThread;
            thread = new ManagedLocalsThread(runnable);
./share/classes/com/sun/media/sound/SoftJitterCorrector.java
import sun.misc.ManagedLocalsThread;
                     new ManagedLocalsThread(runnable).start();
./share/classes/com/sun/media/sound/SoftSynthesizer.java
import sun.misc.ManagedLocalsThread;
                    streamCloser = new ManagedLocalsThread(tg,
./share/classes/com/sun/imageio/stream/StreamCloser.java
import sun.misc.ManagedLocalsThread;
                new ManagedLocalsThread(audioRunnable).start();
./share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java
import sun.misc.ManagedLocalsThread;
            Thread shutdown = new ManagedLocalsThread(
                Thread t = new ManagedLocalsThread(
./windows/classes/sun/java2d/d3d/D3DScreenUpdateManager.java
import sun.misc.ManagedLocalsThread;
                Thread t = new ManagedLocalsThread(
                Thread thread = new ManagedLocalsThread(
./windows/classes/sun/awt/shell/Win32ShellFolderManager2.java
import sun.misc.ManagedLocalsThread;
        new ManagedLocalsThread(this::_show).start();
./windows/classes/sun/awt/windows/WFileDialogPeer.java
import sun.misc.ManagedLocalsThread;
            Thread toolkitThread = new ManagedLocalsThread(rootTG, this, name);
            Thread shutdown = new ManagedLocalsThread(
./windows/classes/sun/awt/windows/WToolkit.java
import sun.misc.ManagedLocalsThread;
        new ManagedLocalsThread(runnable).start();
./windows/classes/sun/awt/windows/WPageDialogPeer.java
import sun.misc.ManagedLocalsThread;
        new ManagedLocalsThread(runnable).start();
./windows/classes/sun/awt/windows/WPrintDialogPeer.java
import sun.misc.ManagedLocalsThread;
            Thread thr = new ManagedLocalsThread(new PrinterChangeListener());
./windows/classes/sun/print/PrintServiceLookupProvider.java
import sun.misc.ManagedLocalsThread;
                            fileCloser = new ManagedLocalsThread(rootTG, fileCloserRunnable);
./macosx/classes/sun/font/CFontManager.java
import sun.misc.ManagedLocalsThread;
            new ManagedLocalsThread(task).start();
./macosx/classes/sun/lwawt/macosx/CPrinterDialogPeer.java
import sun.misc.ManagedLocalsThread;
        new ManagedLocalsThread(() -> _safePrintLoop(target, arg)).start();
./macosx/classes/sun/lwawt/macosx/CPrinterJob.java
import sun.misc.ManagedLocalsThread;
            new ManagedLocalsThread(dragRunnable).start();
./macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java
import sun.misc.ManagedLocalsThread;
            new ManagedLocalsThread(new Task()).start();
./macosx/classes/sun/lwawt/macosx/CFileDialog.java
import sun.misc.ManagedLocalsThread;
            Thread shutdown = new ManagedLocalsThread(
            Thread toolkitThread = new ManagedLocalsThread(
./macosx/classes/sun/lwawt/LWToolkit.java
import sun.misc.ManagedLocalsThread;
            this.loadThread = new ManagedLocalsThread(this, name);
./macosx/classes/com/apple/laf/AquaFileSystemModel.java
import sun.misc.ManagedLocalsThread;
                this.thread = new ManagedLocalsThread(this);
./unix/classes/sun/awt/X11/InfoWindow.java
            Thread shutdownThread = new ManagedLocalsThread(
                Thread thread = new ManagedLocalsThread(
./unix/classes/sun/awt/X11/XToolkit.java
import sun.misc.ManagedLocalsThread;
                new ManagedLocalsThread(task).start();
./unix/classes/sun/awt/X11/GtkFileDialogPeer.java
import sun.misc.ManagedLocalsThread;
                Thread t = new ManagedLocalsThread(
./unix/classes/sun/awt/X11GraphicsDevice.java
import sun.misc.ManagedLocalsThread;
            Thread thr = new ManagedLocalsThread(new PrinterChangeListener());
./unix/classes/sun/print/PrintServiceLookupProvider.java

Comments
I thought you might say it was inconsistent, but I don't know why the others don't allow it .. Not a blocker, it just adds something to it as this does not look like a change I can do with sed any more cheaply than by hand - if at all.
29-03-2016

Accepting a null thread name and converting it to an automatic name is inconsistent with other Thread constructors, that accept a String name. Is this problem a blocker for doing this work?
29-03-2016

I didn't mean another constructor, just update the one you added so that "null" is a valid value for the name parameter.
29-03-2016

This is a very niche area, so *just* the minimal, most flexible, constructor overload was added. There is reluctance to add yet another Thread constructor, especially given the niche nature of this. One option for the desktop module, and possible its friends, is to add a new non-exported, or conditionally-exported, API for use in the module ( which could provide unique thread names ). The use of sub-task IDs in changesets is fine, so yes please commit any changes under the sub-task ID.
29-03-2016

We appear to have 47 (!) distinct Java source files in java.desktop using this API. One thing I notice about the new API is it appears to *require* you to come up with a name. It would have been better (IMO) to support "null" allowing an auto-generated name. As it is, as well as having to think, we are going to end up with some duplicate thread instance names since I don't think we want to come up with custom counters for all each case. Any chance of an API tweak first ? Is the change supposed to be committed under this "sub-task" ID ?
25-03-2016