8080405: Exception in thread "AWT-EventQueue-1" java.security.AccessControlException
Reviewed-by: prr, chegar, art
--- a/jdk/src/java.base/share/classes/sun/misc/ManagedLocalsThread.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.base/share/classes/sun/misc/ManagedLocalsThread.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, 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
@@ -48,6 +48,11 @@
eraseThreadLocals();
}
+ public ManagedLocalsThread(ThreadGroup group, Runnable target) {
+ super(group, target);
+ eraseThreadLocals();
+ }
+
public ManagedLocalsThread(Runnable target, String name) {
super(target, name);
eraseThreadLocals();
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaFileSystemModel.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaFileSystemModel.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2015, 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
@@ -383,11 +383,7 @@
this.currentDirectory = currentDirectory;
this.fid = fid;
String name = "Aqua L&F File Loading Thread";
- if (System.getSecurityManager() == null) {
- this.loadThread = new Thread(FilesLoader.this, name);
- } else {
- this.loadThread = new ManagedLocalsThread(FilesLoader.this, name);
- }
+ this.loadThread = new ManagedLocalsThread(this, name);
this.loadThread.start();
}
--- a/jdk/src/java.desktop/macosx/classes/sun/font/CFontManager.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/macosx/classes/sun/font/CFontManager.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2015, 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
@@ -42,7 +42,7 @@
import sun.awt.HeadlessToolkit;
import sun.awt.util.ThreadGroupUtils;
import sun.lwawt.macosx.*;
-import sun.misc.InnocuousThread;
+import sun.misc.ManagedLocalsThread;
public final class CFontManager extends SunFontManager {
private static Hashtable<String, Font2D> genericFonts = new Hashtable<String, Font2D>();
@@ -213,17 +213,12 @@
}
};
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
- if (System.getSecurityManager() == null) {
- /* The thread must be a member of a thread group
- * which will not get GCed before VM exit.
- * Make its parent the top-level thread group.
- */
- ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
- fileCloser = new Thread(rootTG, fileCloserRunnable);
- } else {
- /* InnocuousThread is a member of a correct TG by default */
- fileCloser = new InnocuousThread(fileCloserRunnable);
- }
+ /* The thread must be a member of a thread group
+ * which will not get GCed before VM exit.
+ * Make its parent the top-level thread group.
+ */
+ ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
+ fileCloser = new ManagedLocalsThread(rootTG, fileCloserRunnable);
fileCloser.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(fileCloser);
return null;
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java Mon Jun 29 01:27:08 2015 +0300
@@ -35,7 +35,7 @@
import java.util.*;
import sun.awt.*;
-import sun.misc.InnocuousThread;
+import sun.misc.ManagedLocalsThread;
import sun.print.*;
import sun.awt.util.ThreadGroupUtils;
@@ -77,22 +77,13 @@
shutdown();
waitForRunState(STATE_CLEANUP);
};
- Thread shutdown;
- if (System.getSecurityManager() == null) {
- shutdown = new Thread(ThreadGroupUtils.getRootThreadGroup(), shutdownRunnable);
- } else {
- shutdown = new InnocuousThread(shutdownRunnable);
- }
+ Thread shutdown = new ManagedLocalsThread(
+ ThreadGroupUtils.getRootThreadGroup(), shutdownRunnable);
shutdown.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(shutdown);
-
String name = "AWT-LW";
- Thread toolkitThread;
- if (System.getSecurityManager() == null) {
- toolkitThread = new Thread(ThreadGroupUtils.getRootThreadGroup(), LWToolkit.this, name);
- } else {
- toolkitThread = new InnocuousThread(LWToolkit.this, name);
- }
+ Thread toolkitThread = new ManagedLocalsThread(
+ ThreadGroupUtils.getRootThreadGroup(), this, name);
toolkitThread.setDaemon(true);
toolkitThread.setPriority(Thread.NORM_PRIORITY + 1);
toolkitThread.start();
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java Mon Jun 29 01:27:08 2015 +0300
@@ -181,13 +181,7 @@
}
}
};
- Thread dragThread;
- if (System.getSecurityManager() == null) {
- dragThread = new Thread(dragRunnable);
- } else {
- dragThread = new ManagedLocalsThread(dragRunnable);
- }
- dragThread.start();
+ new ManagedLocalsThread(dragRunnable).start();
} catch (Exception e) {
final long nativeDragSource = getNativeContext();
setNativeContext(0);
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFileDialog.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFileDialog.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2015, 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
@@ -120,11 +120,7 @@
if (visible) {
// Java2 Dialog class requires peer to run code in a separate thread
// and handles keeping the call modal
- if (System.getSecurityManager() == null) {
- new Thread(new Task()).start();
- } else {
- new ManagedLocalsThread(new Task()).start();
- }
+ new ManagedLocalsThread(new Task()).start();
}
// We hide ourself before "show" returns - setVisible(false)
// doesn't apply
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterDialogPeer.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterDialogPeer.java Mon Jun 29 01:27:08 2015 +0300
@@ -59,11 +59,7 @@
printerDialog.setRetVal(printerDialog.showDialog());
printerDialog.setVisible(false);
};
- if (System.getSecurityManager() == null) {
- new Thread(task).start();
- } else {
- new ManagedLocalsThread(task).start();
- }
+ new ManagedLocalsThread(task).start();
}
}
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2015, 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
@@ -736,12 +736,7 @@
// upcall from native
private static void detachPrintLoop(final long target, final long arg) {
- Runnable task = () -> _safePrintLoop(target, arg);
- if (System.getSecurityManager() == null) {
- new Thread(task).start();
- } else {
- new ManagedLocalsThread(task).start();
- }
+ new ManagedLocalsThread(() -> _safePrintLoop(target, arg)).start();
}
private static native void _safePrintLoop(long target, long arg);
@@ -779,4 +774,4 @@
(float) (paper.getImageableHeight() / dpi),
MediaPrintableArea.INCH);
}
-}
\ No newline at end of file
+}
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/stream/StreamCloser.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/stream/StreamCloser.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2015, 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
@@ -26,7 +26,7 @@
package com.sun.imageio.stream;
import sun.awt.util.ThreadGroupUtils;
-import sun.misc.InnocuousThread;
+import sun.misc.ManagedLocalsThread;
import java.io.IOException;
import java.security.AccessController;
@@ -87,17 +87,13 @@
};
AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
- if (System.getSecurityManager() == null) {
- /* The thread must be a member of a thread group
- * which will not get GCed before VM exit.
- * Make its parent the top-level thread group.
- */
- ThreadGroup tg = ThreadGroupUtils.getRootThreadGroup();
- streamCloser = new Thread(tg, streamCloserRunnable);
- } else {
- /* InnocuousThread is a member of a correct TG by default */
- streamCloser = new InnocuousThread(streamCloserRunnable);
- }
+ /* The thread must be a member of a thread group
+ * which will not get GCed before VM exit.
+ * Make its parent the top-level thread group.
+ */
+ ThreadGroup tg = ThreadGroupUtils.getRootThreadGroup();
+ streamCloser = new ManagedLocalsThread(tg,
+ streamCloserRunnable);
/* Set context class loader to null in order to avoid
* keeping a strong reference to an application classloader.
*/
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, 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
@@ -2038,11 +2038,7 @@
if (audioRunnable != null) {
// Runnable appears to block until completed playing, hence
// start up another thread to handle playing.
- if (System.getSecurityManager() == null) {
- new Thread(audioRunnable).start();
- } else {
- new ManagedLocalsThread(audioRunnable).start();
- }
+ new ManagedLocalsThread(audioRunnable).start();
}
}
}
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/JSSecurityManager.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/JSSecurityManager.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, 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
@@ -25,7 +25,6 @@
package com.sun.media.sound;
-import sun.misc.InnocuousThread;
import sun.misc.ManagedLocalsThread;
import java.io.BufferedInputStream;
@@ -147,12 +146,7 @@
final String threadName,
final boolean isDaemon, final int priority,
final boolean doStart) {
- Thread thread;
- if (System.getSecurityManager() == null) {
- thread = new Thread(runnable);
- } else {
- thread = new ManagedLocalsThread(runnable);
- }
+ Thread thread = new ManagedLocalsThread(runnable);
if (threadName != null) {
thread.setName(threadName);
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftAudioPusher.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftAudioPusher.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2015, 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
@@ -55,11 +55,7 @@
if (active)
return;
active = true;
- if (System.getSecurityManager() == null) {
- audiothread = new Thread(this);
- } else {
- audiothread = new ManagedLocalsThread(this);
- }
+ audiothread = new ManagedLocalsThread(this);
audiothread.setDaemon(true);
audiothread.setPriority(Thread.MAX_PRIORITY);
audiothread.start();
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftJitterCorrector.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftJitterCorrector.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2015, 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
@@ -216,11 +216,7 @@
}
};
- if (System.getSecurityManager() == null) {
- thread = new Thread(runnable);
- } else {
- thread = new ManagedLocalsThread(runnable);
- }
+ thread = new ManagedLocalsThread(runnable);
thread.setDaemon(true);
thread.setPriority(Thread.MAX_PRIORITY);
thread.start();
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftSynthesizer.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftSynthesizer.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2015, 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
@@ -141,11 +141,7 @@
pusher = null;
jitter_stream = null;
sourceDataLine = null;
- if (System.getSecurityManager() == null) {
- new Thread(runnable).start();
- } else {
- new ManagedLocalsThread(runnable).start();
- }
+ new ManagedLocalsThread(runnable).start();
}
return len;
}
--- a/jdk/src/java.desktop/share/classes/java/awt/EventDispatchThread.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/java/awt/EventDispatchThread.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2015, 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
@@ -67,7 +67,7 @@
private ArrayList<EventFilter> eventFilters = new ArrayList<EventFilter>();
EventDispatchThread(ThreadGroup group, String name, EventQueue queue) {
- super(group, null, name);
+ super(group, name);
setEventQueue(queue);
}
--- a/jdk/src/java.desktop/share/classes/java/awt/image/renderable/RenderableImageProducer.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/java/awt/image/renderable/RenderableImageProducer.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2015, 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
@@ -137,12 +137,7 @@
addConsumer(ic);
// Need to build a runnable object for the Thread.
String name = "RenderableImageProducer Thread";
- Thread thread;
- if (System.getSecurityManager() == null) {
- thread = new Thread(this, name);
- } else {
- thread = new ManagedLocalsThread(this);
- }
+ Thread thread = new ManagedLocalsThread(this, name);
thread.start();
}
--- a/jdk/src/java.desktop/share/classes/javax/swing/JTable.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JTable.java Mon Jun 29 01:27:08 2015 +0300
@@ -6402,12 +6402,7 @@
};
// start printing on another thread
- Thread th;
- if (System.getSecurityManager() == null) {
- th = new Thread(runnable);
- } else {
- th = new ManagedLocalsThread(runnable);
- }
+ Thread th = new ManagedLocalsThread(runnable);
th.start();
printingStatus.showModal(true);
--- a/jdk/src/java.desktop/share/classes/javax/swing/TimerQueue.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/javax/swing/TimerQueue.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, 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
@@ -36,8 +36,7 @@
import java.util.concurrent.locks.*;
import java.util.concurrent.atomic.AtomicLong;
import sun.awt.AppContext;
-import sun.misc.InnocuousThread;
-
+import sun.misc.ManagedLocalsThread;
/**
* Internal class to manage all Timers using one thread.
@@ -99,12 +98,8 @@
final ThreadGroup threadGroup = AppContext.getAppContext().getThreadGroup();
AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
String name = "TimerQueue";
- Thread timerThread;
- if (System.getSecurityManager() == null) {
- timerThread = new Thread(threadGroup, TimerQueue.this, name);
- } else {
- timerThread = new InnocuousThread(threadGroup, TimerQueue.this, name);
- }
+ Thread timerThread = new ManagedLocalsThread(threadGroup,
+ this, name);
timerThread.setDaemon(true);
timerThread.setPriority(Thread.NORM_PRIORITY);
timerThread.start();
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicDirectoryModel.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicDirectoryModel.java Mon Jun 29 01:27:08 2015 +0300
@@ -271,11 +271,7 @@
this.currentDirectory = currentDirectory;
this.fid = fid;
String name = "Basic L&F File Loading Thread";
- if (System.getSecurityManager() == null) {
- this.loadThread = new Thread(this, name);
- } else {
- this.loadThread = new ManagedLocalsThread(this, name);
- }
+ this.loadThread = new ManagedLocalsThread(this, name);
this.loadThread.start();
}
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/JTextComponent.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/JTextComponent.java Mon Jun 29 01:27:08 2015 +0300
@@ -2365,11 +2365,7 @@
runnablePrinting.run();
} else {
if (isEventDispatchThread) {
- if (System.getSecurityManager() == null) {
- new Thread(runnablePrinting).start();
- } else {
- new ManagedLocalsThread(runnablePrinting).start();
- }
+ new ManagedLocalsThread(runnablePrinting).start();
printingStatus.showModal(true);
} else {
printingStatus.showModal(false);
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/LayoutQueue.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/LayoutQueue.java Mon Jun 29 01:27:08 2015 +0300
@@ -92,12 +92,7 @@
}
} while (work != null);
};
- String name = "text-layout";
- if (System.getSecurityManager() == null) {
- worker = new Thread(workerRunnable, name);
- } else {
- worker = new ManagedLocalsThread(workerRunnable, name);
- }
+ worker = new ManagedLocalsThread(workerRunnable, "text-layout");
worker.setPriority(Thread.MIN_PRIORITY);
worker.start();
}
--- a/jdk/src/java.desktop/share/classes/sun/applet/AppletClassLoader.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletClassLoader.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2015, 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
@@ -862,7 +862,7 @@
volatile boolean created = false;
AppContextCreator(ThreadGroup group) {
- super(group, null, "AppContextCreator");
+ super(group, "AppContextCreator");
}
public void run() {
--- a/jdk/src/java.desktop/share/classes/sun/awt/AWTAutoShutdown.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/sun/awt/AWTAutoShutdown.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, 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
@@ -34,7 +34,7 @@
import java.util.Set;
import sun.awt.util.ThreadGroupUtils;
-import sun.misc.InnocuousThread;
+import sun.misc.ManagedLocalsThread;
import sun.util.logging.PlatformLogger;
/**
@@ -336,14 +336,9 @@
*/
private void activateBlockerThread() {
AccessController.doPrivileged((PrivilegedAction<Thread>) () -> {
- Thread thread;
String name = "AWT-Shutdown";
- if (System.getSecurityManager() == null) {
- thread = new Thread(ThreadGroupUtils.getRootThreadGroup(), this,
- name);
- } else {
- thread = new InnocuousThread(this, name);
- }
+ Thread thread = new ManagedLocalsThread(
+ ThreadGroupUtils.getRootThreadGroup(), this, name);
thread.setContextClassLoader(null);
thread.setDaemon(false);
blockerThread = thread;
--- a/jdk/src/java.desktop/share/classes/sun/awt/AppContext.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/sun/awt/AppContext.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2015, 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
@@ -44,7 +44,7 @@
import java.beans.PropertyChangeListener;
import java.lang.ref.SoftReference;
-import sun.misc.InnocuousThread;
+import sun.misc.ManagedLocalsThread;
import sun.util.logging.PlatformLogger;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
@@ -591,13 +591,9 @@
}
public Thread run() {
- Thread t;
- if (System.getSecurityManager() == null) {
- t = new Thread(appContext.getThreadGroup(), runnable);
- } else {
- t = new InnocuousThread(appContext.getThreadGroup(), runnable, "AppContext Disposer");
- }
- t.setContextClassLoader(null);
+ Thread t = new ManagedLocalsThread(appContext.getThreadGroup(),
+ runnable, "AppContext Disposer");
+ t.setContextClassLoader(appContext.getContextClassLoader());
t.setPriority(Thread.NORM_PRIORITY + 1);
t.setDaemon(true);
return t;
--- a/jdk/src/java.desktop/share/classes/sun/awt/im/InputMethodManager.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/sun/awt/im/InputMethodManager.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2015, 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
@@ -167,12 +167,7 @@
// to choose from. Otherwise, just keep the instance.
if (imm.hasMultipleInputMethods()) {
imm.initialize();
- Thread immThread;
- if (System.getSecurityManager() == null) {
- immThread = new Thread(imm, threadName);
- } else {
- immThread = new ManagedLocalsThread(imm, threadName);
- }
+ Thread immThread = new ManagedLocalsThread(imm, threadName);
immThread.setDaemon(true);
immThread.setPriority(Thread.NORM_PRIORITY + 1);
immThread.start();
--- a/jdk/src/java.desktop/share/classes/sun/awt/image/ImageFetcher.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/sun/awt/image/ImageFetcher.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2015, 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
@@ -55,7 +55,7 @@
* Constructor for ImageFetcher -- only called by add() below.
*/
private ImageFetcher(ThreadGroup threadGroup, int index) {
- super(threadGroup, null, "Image Fetcher " + index);
+ super(threadGroup, "Image Fetcher " + index);
setDaemon(true);
}
--- a/jdk/src/java.desktop/share/classes/sun/font/CreatedFontTracker.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/sun/font/CreatedFontTracker.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2015, 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
@@ -36,7 +36,7 @@
import sun.awt.AppContext;
import sun.awt.util.ThreadGroupUtils;
-import sun.misc.InnocuousThread;
+import sun.misc.ManagedLocalsThread;
public class CreatedFontTracker {
@@ -117,17 +117,13 @@
if (t == null) {
// Add a shutdown hook to remove the temp file.
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
- if (System.getSecurityManager() == null) {
- /* The thread must be a member of a thread group
- * which will not get GCed before VM exit.
- * Make its parent the top-level thread group.
- */
- ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
- t = new Thread(rootTG, TempFileDeletionHook::runHooks);
- } else {
- /* InnocuousThread is a member of a correct TG by default */
- t = new InnocuousThread(TempFileDeletionHook::runHooks);
- }
+ /* The thread must be a member of a thread group
+ * which will not get GCed before VM exit.
+ * Make its parent the top-level thread group.
+ */
+ ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
+ t = new ManagedLocalsThread(rootTG,
+ TempFileDeletionHook::runHooks);
/* Set context class loader to null in order to avoid
* keeping a strong reference to an application classloader.
*/
--- a/jdk/src/java.desktop/share/classes/sun/font/SunFontManager.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/sun/font/SunFontManager.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2015, 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
@@ -55,6 +55,7 @@
import sun.awt.util.ThreadGroupUtils;
import sun.java2d.FontSupport;
import sun.misc.InnocuousThread;
+import sun.misc.ManagedLocalsThread;
import sun.util.logging.PlatformLogger;
/**
@@ -2501,12 +2502,9 @@
}
};
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
- if (System.getSecurityManager() == null) {
- ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
- fileCloser = new Thread(rootTG, fileCloserRunnable);
- } else {
- fileCloser = new InnocuousThread(fileCloserRunnable);
- }
+ ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
+ fileCloser = new ManagedLocalsThread(rootTG,
+ fileCloserRunnable);
fileCloser.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(fileCloser);
return null;
--- a/jdk/src/java.desktop/share/classes/sun/java2d/Disposer.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/Disposer.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015, 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
@@ -26,7 +26,7 @@
package sun.java2d;
import sun.awt.util.ThreadGroupUtils;
-import sun.misc.InnocuousThread;
+import sun.misc.ManagedLocalsThread;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
@@ -84,13 +84,8 @@
disposerInstance = new Disposer();
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
String name = "Java2D Disposer";
- Thread t;
- if (System.getSecurityManager() == null) {
- ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
- t = new Thread(rootTG, disposerInstance, name);
- } else {
- t = new InnocuousThread(disposerInstance, name);
- }
+ ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
+ Thread t = new ManagedLocalsThread(rootTG, disposerInstance, name);
t.setContextClassLoader(null);
t.setDaemon(true);
t.setPriority(Thread.MAX_PRIORITY);
--- a/jdk/src/java.desktop/share/classes/sun/java2d/loops/GraphicsPrimitive.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/loops/GraphicsPrimitive.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, 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
@@ -48,7 +48,7 @@
import java.security.AccessController;
import java.security.PrivilegedAction;
-import sun.misc.InnocuousThread;
+import sun.misc.ManagedLocalsThread;
import sun.security.action.GetPropertyAction;
/**
@@ -420,12 +420,8 @@
public static void setShutdownHook() {
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
TraceReporter t = new TraceReporter();
- Thread thread;
- if (System.getSecurityManager() == null) {
- thread = new Thread(ThreadGroupUtils.getRootThreadGroup(), t);
- } else {
- thread = new InnocuousThread(t);
- }
+ Thread thread = new ManagedLocalsThread(
+ ThreadGroupUtils.getRootThreadGroup(), t);
thread.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(thread);
return null;
--- a/jdk/src/java.desktop/share/classes/sun/java2d/opengl/OGLRenderQueue.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/opengl/OGLRenderQueue.java Mon Jun 29 01:27:08 2015 +0300
@@ -29,6 +29,7 @@
import sun.java2d.pipe.RenderBuffer;
import sun.java2d.pipe.RenderQueue;
import sun.misc.InnocuousThread;
+import sun.misc.ManagedLocalsThread;
import static sun.java2d.pipe.BufferedOpCodes.*;
import java.security.AccessController;
@@ -161,11 +162,7 @@
public QueueFlusher() {
String name = "Java2D Queue Flusher";
- if (System.getSecurityManager() == null) {
- this.thread = new Thread(ThreadGroupUtils.getRootThreadGroup(), this, name);
- } else {
- this.thread = new InnocuousThread(this, name);
- }
+ thread = new ManagedLocalsThread(ThreadGroupUtils.getRootThreadGroup(), this, name);
thread.setDaemon(true);
thread.setPriority(Thread.MAX_PRIORITY);
thread.start();
--- a/jdk/src/java.desktop/share/classes/sun/print/PrintJob2D.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/sun/print/PrintJob2D.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, 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
@@ -987,12 +987,7 @@
}
private void startPrinterJobThread() {
- String name = "printerJobThread";
- if (System.getSecurityManager() == null) {
- printerJobThread = new Thread(this, name);
- } else {
- printerJobThread = new ManagedLocalsThread(this, name);
- }
+ printerJobThread = new ManagedLocalsThread(this, "printerJobThread");
printerJobThread.start();
}
--- a/jdk/src/java.desktop/share/classes/sun/print/ServiceNotifier.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/sun/print/ServiceNotifier.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, 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
@@ -50,7 +50,7 @@
private PrintServiceAttributeSet lastSet;
ServiceNotifier(PrintService service) {
- super((Runnable) null, service.getName() + " notifier");
+ super(service.getName() + " notifier");
this.service = service;
listeners = new Vector<>();
try {
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/GtkFileDialogPeer.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/GtkFileDialogPeer.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, 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
@@ -116,12 +116,7 @@
showNativeDialog();
fd.setVisible(false);
};
- if (System.getSecurityManager() == null) {
- new Thread(task).start();
- } else {
- new ManagedLocalsThread(task).start();
- }
-
+ new ManagedLocalsThread(task).start();
} else {
quit();
fd.setVisible(false);
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/InfoWindow.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/InfoWindow.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015, 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
@@ -29,7 +29,6 @@
import java.awt.event.*;
import java.awt.peer.TrayIconPeer;
import sun.awt.*;
-import sun.misc.InnocuousThread;
import sun.misc.ManagedLocalsThread;
import java.awt.image.*;
@@ -455,11 +454,7 @@
final Thread thread;
Displayer() {
- if (System.getSecurityManager() == null) {
- this.thread = new Thread(this);
- } else {
- this.thread = new ManagedLocalsThread(this);
- }
+ this.thread = new ManagedLocalsThread(this);
this.thread.setDaemon(true);
}
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java Mon Jun 29 01:27:08 2015 +0300
@@ -281,12 +281,8 @@
}
};
String name = "XToolkt-Shutdown-Thread";
- Thread shutdownThread;
- if (System.getSecurityManager() == null) {
- shutdownThread = new Thread(ThreadGroupUtils.getRootThreadGroup(), r, name);
- } else {
- shutdownThread = new InnocuousThread(r, name);
- }
+ Thread shutdownThread = new ManagedLocalsThread(
+ ThreadGroupUtils.getRootThreadGroup(), r, name);
shutdownThread.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(shutdownThread);
return null;
@@ -333,12 +329,8 @@
toolkitThread = AccessController.doPrivileged((PrivilegedAction<Thread>) () -> {
String name = "AWT-XAWT";
- Thread thread;
- if (System.getSecurityManager() == null) {
- thread = new Thread(ThreadGroupUtils.getRootThreadGroup(), XToolkit.this, name);
- } else {
- thread = new InnocuousThread(XToolkit.this, name);
- }
+ Thread thread = new ManagedLocalsThread(
+ ThreadGroupUtils.getRootThreadGroup(), this, name);
thread.setContextClassLoader(null);
thread.setPriority(Thread.NORM_PRIORITY + 1);
thread.setDaemon(true);
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java Mon Jun 29 01:27:08 2015 +0300
@@ -43,7 +43,7 @@
import sun.java2d.loops.SurfaceType;
import sun.awt.util.ThreadGroupUtils;
-import sun.misc.InnocuousThread;
+import sun.misc.ManagedLocalsThread;
/**
* This is an implementation of a GraphicsDevice object for a single
@@ -437,12 +437,8 @@
}
};
String name = "Display-Change-Shutdown-Thread-" + screen;
- Thread t;
- if (System.getSecurityManager() == null) {
- t = new Thread(ThreadGroupUtils.getRootThreadGroup(), r, name);
- } else {
- t = new InnocuousThread(r, name);
- }
+ Thread t = new ManagedLocalsThread(
+ ThreadGroupUtils.getRootThreadGroup(), r, name);
t.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(t);
return null;
--- a/jdk/src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, 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
@@ -213,12 +213,7 @@
public PrintServiceLookupProvider() {
// start the printer listener thread
if (pollServices) {
- Thread thr;
- if (System.getSecurityManager() == null) {
- thr = new Thread(new PrinterChangeListener());
- } else {
- thr = new ManagedLocalsThread(new PrinterChangeListener());
- }
+ Thread thr = new ManagedLocalsThread(new PrinterChangeListener());
thr.setDaemon(true);
thr.start();
IPPPrintService.debug_println(debugPrefix+"polling turned on");
--- a/jdk/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java Mon Jun 29 01:27:08 2015 +0300
@@ -41,8 +41,7 @@
import static sun.awt.shell.Win32ShellFolder2.*;
import sun.awt.OSInfo;
import sun.awt.util.ThreadGroupUtils;
-import sun.misc.InnocuousThread;
-
+import sun.misc.ManagedLocalsThread;
// NOTE: This class supersedes Win32ShellFolderManager, which was removed
// from distribution after version 1.4.2.
@@ -525,12 +524,8 @@
return null;
});
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
- Thread t;
- if (System.getSecurityManager() == null) {
- t = new Thread(ThreadGroupUtils.getRootThreadGroup(), shutdownHook);
- } else {
- t = new InnocuousThread(shutdownHook);
- }
+ Thread t = new ManagedLocalsThread(
+ ThreadGroupUtils.getRootThreadGroup(), shutdownHook);
Runtime.getRuntime().addShutdownHook(t);
return null;
});
@@ -549,17 +544,12 @@
};
comThread = AccessController.doPrivileged((PrivilegedAction<Thread>) () -> {
String name = "Swing-Shell";
- Thread thread;
- if (System.getSecurityManager() == null) {
- /* The thread must be a member of a thread group
- * which will not get GCed before VM exit.
- * Make its parent the top-level thread group.
- */
- thread = new Thread(ThreadGroupUtils.getRootThreadGroup(), comRun, name);
- } else {
- /* InnocuousThread is a member of a correct TG by default */
- thread = new InnocuousThread(comRun, name);
- }
+ /* The thread must be a member of a thread group
+ * which will not get GCed before VM exit.
+ * Make its parent the top-level thread group.
+ */
+ Thread thread = new ManagedLocalsThread(
+ ThreadGroupUtils.getRootThreadGroup(), comRun, name);
thread.setDaemon(true);
return thread;
});
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WFileDialogPeer.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WFileDialogPeer.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2015, 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
@@ -98,11 +98,7 @@
@Override
public void show() {
- if (System.getSecurityManager() == null) {
- new Thread(this::_show).start();
- } else {
- new ManagedLocalsThread(this::_show).start();
- }
+ new ManagedLocalsThread(this::_show).start();
}
@Override
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPageDialogPeer.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPageDialogPeer.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, 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
@@ -53,10 +53,6 @@
}
((WPrintDialog)target).setVisible(false);
};
- if (System.getSecurityManager() == null) {
- new Thread(runnable).start();
- } else {
- new ManagedLocalsThread(runnable).start();
- }
+ new ManagedLocalsThread(runnable).start();
}
}
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPrintDialogPeer.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPrintDialogPeer.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, 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
@@ -78,11 +78,7 @@
}
((WPrintDialog)target).setVisible(false);
};
- if (System.getSecurityManager() == null) {
- new Thread(runnable).start();
- } else {
- new ManagedLocalsThread(runnable).start();
- }
+ new ManagedLocalsThread(runnable).start();
}
synchronized void setHWnd(long hwnd) {
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java Mon Jun 29 01:27:08 2015 +0300
@@ -51,7 +51,7 @@
import sun.java2d.d3d.D3DRenderQueue;
import sun.java2d.opengl.OGLRenderQueue;
-import sun.misc.InnocuousThread;
+import sun.misc.ManagedLocalsThread;
import sun.print.PrintJob2D;
import java.awt.dnd.DragSource;
@@ -255,12 +255,7 @@
(PrivilegedAction<ThreadGroup>) ThreadGroupUtils::getRootThreadGroup);
if (!startToolkitThread(this, rootTG)) {
String name = "AWT-Windows";
- Thread toolkitThread;
- if (System.getSecurityManager() == null) {
- toolkitThread = new Thread(rootTG, this, name);
- } else {
- toolkitThread = new InnocuousThread(this, name);
- }
+ Thread toolkitThread = new ManagedLocalsThread(rootTG, this, name);
toolkitThread.setDaemon(true);
toolkitThread.start();
}
@@ -287,16 +282,12 @@
private void registerShutdownHook() {
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
- Thread shutdown;
- if (System.getSecurityManager() == null) {
- shutdown = new Thread(ThreadGroupUtils.getRootThreadGroup(), this::shutdown);
- } else {
- shutdown = new InnocuousThread(this::shutdown);
- }
+ Thread shutdown = new ManagedLocalsThread(
+ ThreadGroupUtils.getRootThreadGroup(), this::shutdown);
shutdown.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(shutdown);
return null;
- });
+ });
}
@Override
--- a/jdk/src/java.desktop/windows/classes/sun/java2d/d3d/D3DScreenUpdateManager.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/windows/classes/sun/java2d/d3d/D3DScreenUpdateManager.java Mon Jun 29 01:27:08 2015 +0300
@@ -49,7 +49,7 @@
import sun.java2d.windows.GDIWindowSurfaceData;
import sun.java2d.d3d.D3DSurfaceData.D3DWindowSurfaceData;
import sun.java2d.windows.WindowsFlags;
-import sun.misc.InnocuousThread;
+import sun.misc.ManagedLocalsThread;
/**
* This class handles rendering to the screen with the D3D pipeline.
@@ -99,12 +99,8 @@
done = true;
wakeUpUpdateThread();
};
- Thread shutdown;
- if (System.getSecurityManager() == null) {
- shutdown = new Thread(ThreadGroupUtils.getRootThreadGroup(), shutdownRunnable);
- } else {
- shutdown = new InnocuousThread(shutdownRunnable);
- }
+ Thread shutdown = new ManagedLocalsThread(
+ ThreadGroupUtils.getRootThreadGroup(), shutdownRunnable);
shutdown.setContextClassLoader(null);
try {
Runtime.getRuntime().addShutdownHook(shutdown);
@@ -351,15 +347,9 @@
private synchronized void startUpdateThread() {
if (screenUpdater == null) {
screenUpdater = AccessController.doPrivileged((PrivilegedAction<Thread>) () -> {
- Thread t;
String name = "D3D Screen Updater";
- if (System.getSecurityManager() == null) {
- t = new Thread(ThreadGroupUtils.getRootThreadGroup(),
- D3DScreenUpdateManager.this,
- name);
- } else {
- t = new InnocuousThread(D3DScreenUpdateManager.this, name);
- }
+ Thread t = new ManagedLocalsThread(
+ ThreadGroupUtils.getRootThreadGroup(), this, name);
// REMIND: should it be higher?
t.setPriority(Thread.NORM_PRIORITY + 2);
t.setDaemon(true);
--- a/jdk/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java Fri Jun 26 12:38:39 2015 +0300
+++ b/jdk/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java Mon Jun 29 01:27:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, 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
@@ -99,12 +99,7 @@
return;
}
// start the printer listener thread
- Thread thr;
- if (System.getSecurityManager() == null) {
- thr = new Thread(new PrinterChangeListener());
- } else {
- thr = new ManagedLocalsThread(new PrinterChangeListener());
- }
+ Thread thr = new ManagedLocalsThread(new PrinterChangeListener());
thr.setDaemon(true);
thr.start();
} /* else condition ought to never happen! */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/EventDispatchThread/PropertyPermissionOnEDT/PropertyPermissionOnEDT.java Mon Jun 29 01:27:08 2015 +0300
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2015, 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.event.InputEvent;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+
+/**
+ * @test
+ * @bug 8080405
+ * @run main/othervm/policy=java.policy -Djava.security.manager PropertyPermissionOnEDT
+ */
+public final class PropertyPermissionOnEDT {
+
+ public static void main(final String[] args) throws Exception {
+ SwingUtilities.invokeAndWait(PropertyPermissionOnEDT::test);
+
+ JFrame frame = new JFrame();
+ frame.addMouseListener(new MouseListener() {
+ @Override
+ public void mouseClicked(final MouseEvent e) {
+ test();
+ }
+
+ @Override
+ public void mousePressed(MouseEvent e) {
+ test();
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent e) {
+ test();
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent e) {
+ test();
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e) {
+ test();
+ }
+ });
+ frame.addFocusListener(new FocusListener() {
+ @Override
+ public void focusGained(FocusEvent e) {
+ test();
+ }
+
+ @Override
+ public void focusLost(FocusEvent e) {
+ test();
+ }
+ });
+ frame.addMouseWheelListener(e -> test());
+ frame.addWindowStateListener(e -> test());
+
+ frame.setSize(100, 100);
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+ Robot robot = new Robot();
+ robot.setAutoWaitForIdle(true);
+ robot.setAutoDelay(100);
+ Point loc = frame.getLocationOnScreen();
+ robot.mouseMove(loc.x + frame.getWidth() / 2,
+ loc.y + frame.getHeight() / 2);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.mouseWheel(100);
+ frame.dispose();
+ }
+
+ private static void test() {
+ String property = System.getProperty("os.name");
+ System.out.println("property = " + property);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/EventDispatchThread/PropertyPermissionOnEDT/java.policy Mon Jun 29 01:27:08 2015 +0300
@@ -0,0 +1,4 @@
+grant {
+ permission java.util.PropertyPermission "os.name", "read";
+ permission java.awt.AWTPermission "createRobot";
+};