8080405: Exception in thread "AWT-EventQueue-1" java.security.AccessControlException

Reviewed-by: prr, chegar, art
This commit is contained in:
Sergey Bylokhov 2015-06-29 01:27:08 +03:00
parent 561c4e223c
commit 33c5b92bc6
47 changed files with 251 additions and 338 deletions

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -48,6 +48,11 @@ public class ManagedLocalsThread extends Thread {
eraseThreadLocals(); eraseThreadLocals();
} }
public ManagedLocalsThread(ThreadGroup group, Runnable target) {
super(group, target);
eraseThreadLocals();
}
public ManagedLocalsThread(Runnable target, String name) { public ManagedLocalsThread(Runnable target, String name) {
super(target, name); super(target, name);
eraseThreadLocals(); eraseThreadLocals();

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -383,11 +383,7 @@ class AquaFileSystemModel extends AbstractTableModel implements PropertyChangeLi
this.currentDirectory = currentDirectory; this.currentDirectory = currentDirectory;
this.fid = fid; this.fid = fid;
String name = "Aqua L&F File Loading Thread"; String name = "Aqua L&F File Loading Thread";
if (System.getSecurityManager() == null) { this.loadThread = new ManagedLocalsThread(this, name);
this.loadThread = new Thread(FilesLoader.this, name);
} else {
this.loadThread = new ManagedLocalsThread(FilesLoader.this, name);
}
this.loadThread.start(); this.loadThread.start();
} }

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -42,7 +42,7 @@ import sun.awt.FontConfiguration;
import sun.awt.HeadlessToolkit; import sun.awt.HeadlessToolkit;
import sun.awt.util.ThreadGroupUtils; import sun.awt.util.ThreadGroupUtils;
import sun.lwawt.macosx.*; import sun.lwawt.macosx.*;
import sun.misc.InnocuousThread; import sun.misc.ManagedLocalsThread;
public final class CFontManager extends SunFontManager { public final class CFontManager extends SunFontManager {
private static Hashtable<String, Font2D> genericFonts = new Hashtable<String, Font2D>(); private static Hashtable<String, Font2D> genericFonts = new Hashtable<String, Font2D>();
@ -213,17 +213,12 @@ public final class CFontManager extends SunFontManager {
} }
}; };
AccessController.doPrivileged((PrivilegedAction<Void>) () -> { AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
if (System.getSecurityManager() == null) { /* The thread must be a member of a thread group
/* The thread must be a member of a thread group * which will not get GCed before VM exit.
* which will not get GCed before VM exit. * Make its parent the top-level thread group.
* Make its parent the top-level thread group. */
*/ ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup(); fileCloser = new ManagedLocalsThread(rootTG, fileCloserRunnable);
fileCloser = new Thread(rootTG, fileCloserRunnable);
} else {
/* InnocuousThread is a member of a correct TG by default */
fileCloser = new InnocuousThread(fileCloserRunnable);
}
fileCloser.setContextClassLoader(null); fileCloser.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(fileCloser); Runtime.getRuntime().addShutdownHook(fileCloser);
return null; return null;

View File

@ -35,7 +35,7 @@ import java.security.*;
import java.util.*; import java.util.*;
import sun.awt.*; import sun.awt.*;
import sun.misc.InnocuousThread; import sun.misc.ManagedLocalsThread;
import sun.print.*; import sun.print.*;
import sun.awt.util.ThreadGroupUtils; import sun.awt.util.ThreadGroupUtils;
@ -77,22 +77,13 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
shutdown(); shutdown();
waitForRunState(STATE_CLEANUP); waitForRunState(STATE_CLEANUP);
}; };
Thread shutdown; Thread shutdown = new ManagedLocalsThread(
if (System.getSecurityManager() == null) { ThreadGroupUtils.getRootThreadGroup(), shutdownRunnable);
shutdown = new Thread(ThreadGroupUtils.getRootThreadGroup(), shutdownRunnable);
} else {
shutdown = new InnocuousThread(shutdownRunnable);
}
shutdown.setContextClassLoader(null); shutdown.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(shutdown); Runtime.getRuntime().addShutdownHook(shutdown);
String name = "AWT-LW"; String name = "AWT-LW";
Thread toolkitThread; Thread toolkitThread = new ManagedLocalsThread(
if (System.getSecurityManager() == null) { ThreadGroupUtils.getRootThreadGroup(), this, name);
toolkitThread = new Thread(ThreadGroupUtils.getRootThreadGroup(), LWToolkit.this, name);
} else {
toolkitThread = new InnocuousThread(LWToolkit.this, name);
}
toolkitThread.setDaemon(true); toolkitThread.setDaemon(true);
toolkitThread.setPriority(Thread.NORM_PRIORITY + 1); toolkitThread.setPriority(Thread.NORM_PRIORITY + 1);
toolkitThread.start(); toolkitThread.start();

View File

