提交 21e3f434 编写于 作者: L lbourges

8144630: Use PrivilegedAction to create Thread in Marlin RendererStats

Reviewed-by: phh, andrew
上级 cdbd5f15
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
package sun.java2d.marlin; package sun.java2d.marlin;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
...@@ -32,6 +34,7 @@ import static sun.java2d.marlin.MarlinUtils.logInfo; ...@@ -32,6 +34,7 @@ import static sun.java2d.marlin.MarlinUtils.logInfo;
import sun.java2d.marlin.stats.Histogram; import sun.java2d.marlin.stats.Histogram;
import sun.java2d.marlin.stats.Monitor; import sun.java2d.marlin.stats.Monitor;
import sun.java2d.marlin.stats.StatLong; import sun.java2d.marlin.stats.StatLong;
import sun.misc.ThreadGroupUtils;
/** /**
* This class gathers global rendering statistics for debugging purposes only * This class gathers global rendering statistics for debugging purposes only
...@@ -237,12 +240,20 @@ public final class RendererStats implements MarlinConst { ...@@ -237,12 +240,20 @@ public final class RendererStats implements MarlinConst {
private RendererStats() { private RendererStats() {
super(); super();
Runtime.getRuntime().addShutdownHook(new Thread() { AccessController.doPrivileged(
(PrivilegedAction<Void>) () -> {
final Thread hook = new Thread(
ThreadGroupUtils.getRootThreadGroup(),
new Runnable() {
@Override @Override
public void run() { public void run() {
dump(); dump();
} }
}); },
"MarlinStatsHook"
);
hook.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(hook);
if (useDumpThread) { if (useDumpThread) {
final Timer statTimer = new Timer("RendererStats"); final Timer statTimer = new Timer("RendererStats");
...@@ -253,6 +264,9 @@ public final class RendererStats implements MarlinConst { ...@@ -253,6 +264,9 @@ public final class RendererStats implements MarlinConst {
} }
}, statDump, statDump); }, statDump, statDump);
} }
return null;
}
);
} }
void dump() { void dump() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册