@ -181,13 +181,7 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
} }
} }
}; };
Thread dragThread; new ManagedLocalsThread(dragRunnable).start();
if (System.getSecurityManager() == null) {
dragThread = new Thread(dragRunnable);
} else {
dragThread = new ManagedLocalsThread(dragRunnable);
}
dragThread.start();
} catch (Exception e) { } catch (Exception e) {
final long nativeDragSource = getNativeContext(); final long nativeDragSource = getNativeContext();
setNativeContext(0); setNativeContext(0);

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -120,11 +120,7 @@ class CFileDialog implements FileDialogPeer {
if (visible) { if (visible) {
// Java2 Dialog class requires peer to run code in a separate thread // Java2 Dialog class requires peer to run code in a separate thread
// and handles keeping the call modal // and handles keeping the call modal
if (System.getSecurityManager() == null) { new ManagedLocalsThread(new Task()).start();
new Thread(new Task()).start();
} else {
new ManagedLocalsThread(new Task()).start();
}
} }
// We hide ourself before "show" returns - setVisible(false) // We hide ourself before "show" returns - setVisible(false)
// doesn't apply // doesn't apply

View File

@ -59,11 +59,7 @@ public class CPrinterDialogPeer extends LWWindowPeer {
printerDialog.setRetVal(printerDialog.showDialog()); printerDialog.setRetVal(printerDialog.showDialog());
printerDialog.setVisible(false); printerDialog.setVisible(false);
}; };
if (System.getSecurityManager() == null) { new ManagedLocalsThread(task).start();
new Thread(task).start();
} else {
new ManagedLocalsThread(task).start();
}
} }
} }

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -736,12 +736,7 @@ public final class CPrinterJob extends RasterPrinterJob {
// upcall from native // upcall from native
private static void detachPrintLoop(final long target, final long arg) { private static void detachPrintLoop(final long target, final long arg) {
Runnable task = () -> _safePrintLoop(target, arg); new ManagedLocalsThread(() -> _safePrintLoop(target, arg)).start();
if (System.getSecurityManager() == null) {
new Thread(task).start();
} else {
new ManagedLocalsThread(task).start();
}
} }
private static native void _safePrintLoop(long target, long arg); private static native void _safePrintLoop(long target, long arg);
@ -779,4 +774,4 @@ public final class CPrinterJob extends RasterPrinterJob {
(float) (paper.getImageableHeight() / dpi), (float) (paper.getImageableHeight() / dpi),
MediaPrintableArea.INCH); MediaPrintableArea.INCH);
} }
} }

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -26,7 +26,7 @@
package com.sun.imageio.stream; package com.sun.imageio.stream;
import sun.awt.util.ThreadGroupUtils; import sun.awt.util.ThreadGroupUtils;
import sun.misc.InnocuousThread; import sun.misc.ManagedLocalsThread;
import java.io.IOException; import java.io.IOException;
import java.security.AccessController; import java.security.AccessController;
@ -87,17 +87,13 @@ public class StreamCloser {
}; };
AccessController.doPrivileged((PrivilegedAction<Object>) () -> { AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
if (System.getSecurityManager() == null) { /* The thread must be a member of a thread group
/* The thread must be a member of a thread group * which will not get GCed before VM exit.
* which will not get GCed before VM exit. * Make its parent the top-level thread group.
* Make its parent the top-level thread group. */
*/ ThreadGroup tg = ThreadGroupUtils.getRootThreadGroup();
ThreadGroup tg = ThreadGroupUtils.getRootThreadGroup(); streamCloser = new ManagedLocalsThread(tg,
streamCloser = new Thread(tg, streamCloserRunnable); streamCloserRunnable);
} else {
/* InnocuousThread is a member of a correct TG by default */
streamCloser = new InnocuousThread(streamCloserRunnable);
}
/* Set context class loader to null in order to avoid /* Set context class loader to null in order to avoid
* keeping a strong reference to an application classloader. * keeping a strong reference to an application classloader.
*/ */

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -2038,11 +2038,7 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
if (audioRunnable != null) { if (audioRunnable != null) {
// Runnable appears to block until completed playing, hence // Runnable appears to block until completed playing, hence
// start up another thread to handle playing. // start up another thread to handle playing.
if (System.getSecurityManager() == null) { new ManagedLocalsThread(audioRunnable).start();
new Thread(audioRunnable).start();
} else {
new ManagedLocalsThread(audioRunnable).start();
}
} }
} }
} }

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,7 +25,6 @@
package com.sun.media.sound; package com.sun.media.sound;
import sun.misc.InnocuousThread;
import sun.misc.ManagedLocalsThread; import sun.misc.ManagedLocalsThread;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
@ -147,12 +146,7 @@ final class JSSecurityManager {
final String threadName, final String threadName,
final boolean isDaemon, final int priority, final boolean isDaemon, final int priority,
final boolean doStart) { final boolean doStart) {
Thread thread; Thread thread = new ManagedLocalsThread(runnable);
if (System.getSecurityManager() == null) {
thread = new Thread(runnable);
} else {
thread = new ManagedLocalsThread(runnable);
}
if (threadName != null) { if (threadName != null) {
thread.setName(threadName); thread.setName(threadName);

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -55,11 +55,7 @@ public final class SoftAudioPusher implements Runnable {
if (active) if (active)
return; return;
active = true; active = true;
if (System.getSecurityManager() == null) { audiothread = new ManagedLocalsThread(this);
audiothread = new Thread(this);
} else {
audiothread = new ManagedLocalsThread(this);
}
audiothread.setDaemon(true); audiothread.setDaemon(true);
audiothread.setPriority(Thread.MAX_PRIORITY); audiothread.setPriority(Thread.MAX_PRIORITY);
audiothread.start(); audiothread.start();

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -216,11 +216,7 @@ public final class SoftJitterCorrector extends AudioInputStream {
} }
}; };
if (System.getSecurityManager() == null) { thread = new ManagedLocalsThread(runnable);
thread = new Thread(runnable);
} else {
thread = new ManagedLocalsThread(runnable);
}
thread.setDaemon(true); thread.setDaemon(true);
thread.setPriority(Thread.MAX_PRIORITY); thread.setPriority(Thread.MAX_PRIORITY);
thread.start(); thread.start();

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -141,11 +141,7 @@ public final class SoftSynthesizer implements AudioSynthesizer,
pusher = null; pusher = null;
jitter_stream = null; jitter_stream = null;
sourceDataLine = null; sourceDataLine = null;
if (System.getSecurityManager() == null) { new ManagedLocalsThread(runnable).start();
new Thread(runnable).start();
} else {
new ManagedLocalsThread(runnable).start();
}
} }
return len; return len;
} }

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -67,7 +67,7 @@ class EventDispatchThread extends ManagedLocalsThread {
private ArrayList<EventFilter> eventFilters = new ArrayList<EventFilter>(); private ArrayList<EventFilter> eventFilters = new ArrayList<EventFilter>();
EventDispatchThread(ThreadGroup group, String name, EventQueue queue) { EventDispatchThread(ThreadGroup group, String name, EventQueue queue) {
super(group, null, name); super(group, name);
setEventQueue(queue); setEventQueue(queue);
} }

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -137,12 +137,7 @@ public class RenderableImageProducer implements ImageProducer, Runnable {
addConsumer(ic); addConsumer(ic);
// Need to build a runnable object for the Thread. // Need to build a runnable object for the Thread.
String name = "RenderableImageProducer Thread"; String name = "RenderableImageProducer Thread";
Thread thread; Thread thread = new ManagedLocalsThread(this, name);
if (System.getSecurityManager() == null) {
thread = new Thread(this, name);
} else {
thread = new ManagedLocalsThread(this);
}
thread.start(); thread.start();
} }

View File

@ -6402,12 +6402,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
}; };
// start printing on another thread // start printing on another thread
Thread th; Thread th = new ManagedLocalsThread(runnable);
if (System.getSecurityManager() == null) {
th = new Thread(runnable);
} else {
th = new ManagedLocalsThread(runnable);
}
th.start(); th.start();
printingStatus.showModal(true); printingStatus.showModal(true);

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -36,8 +36,7 @@ import java.util.concurrent.*;
import java.util.concurrent.locks.*; import java.util.concurrent.locks.*;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import sun.awt.AppContext; import sun.awt.AppContext;
import sun.misc.InnocuousThread; import sun.misc.ManagedLocalsThread;
/** /**
* Internal class to manage all Timers using one thread. * Internal class to manage all Timers using one thread.
@ -99,12 +98,8 @@ class TimerQueue implements Runnable
final ThreadGroup threadGroup = AppContext.getAppContext().getThreadGroup(); final ThreadGroup threadGroup = AppContext.getAppContext().getThreadGroup();
AccessController.doPrivileged((PrivilegedAction<Object>) () -> { AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
String name = "TimerQueue"; String name = "TimerQueue";
Thread timerThread; Thread timerThread = new ManagedLocalsThread(threadGroup,
if (System.getSecurityManager() == null) { this, name);
timerThread = new Thread(threadGroup, TimerQueue.this, name);
} else {
timerThread = new InnocuousThread(threadGroup, TimerQueue.this, name);
}
timerThread.setDaemon(true); timerThread.setDaemon(true);
timerThread.setPriority(Thread.NORM_PRIORITY); timerThread.setPriority(Thread.NORM_PRIORITY);
timerThread.start(); timerThread.start();

View File

@ -271,11 +271,7 @@ public class BasicDirectoryModel extends AbstractListModel<Object> implements Pr
this.currentDirectory = currentDirectory; this.currentDirectory = currentDirectory;
this.fid = fid; this.fid = fid;
String name = "Basic L&F File Loading Thread"; String name = "Basic L&F File Loading Thread";
if (System.getSecurityManager() == null) { this.loadThread = new ManagedLocalsThread(this, name);
this.loadThread = new Thread(this, name);
} else {
this.loadThread = new ManagedLocalsThread(this, name);
}
this.loadThread.start(); this.loadThread.start();
} }

View File

@ -2365,11 +2365,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
runnablePrinting.run(); runnablePrinting.run();
} else { } else {
if (isEventDispatchThread) { if (isEventDispatchThread) {
if (System.getSecurityManager() == null) { new ManagedLocalsThread(runnablePrinting).start();
new Thread(runnablePrinting).start();
} else {
new ManagedLocalsThread(runnablePrinting).start();
}
printingStatus.showModal(true); printingStatus.showModal(true);
} else { } else {
printingStatus.showModal(false); printingStatus.showModal(false);

View File

@ -92,12 +92,7 @@ public class LayoutQueue {
} }
} while (work != null); } while (work != null);
}; };
String name = "text-layout"; worker = new ManagedLocalsThread(workerRunnable, "text-layout");
if (System.getSecurityManager() == null) {
worker = new Thread(workerRunnable, name);
} else {
worker = new ManagedLocalsThread(workerRunnable, name);
}
worker.setPriority(Thread.MIN_PRIORITY); worker.setPriority(Thread.MIN_PRIORITY);
worker.start(); worker.start();
} }

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -862,7 +862,7 @@ class AppContextCreator extends ManagedLocalsThread {
volatile boolean created = false; volatile boolean created = false;
AppContextCreator(ThreadGroup group) { AppContextCreator(ThreadGroup group) {
super(group, null, "AppContextCreator"); super(group, "AppContextCreator");
} }
public void run() { public void run() {

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -34,7 +34,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import sun.awt.util.ThreadGroupUtils; import sun.awt.util.ThreadGroupUtils;
import sun.misc.InnocuousThread; import sun.misc.ManagedLocalsThread;
import sun.util.logging.PlatformLogger; import sun.util.logging.PlatformLogger;
/** /**
@ -336,14 +336,9 @@ public final class AWTAutoShutdown implements Runnable {
*/ */
private void activateBlockerThread() { private void activateBlockerThread() {
AccessController.doPrivileged((PrivilegedAction<Thread>) () -> { AccessController.doPrivileged((PrivilegedAction<Thread>) () -> {
Thread thread;
String name = "AWT-Shutdown"; String name = "AWT-Shutdown";
if (System.getSecurityManager() == null) { Thread thread = new ManagedLocalsThread(
thread = new Thread(ThreadGroupUtils.getRootThreadGroup(), this, ThreadGroupUtils.getRootThreadGroup(), this, name);
name);
} else {
thread = new InnocuousThread(this, name);
}
thread.setContextClassLoader(null); thread.setContextClassLoader(null);
thread.setDaemon(false); thread.setDaemon(false);
blockerThread = thread; blockerThread = thread;

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -44,7 +44,7 @@ import java.beans.PropertyChangeSupport;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.lang.ref.SoftReference; import java.lang.ref.SoftReference;
import sun.misc.InnocuousThread; import sun.misc.ManagedLocalsThread;
import sun.util.logging.PlatformLogger; import sun.util.logging.PlatformLogger;
import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.Lock;
@ -591,13 +591,9 @@ public final class AppContext {
} }
public Thread run() { public Thread run() {
Thread t; Thread t = new ManagedLocalsThread(appContext.getThreadGroup(),
if (System.getSecurityManager() == null) { runnable, "AppContext Disposer");
t = new Thread(appContext.getThreadGroup(), runnable); t.setContextClassLoader(appContext.getContextClassLoader());
} else {
t = new InnocuousThread(appContext.getThreadGroup(), runnable, "AppContext Disposer");
}
t.setContextClassLoader(null);
t.setPriority(Thread.NORM_PRIORITY + 1); t.setPriority(Thread.NORM_PRIORITY + 1);
t.setDaemon(true); t.setDaemon(true);
return t; return t;

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -167,12 +167,7 @@ public abstract class InputMethodManager {
// to choose from. Otherwise, just keep the instance. // to choose from. Otherwise, just keep the instance.
if (imm.hasMultipleInputMethods()) { if (imm.hasMultipleInputMethods()) {
imm.initialize(); imm.initialize();
Thread immThread; Thread immThread = new ManagedLocalsThread(imm, threadName);
if (System.getSecurityManager() == null) {
immThread = new Thread(imm, threadName);
} else {
immThread = new ManagedLocalsThread(imm, threadName);
}
immThread.setDaemon(true); immThread.setDaemon(true);
immThread.setPriority(Thread.NORM_PRIORITY + 1); immThread.setPriority(Thread.NORM_PRIORITY + 1);
immThread.start(); immThread.start();

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -55,7 +55,7 @@ class ImageFetcher extends ManagedLocalsThread {
* Constructor for ImageFetcher -- only called by add() below. * Constructor for ImageFetcher -- only called by add() below.
*/ */
private ImageFetcher(ThreadGroup threadGroup, int index) { private ImageFetcher(ThreadGroup threadGroup, int index) {
super(threadGroup, null, "Image Fetcher " + index); super(threadGroup, "Image Fetcher " + index);
setDaemon(true); setDaemon(true);
} }

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -36,7 +36,7 @@ import java.util.concurrent.TimeUnit;
import sun.awt.AppContext; import sun.awt.AppContext;
import sun.awt.util.ThreadGroupUtils; import sun.awt.util.ThreadGroupUtils;
import sun.misc.InnocuousThread; import sun.misc.ManagedLocalsThread;
public class CreatedFontTracker { public class CreatedFontTracker {
@ -117,17 +117,13 @@ public class CreatedFontTracker {
if (t == null) { if (t == null) {
// Add a shutdown hook to remove the temp file. // Add a shutdown hook to remove the temp file.
AccessController.doPrivileged((PrivilegedAction<Void>) () -> { AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
if (System.getSecurityManager() == null) { /* The thread must be a member of a thread group
/* The thread must be a member of a thread group * which will not get GCed before VM exit.
* which will not get GCed before VM exit. * Make its parent the top-level thread group.
* Make its parent the top-level thread group. */
*/ ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup(); t = new ManagedLocalsThread(rootTG,
t = new Thread(rootTG, TempFileDeletionHook::runHooks); TempFileDeletionHook::runHooks);
} else {
/* InnocuousThread is a member of a correct TG by default */
t = new InnocuousThread(TempFileDeletionHook::runHooks);
}
/* Set context class loader to null in order to avoid /* Set context class loader to null in order to avoid
* keeping a strong reference to an application classloader. * keeping a strong reference to an application classloader.
*/ */

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -55,6 +55,7 @@ import sun.awt.SunToolkit;
import sun.awt.util.ThreadGroupUtils; import sun.awt.util.ThreadGroupUtils;
import sun.java2d.FontSupport; import sun.java2d.FontSupport;
import sun.misc.InnocuousThread; import sun.misc.InnocuousThread;
import sun.misc.ManagedLocalsThread;
import sun.util.logging.PlatformLogger; import sun.util.logging.PlatformLogger;
/** /**
@ -2501,12 +2502,9 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
} }
}; };
AccessController.doPrivileged((PrivilegedAction<Void>) () -> { AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
if (System.getSecurityManager() == null) { ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup(); fileCloser = new ManagedLocalsThread(rootTG,
fileCloser = new Thread(rootTG, fileCloserRunnable); fileCloserRunnable);
} else {
fileCloser = new InnocuousThread(fileCloserRunnable);
}
fileCloser.setContextClassLoader(null); fileCloser.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(fileCloser); Runtime.getRuntime().addShutdownHook(fileCloser);
return null; return null;

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -26,7 +26,7 @@
package sun.java2d; package sun.java2d;
import sun.awt.util.ThreadGroupUtils; import sun.awt.util.ThreadGroupUtils;
import sun.misc.InnocuousThread; import sun.misc.ManagedLocalsThread;
import java.lang.ref.Reference; import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue; import java.lang.ref.ReferenceQueue;
@ -84,13 +84,8 @@ public class Disposer implements Runnable {
disposerInstance = new Disposer(); disposerInstance = new Disposer();
AccessController.doPrivileged((PrivilegedAction<Void>) () -> { AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
String name = "Java2D Disposer"; String name = "Java2D Disposer";
Thread t; ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
if (System.getSecurityManager() == null) { Thread t = new ManagedLocalsThread(rootTG, disposerInstance, name);
ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
t = new Thread(rootTG, disposerInstance, name);
} else {
t = new InnocuousThread(disposerInstance, name);
}
t.setContextClassLoader(null); t.setContextClassLoader(null);
t.setDaemon(true); t.setDaemon(true);
t.setPriority(Thread.MAX_PRIORITY); t.setPriority(Thread.MAX_PRIORITY);

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -48,7 +48,7 @@ import java.io.FileNotFoundException;
import java.security.AccessController; import java.security.AccessController;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
import sun.misc.InnocuousThread; import sun.misc.ManagedLocalsThread;
import sun.security.action.GetPropertyAction; import sun.security.action.GetPropertyAction;
/** /**
@ -420,12 +420,8 @@ public abstract class GraphicsPrimitive {
public static void setShutdownHook() { public static void setShutdownHook() {
AccessController.doPrivileged((PrivilegedAction<Void>) () -> { AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
TraceReporter t = new TraceReporter(); TraceReporter t = new TraceReporter();
Thread thread; Thread thread = new ManagedLocalsThread(
if (System.getSecurityManager() == null) { ThreadGroupUtils.getRootThreadGroup(), t);
thread = new Thread(ThreadGroupUtils.getRootThreadGroup(), t);
} else {
thread = new InnocuousThread(t);
}
thread.setContextClassLoader(null); thread.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(thread); Runtime.getRuntime().addShutdownHook(thread);
return null; return null;

View File

@ -29,6 +29,7 @@ import sun.awt.util.ThreadGroupUtils;
import sun.java2d.pipe.RenderBuffer; import sun.java2d.pipe.RenderBuffer;
import sun.java2d.pipe.RenderQueue; import sun.java2d.pipe.RenderQueue;
import sun.misc.InnocuousThread; import sun.misc.InnocuousThread;
import sun.misc.ManagedLocalsThread;
import static sun.java2d.pipe.BufferedOpCodes.*; import static sun.java2d.pipe.BufferedOpCodes.*;
import java.security.AccessController; import java.security.AccessController;
@ -161,11 +162,7 @@ public class OGLRenderQueue extends RenderQueue {
public QueueFlusher() { public QueueFlusher() {
String name = "Java2D Queue Flusher"; String name = "Java2D Queue Flusher";
if (System.getSecurityManager() == null) { thread = new ManagedLocalsThread(ThreadGroupUtils.getRootThreadGroup(), this, name);
this.thread = new Thread(ThreadGroupUtils.getRootThreadGroup(), this, name);
} else {
this.thread = new InnocuousThread(this, name);
}
thread.setDaemon(true); thread.setDaemon(true);
thread.setPriority(Thread.MAX_PRIORITY); thread.setPriority(Thread.MAX_PRIORITY);
thread.start(); thread.start();

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -987,12 +987,7 @@ public class PrintJob2D extends PrintJob implements Printable, Runnable {
} }
private void startPrinterJobThread() { private void startPrinterJobThread() {
String name = "printerJobThread"; printerJobThread = new ManagedLocalsThread(this, "printerJobThread");
if (System.getSecurityManager() == null) {
printerJobThread = new Thread(this, name);
} else {
printerJobThread = new ManagedLocalsThread(this, name);
}
printerJobThread.start(); printerJobThread.start();
} }

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -50,7 +50,7 @@ class ServiceNotifier extends ManagedLocalsThread {
private PrintServiceAttributeSet lastSet; private PrintServiceAttributeSet lastSet;
ServiceNotifier(PrintService service) { ServiceNotifier(PrintService service) {
super((Runnable) null, service.getName() + " notifier"); super(service.getName() + " notifier");
this.service = service; this.service = service;
listeners = new Vector<>(); listeners = new Vector<>();
try { try {

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -116,12 +116,7 @@ final class GtkFileDialogPeer extends XDialogPeer implements FileDialogPeer {
showNativeDialog(); showNativeDialog();
fd.setVisible(false); fd.setVisible(false);
}; };
if (System.getSecurityManager() == null) { new ManagedLocalsThread(task).start();
new Thread(task).start();
} else {
new ManagedLocalsThread(task).start();
}
} else { } else {
quit(); quit();
fd.setVisible(false); fd.setVisible(false);

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -29,7 +29,6 @@ import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.awt.peer.TrayIconPeer; import java.awt.peer.TrayIconPeer;
import sun.awt.*; import sun.awt.*;
import sun.misc.InnocuousThread;
import sun.misc.ManagedLocalsThread; import sun.misc.ManagedLocalsThread;
import java.awt.image.*; import java.awt.image.*;
@ -455,11 +454,7 @@ public abstract class InfoWindow extends Window {
final Thread thread; final Thread thread;
Displayer() { Displayer() {
if (System.getSecurityManager() == null) { this.thread = new ManagedLocalsThread(this);
this.thread = new Thread(this);
} else {
this.thread = new ManagedLocalsThread(this);
}
this.thread.setDaemon(true); this.thread.setDaemon(true);
} }

View File

@ -281,12 +281,8 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
} }
}; };
String name = "XToolkt-Shutdown-Thread"; String name = "XToolkt-Shutdown-Thread";
Thread shutdownThread; Thread shutdownThread = new ManagedLocalsThread(
if (System.getSecurityManager() == null) { ThreadGroupUtils.getRootThreadGroup(), r, name);
shutdownThread = new Thread(ThreadGroupUtils.getRootThreadGroup(), r, name);
} else {
shutdownThread = new InnocuousThread(r, name);
}
shutdownThread.setContextClassLoader(null); shutdownThread.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(shutdownThread); Runtime.getRuntime().addShutdownHook(shutdownThread);
return null; return null;
@ -333,12 +329,8 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
toolkitThread = AccessController.doPrivileged((PrivilegedAction<Thread>) () -> { toolkitThread = AccessController.doPrivileged((PrivilegedAction<Thread>) () -> {
String name = "AWT-XAWT"; String name = "AWT-XAWT";
Thread thread; Thread thread = new ManagedLocalsThread(
if (System.getSecurityManager() == null) { ThreadGroupUtils.getRootThreadGroup(), this, name);
thread = new Thread(ThreadGroupUtils.getRootThreadGroup(), XToolkit.this, name);
} else {
thread = new InnocuousThread(XToolkit.this, name);
}
thread.setContextClassLoader(null); thread.setContextClassLoader(null);
thread.setPriority(Thread.NORM_PRIORITY + 1); thread.setPriority(Thread.NORM_PRIORITY + 1);
thread.setDaemon(true); thread.setDaemon(true);

View File

@ -43,7 +43,7 @@ import sun.java2d.xr.XRGraphicsConfig;
import sun.java2d.loops.SurfaceType; import sun.java2d.loops.SurfaceType;
import sun.awt.util.ThreadGroupUtils; import sun.awt.util.ThreadGroupUtils;
import sun.misc.InnocuousThread; import sun.misc.ManagedLocalsThread;
/** /**
* This is an implementation of a GraphicsDevice object for a single * This is an implementation of a GraphicsDevice object for a single
@ -437,12 +437,8 @@ public final class X11GraphicsDevice extends GraphicsDevice
} }
}; };
String name = "Display-Change-Shutdown-Thread-" + screen; String name = "Display-Change-Shutdown-Thread-" + screen;
Thread t; Thread t = new ManagedLocalsThread(
if (System.getSecurityManager() == null) { ThreadGroupUtils.getRootThreadGroup(), r, name);
t = new Thread(ThreadGroupUtils.getRootThreadGroup(), r, name);
} else {
t = new InnocuousThread(r, name);
}
t.setContextClassLoader(null); t.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(t); Runtime.getRuntime().addShutdownHook(t);
return null; return null;

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -213,12 +213,7 @@ public class PrintServiceLookupProvider extends PrintServiceLookup
public PrintServiceLookupProvider() { public PrintServiceLookupProvider() {
// start the printer listener thread // start the printer listener thread
if (pollServices) { if (pollServices) {
Thread thr; Thread thr = new ManagedLocalsThread(new PrinterChangeListener());
if (System.getSecurityManager() == null) {
thr = new Thread(new PrinterChangeListener());
} else {
thr = new ManagedLocalsThread(new PrinterChangeListener());
}
thr.setDaemon(true); thr.setDaemon(true);
thr.start(); thr.start();
IPPPrintService.debug_println(debugPrefix+"polling turned on"); IPPPrintService.debug_println(debugPrefix+"polling turned on");

View File

@ -41,8 +41,7 @@ import java.util.stream.Stream;
import static sun.awt.shell.Win32ShellFolder2.*; import static sun.awt.shell.Win32ShellFolder2.*;
import sun.awt.OSInfo; import sun.awt.OSInfo;
import sun.awt.util.ThreadGroupUtils; import sun.awt.util.ThreadGroupUtils;
import sun.misc.InnocuousThread; import sun.misc.ManagedLocalsThread;
// NOTE: This class supersedes Win32ShellFolderManager, which was removed // NOTE: This class supersedes Win32ShellFolderManager, which was removed
// from distribution after version 1.4.2. // from distribution after version 1.4.2.
@ -525,12 +524,8 @@ final class Win32ShellFolderManager2 extends ShellFolderManager {
return null; return null;
}); });
AccessController.doPrivileged((PrivilegedAction<Void>) () -> { AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
Thread t; Thread t = new ManagedLocalsThread(
if (System.getSecurityManager() == null) { ThreadGroupUtils.getRootThreadGroup(), shutdownHook);
t = new Thread(ThreadGroupUtils.getRootThreadGroup(), shutdownHook);
} else {
t = new InnocuousThread(shutdownHook);
}
Runtime.getRuntime().addShutdownHook(t); Runtime.getRuntime().addShutdownHook(t);
return null; return null;
}); });
@ -549,17 +544,12 @@ final class Win32ShellFolderManager2 extends ShellFolderManager {
}; };
comThread = AccessController.doPrivileged((PrivilegedAction<Thread>) () -> { comThread = AccessController.doPrivileged((PrivilegedAction<Thread>) () -> {
String name = "Swing-Shell"; String name = "Swing-Shell";
Thread thread; /* The thread must be a member of a thread group
if (System.getSecurityManager() == null) { * which will not get GCed before VM exit.
/* The thread must be a member of a thread group * Make its parent the top-level 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 = new Thread(ThreadGroupUtils.getRootThreadGroup(), comRun, name);
} else {
/* InnocuousThread is a member of a correct TG by default */
thread = new InnocuousThread(comRun, name);
}
thread.setDaemon(true); thread.setDaemon(true);
return thread; return thread;
}); });

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -98,11 +98,7 @@ final class WFileDialogPeer extends WWindowPeer implements FileDialogPeer {
@Override @Override
public void show() { public void show() {
if (System.getSecurityManager() == null) { new ManagedLocalsThread(this::_show).start();
new Thread(this::_show).start();
} else {
new ManagedLocalsThread(this::_show).start();
}
} }
@Override @Override

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -53,10 +53,6 @@ final class WPageDialogPeer extends WPrintDialogPeer {
} }
((WPrintDialog)target).setVisible(false); ((WPrintDialog)target).setVisible(false);
}; };
if (System.getSecurityManager() == null) { new ManagedLocalsThread(runnable).start();
new Thread(runnable).start();
} else {
new ManagedLocalsThread(runnable).start();
}
} }
} }

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -78,11 +78,7 @@ class WPrintDialogPeer extends WWindowPeer implements DialogPeer {
} }
((WPrintDialog)target).setVisible(false); ((WPrintDialog)target).setVisible(false);
}; };
if (System.getSecurityManager() == null) { new ManagedLocalsThread(runnable).start();
new Thread(runnable).start();
} else {
new ManagedLocalsThread(runnable).start();
}
} }
synchronized void setHWnd(long hwnd) { synchronized void setHWnd(long hwnd) {

View File

@ -51,7 +51,7 @@ import sun.awt.datatransfer.DataTransferer;
import sun.java2d.d3d.D3DRenderQueue; import sun.java2d.d3d.D3DRenderQueue;
import sun.java2d.opengl.OGLRenderQueue; import sun.java2d.opengl.OGLRenderQueue;
import sun.misc.InnocuousThread; import sun.misc.ManagedLocalsThread;
import sun.print.PrintJob2D; import sun.print.PrintJob2D;
import java.awt.dnd.DragSource; import java.awt.dnd.DragSource;
@ -255,12 +255,7 @@ public final class WToolkit extends SunToolkit implements Runnable {
(PrivilegedAction<ThreadGroup>) ThreadGroupUtils::getRootThreadGroup); (PrivilegedAction<ThreadGroup>) ThreadGroupUtils::getRootThreadGroup);
if (!startToolkitThread(this, rootTG)) { if (!startToolkitThread(this, rootTG)) {
String name = "AWT-Windows"; String name = "AWT-Windows";
Thread toolkitThread; Thread toolkitThread = new ManagedLocalsThread(rootTG, this, name);
if (System.getSecurityManager() == null) {
toolkitThread = new Thread(rootTG, this, name);
} else {
toolkitThread = new InnocuousThread(this, name);
}
toolkitThread.setDaemon(true); toolkitThread.setDaemon(true);
toolkitThread.start(); toolkitThread.start();
} }
@ -287,16 +282,12 @@ public final class WToolkit extends SunToolkit implements Runnable {
private void registerShutdownHook() { private void registerShutdownHook() {
AccessController.doPrivileged((PrivilegedAction<Void>) () -> { AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
Thread shutdown; Thread shutdown = new ManagedLocalsThread(
if (System.getSecurityManager() == null) { ThreadGroupUtils.getRootThreadGroup(), this::shutdown);
shutdown = new Thread(ThreadGroupUtils.getRootThreadGroup(), this::shutdown);
} else {
shutdown = new InnocuousThread(this::shutdown);
}
shutdown.setContextClassLoader(null); shutdown.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(shutdown); Runtime.getRuntime().addShutdownHook(shutdown);
return null; return null;
}); });
} }
@Override @Override

View File

@ -49,7 +49,7 @@ import sun.java2d.SurfaceData;
import sun.java2d.windows.GDIWindowSurfaceData; import sun.java2d.windows.GDIWindowSurfaceData;
import sun.java2d.d3d.D3DSurfaceData.D3DWindowSurfaceData; import sun.java2d.d3d.D3DSurfaceData.D3DWindowSurfaceData;
import sun.java2d.windows.WindowsFlags; import sun.java2d.windows.WindowsFlags;
import sun.misc.InnocuousThread; import sun.misc.ManagedLocalsThread;
/** /**
* This class handles rendering to the screen with the D3D pipeline. * This class handles rendering to the screen with the D3D pipeline.
@ -99,12 +99,8 @@ public class D3DScreenUpdateManager extends ScreenUpdateManager
done = true; done = true;
wakeUpUpdateThread(); wakeUpUpdateThread();
}; };
Thread shutdown; Thread shutdown = new ManagedLocalsThread(
if (System.getSecurityManager() == null) { ThreadGroupUtils.getRootThreadGroup(), shutdownRunnable);
shutdown = new Thread(ThreadGroupUtils.getRootThreadGroup(), shutdownRunnable);
} else {
shutdown = new InnocuousThread(shutdownRunnable);
}
shutdown.setContextClassLoader(null); shutdown.setContextClassLoader(null);
try { try {
Runtime.getRuntime().addShutdownHook(shutdown); Runtime.getRuntime().addShutdownHook(shutdown);
@ -351,15 +347,9 @@ public class D3DScreenUpdateManager extends ScreenUpdateManager
private synchronized void startUpdateThread() { private synchronized void startUpdateThread() {
if (screenUpdater == null) { if (screenUpdater == null) {
screenUpdater = AccessController.doPrivileged((PrivilegedAction<Thread>) () -> { screenUpdater = AccessController.doPrivileged((PrivilegedAction<Thread>) () -> {
Thread t;
String name = "D3D Screen Updater"; String name = "D3D Screen Updater";
if (System.getSecurityManager() == null) { Thread t = new ManagedLocalsThread(
t = new Thread(ThreadGroupUtils.getRootThreadGroup(), ThreadGroupUtils.getRootThreadGroup(), this, name);
D3DScreenUpdateManager.this,
name);
} else {
t = new InnocuousThread(D3DScreenUpdateManager.this, name);
}
// REMIND: should it be higher? // REMIND: should it be higher?
t.setPriority(Thread.NORM_PRIORITY + 2); t.setPriority(Thread.NORM_PRIORITY + 2);
t.setDaemon(true); t.setDaemon(true);

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -99,12 +99,7 @@ public class PrintServiceLookupProvider extends PrintServiceLookup {
return; return;
} }
// start the printer listener thread // start the printer listener thread
Thread thr; Thread thr = new ManagedLocalsThread(new PrinterChangeListener());
if (System.getSecurityManager() == null) {
thr = new Thread(new PrinterChangeListener());
} else {
thr = new ManagedLocalsThread(new PrinterChangeListener());
}
thr.setDaemon(true); thr.setDaemon(true);
thr.start(); thr.start();
} /* else condition ought to never happen! */ } /* else condition ought to never happen! */

View File

@ -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);
}
}

View File

@ -0,0 +1,4 @@
grant {
permission java.util.PropertyPermission "os.name", "read";
permission java.awt.AWTPermission "createRobot";
};