Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
1dde2675
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
1dde2675
编写于
12月 20, 2013
作者:
P
pchelko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8025010: Enhance AWT contexts
Reviewed-by: art, serb, hawtin
上级
d7d5a6d0
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
80 addition
and
37 deletion
+80
-37
src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java
src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java
+5
-1
src/macosx/native/sun/awt/LWCToolkit.m
src/macosx/native/sun/awt/LWCToolkit.m
+3
-3
src/macosx/native/sun/awt/awt.m
src/macosx/native/sun/awt/awt.m
+9
-0
src/macosx/native/sun/osxapp/ThreadUtilities.h
src/macosx/native/sun/osxapp/ThreadUtilities.h
+4
-0
src/macosx/native/sun/osxapp/ThreadUtilities.m
src/macosx/native/sun/osxapp/ThreadUtilities.m
+19
-2
src/share/classes/sun/awt/AWTAutoShutdown.java
src/share/classes/sun/awt/AWTAutoShutdown.java
+7
-1
src/share/classes/sun/awt/SunToolkit.java
src/share/classes/sun/awt/SunToolkit.java
+12
-0
src/solaris/classes/sun/awt/X11/XToolkit.java
src/solaris/classes/sun/awt/X11/XToolkit.java
+3
-14
src/windows/classes/sun/awt/windows/WToolkit.java
src/windows/classes/sun/awt/windows/WToolkit.java
+11
-12
src/windows/native/sun/windows/awt_Toolkit.cpp
src/windows/native/sun/windows/awt_Toolkit.cpp
+7
-4
未找到文件。
src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java
浏览文件 @
1dde2675
...
...
@@ -444,8 +444,12 @@ public final class LWCToolkit extends LWToolkit {
}
// Intended to be called from the LWCToolkit.m only.
private
static
void
installToolkitThread
Name
InJava
()
{
private
static
void
installToolkitThreadInJava
()
{
Thread
.
currentThread
().
setName
(
CThreading
.
APPKIT_THREAD_NAME
);
AccessController
.
doPrivileged
((
PrivilegedAction
<
Void
>)
()
->
{
Thread
.
currentThread
().
setContextClassLoader
(
null
);
return
null
;
});
}
@Override
...
...
src/macosx/native/sun/awt/LWCToolkit.m
浏览文件 @
1dde2675
...
...
@@ -193,8 +193,8 @@ Java_sun_lwawt_macosx_LWCToolkit_initIDs
JNIEnv
*
env
=
[
ThreadUtilities
getJNIEnv
];
static
JNF_CLASS_CACHE
(
jc_LWCToolkit
,
"sun/lwawt/macosx/LWCToolkit"
);
static
JNF_STATIC_MEMBER_CACHE
(
jsm_installToolkitThread
NameInJava
,
jc_LWCToolkit
,
"installToolkitThreadName
InJava"
,
"()V"
);
JNFCallStaticVoidMethod
(
env
,
jsm_installToolkitThread
Name
InJava
);
static
JNF_STATIC_MEMBER_CACHE
(
jsm_installToolkitThread
InJava
,
jc_LWCToolkit
,
"installToolkitThread
InJava"
,
"()V"
);
JNFCallStaticVoidMethod
(
env
,
jsm_installToolkitThreadInJava
);
});
gNumberOfButtons
=
sun_lwawt_macosx_LWCToolkit_BUTTONS
;
...
...
src/macosx/native/sun/awt/awt.m
浏览文件 @
1dde2675
...
...
@@ -434,6 +434,15 @@ JNF_COCOA_ENTER(env);
forceEmbeddedMode
=
YES
;
}
JNIEnv
*
env
=
[
ThreadUtilities
getJNIEnvUncached
];
jclass
jc_SunToolkit
=
(
*
env
)
->
FindClass
(
env
,
"sun/awt/SunToolkit"
);
jmethodID
sjm_getRootThreadGroup
=
(
*
env
)
->
GetStaticMethodID
(
env
,
jc_SunToolkit
,
"getRootThreadGroup"
,
"()Ljava/lang/ThreadGroup;"
);
jobject
rootThreadGroup
=
(
*
env
)
->
CallStaticObjectMethod
(
env
,
jc_SunToolkit
,
sjm_getRootThreadGroup
);
appkitThreadGroup
=
(
*
env
)
->
NewGlobalRef
(
env
,
rootThreadGroup
);
// The current thread was attached in getJNIEnvUnchached.
// Detach it back. It will be reattached later if needed with a proper TG
[
ThreadUtilities
detachCurrentThread
];
BOOL
headless
=
isHeadless
(
env
);
// We need to let Foundation know that this is a multithreaded application, if it isn't already.
...
...
src/macosx/native/sun/osxapp/ThreadUtilities.h
浏览文件 @
1dde2675
...
...
@@ -122,11 +122,15 @@ do { \
#endif
/* AWT_THREAD_ASSERTS */
// --------------------------------------------------------------------------
// Set from JNI_Onload
extern
jobject
appkitThreadGroup
;
__attribute__
((
visibility
(
"default"
)))
@interface
ThreadUtilities
{
}
+
(
JNIEnv
*
)
getJNIEnv
;
+
(
JNIEnv
*
)
getJNIEnvUncached
;
+
(
void
)
detachCurrentThread
;
//Wrappers for the corresponding JNFRunLoop methods with a check for main thread
+
(
void
)
performOnMainThreadWaiting
:(
BOOL
)
wait
block
:(
void
(
^
)())
block
;
...
...
src/macosx/native/sun/osxapp/ThreadUtilities.m
浏览文件 @
1dde2675
...
...
@@ -33,23 +33,40 @@
// The following must be named "jvm", as there are extern references to it in AWT
JavaVM
*
jvm
=
NULL
;
static
JNIEnv
*
appKitEnv
=
NULL
;
jobject
appkitThreadGroup
=
NULL
;
inline
void
attachCurrentThread
(
void
**
env
)
{
JavaVMAttachArgs
args
;
args
.
version
=
JNI_VERSION_1_2
;
args
.
name
=
NULL
;
// Set from LWCToolkit
if
([
NSThread
isMainThread
])
{
args
.
group
=
appkitThreadGroup
;
}
else
{
args
.
group
=
NULL
;
}
(
*
jvm
)
->
AttachCurrentThreadAsDaemon
(
jvm
,
env
,
&
args
);
}
@implementation
ThreadUtilities
+
(
JNIEnv
*
)
getJNIEnv
{
AWT_ASSERT_APPKIT_THREAD
;
if
(
appKitEnv
==
NULL
)
{
(
*
jvm
)
->
AttachCurrentThreadAsDaemon
(
jvm
,
(
void
**
)
&
appKitEnv
,
NULL
);
attachCurrentThread
((
void
**
)
&
appKitEnv
);
}
return
appKitEnv
;
}
+
(
JNIEnv
*
)
getJNIEnvUncached
{
JNIEnv
*
env
=
NULL
;
(
*
jvm
)
->
AttachCurrentThreadAsDaemon
(
jvm
,
(
void
**
)
&
env
,
nil
);
attachCurrentThread
((
void
**
)
&
env
);
return
env
;
}
+
(
void
)
detachCurrentThread
{
(
*
jvm
)
->
DetachCurrentThread
(
jvm
);
}
+
(
void
)
performOnMainThreadWaiting
:(
BOOL
)
wait
block
:(
void
(
^
)())
block
{
if
([
NSThread
isMainThread
]
&&
wait
==
YES
)
{
block
();
...
...
src/share/classes/sun/awt/AWTAutoShutdown.java
浏览文件 @
1dde2675
...
...
@@ -27,6 +27,8 @@ package sun.awt;
import
java.awt.AWTEvent
;
import
java.security.AccessController
;
import
java.security.PrivilegedAction
;
import
java.util.Collections
;
import
java.util.HashSet
;
import
java.util.IdentityHashMap
;
...
...
@@ -333,7 +335,11 @@ public final class AWTAutoShutdown implements Runnable {
* the new blocker thread starts.
*/
private
void
activateBlockerThread
()
{
Thread
thread
=
new
Thread
(
this
,
"AWT-Shutdown"
);
Thread
thread
=
new
Thread
(
SunToolkit
.
getRootThreadGroup
(),
this
,
"AWT-Shutdown"
);
AccessController
.
doPrivileged
((
PrivilegedAction
<
Void
>)
()
->
{
thread
.
setContextClassLoader
(
null
);
return
null
;
});
thread
.
setDaemon
(
false
);
blockerThread
=
thread
;
thread
.
start
();
...
...
src/share/classes/sun/awt/SunToolkit.java
浏览文件 @
1dde2675
...
...
@@ -37,6 +37,7 @@ import java.awt.TrayIcon;
import
java.awt.SystemTray
;
import
java.awt.event.InputEvent
;
import
java.net.URL
;
import
java.security.PrivilegedAction
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.locks.Condition
;
...
...
@@ -1115,6 +1116,17 @@ public abstract class SunToolkit extends Toolkit
return
startupLocale
;
}
protected
static
ThreadGroup
getRootThreadGroup
()
{
return
AccessController
.
doPrivileged
((
PrivilegedAction
<
ThreadGroup
>)
()
->
{
ThreadGroup
currentTG
=
Thread
.
currentThread
().
getThreadGroup
();
ThreadGroup
parentTG
=
currentTG
.
getParent
();
while
(
parentTG
!=
null
)
{
currentTG
=
parentTG
;
parentTG
=
currentTG
.
getParent
();
}
return
currentTG
;
});
}
/**
* Returns the default keyboard locale of the underlying operating system
*/
...
...
src/solaris/classes/sun/awt/X11/XToolkit.java
浏览文件 @
1dde2675
...
...
@@ -256,13 +256,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
}
PrivilegedAction
<
Void
>
a
=
new
PrivilegedAction
<
Void
>()
{
public
Void
run
()
{
ThreadGroup
mainTG
=
Thread
.
currentThread
().
getThreadGroup
();
ThreadGroup
parentTG
=
mainTG
.
getParent
();
while
(
parentTG
!=
null
)
{
mainTG
=
parentTG
;
parentTG
=
mainTG
.
getParent
();
}
Thread
shutdownThread
=
new
Thread
(
mainTG
,
"XToolkt-Shutdown-Thread"
)
{
Thread
shutdownThread
=
new
Thread
(
getRootThreadGroup
(),
"XToolkt-Shutdown-Thread"
)
{
public
void
run
()
{
XSystemTrayPeer
peer
=
XSystemTrayPeer
.
getPeerInstance
();
if
(
peer
!=
null
)
{
...
...
@@ -327,13 +321,8 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
PrivilegedAction
<
Thread
>
action
=
new
PrivilegedAction
()
{
public
Thread
run
()
{
ThreadGroup
currentTG
=
Thread
.
currentThread
().
getThreadGroup
();
ThreadGroup
parentTG
=
currentTG
.
getParent
();
while
(
parentTG
!=
null
)
{
currentTG
=
parentTG
;
parentTG
=
currentTG
.
getParent
();
}
Thread
thread
=
new
Thread
(
currentTG
,
XToolkit
.
this
,
"AWT-XAWT"
);
Thread
thread
=
new
Thread
(
getRootThreadGroup
(),
XToolkit
.
this
,
"AWT-XAWT"
);
thread
.
setContextClassLoader
(
null
);
thread
.
setPriority
(
Thread
.
NORM_PRIORITY
+
1
);
thread
.
setDaemon
(
true
);
return
thread
;
...
...
src/windows/classes/sun/awt/windows/WToolkit.java
浏览文件 @
1dde2675
...
...
@@ -222,7 +222,7 @@ public class WToolkit extends SunToolkit implements Runnable {
private
static
native
void
postDispose
();
private
static
native
boolean
startToolkitThread
(
Runnable
thread
);
private
static
native
boolean
startToolkitThread
(
Runnable
thread
,
ThreadGroup
rootThreadGroup
);
public
WToolkit
()
{
// Startup toolkit threads
...
...
@@ -239,8 +239,10 @@ public class WToolkit extends SunToolkit implements Runnable {
*/
AWTAutoShutdown
.
notifyToolkitThreadBusy
();
if
(!
startToolkitThread
(
this
))
{
Thread
toolkitThread
=
new
Thread
(
this
,
"AWT-Windows"
);
// Find a root TG and attach Appkit thread to it
ThreadGroup
rootTG
=
getRootThreadGroup
();
if
(!
startToolkitThread
(
this
,
rootTG
))
{
Thread
toolkitThread
=
new
Thread
(
rootTG
,
this
,
"AWT-Windows"
);
toolkitThread
.
setDaemon
(
true
);
toolkitThread
.
start
();
}
...
...
@@ -270,14 +272,7 @@ public class WToolkit extends SunToolkit implements Runnable {
private
final
void
registerShutdownHook
()
{
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
Void
>()
{
public
Void
run
()
{
ThreadGroup
currentTG
=
Thread
.
currentThread
().
getThreadGroup
();
ThreadGroup
parentTG
=
currentTG
.
getParent
();
while
(
parentTG
!=
null
)
{
currentTG
=
parentTG
;
parentTG
=
currentTG
.
getParent
();
}
Thread
shutdown
=
new
Thread
(
currentTG
,
new
Runnable
()
{
Thread
shutdown
=
new
Thread
(
getRootThreadGroup
(),
new
Runnable
()
{
public
void
run
()
{
shutdown
();
}
...
...
@@ -290,7 +285,11 @@ public class WToolkit extends SunToolkit implements Runnable {
}
public
void
run
()
{
Thread
.
currentThread
().
setPriority
(
Thread
.
NORM_PRIORITY
+
1
);
AccessController
.
doPrivileged
((
PrivilegedAction
<
Void
>)
()
->
{
Thread
.
currentThread
().
setContextClassLoader
(
null
);
return
null
;
});
Thread
.
currentThread
().
setPriority
(
Thread
.
NORM_PRIORITY
+
1
);
boolean
startPump
=
init
();
if
(
startPump
)
{
...
...
src/windows/native/sun/windows/awt_Toolkit.cpp
浏览文件 @
1dde2675
...
...
@@ -364,6 +364,7 @@ struct ToolkitThreadProc_Data {
HANDLE
hCompleted
;
jobject
thread
;
jobject
threadGroup
;
};
void
ToolkitThreadProc
(
void
*
param
)
...
...
@@ -376,7 +377,7 @@ void ToolkitThreadProc(void *param)
JavaVMAttachArgs
attachArgs
;
attachArgs
.
version
=
JNI_VERSION_1_2
;
attachArgs
.
name
=
"AWT-Windows"
;
attachArgs
.
group
=
NULL
;
attachArgs
.
group
=
data
->
threadGroup
;
jint
res
=
jvm
->
AttachCurrentThreadAsDaemon
((
void
**
)
&
env
,
&
attachArgs
);
if
(
res
<
0
)
{
...
...
@@ -415,17 +416,18 @@ void ToolkitThreadProc(void *param)
/*
* Class: sun_awt_windows_WToolkit
* Method: startToolkitThread
* Signature: (Ljava/lang/Runnable;)Z
* Signature: (Ljava/lang/Runnable;
Ljava/lang/ThreadGroup
)Z
*/
JNIEXPORT
jboolean
JNICALL
Java_sun_awt_windows_WToolkit_startToolkitThread
(
JNIEnv
*
env
,
jclass
cls
,
jobject
thread
)
Java_sun_awt_windows_WToolkit_startToolkitThread
(
JNIEnv
*
env
,
jclass
cls
,
jobject
thread
,
jobject
threadGroup
)
{
AwtToolkit
&
tk
=
AwtToolkit
::
GetInstance
();
ToolkitThreadProc_Data
data
;
data
.
result
=
false
;
data
.
thread
=
env
->
NewGlobalRef
(
thread
);
if
(
data
.
thread
==
NULL
)
{
data
.
threadGroup
=
env
->
NewGlobalRef
(
threadGroup
);
if
(
data
.
thread
==
NULL
||
data
.
threadGroup
==
NULL
)
{
return
JNI_FALSE
;
}
data
.
hCompleted
=
::
CreateEvent
(
NULL
,
FALSE
,
FALSE
,
NULL
);
...
...
@@ -443,6 +445,7 @@ Java_sun_awt_windows_WToolkit_startToolkitThread(JNIEnv *env, jclass cls, jobjec
::
CloseHandle
(
data
.
hCompleted
);
env
->
DeleteGlobalRef
(
data
.
thread
);
env
->
DeleteGlobalRef
(
data
.
threadGroup
);
return
result
?
JNI_TRUE
:
JNI_FALSE
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录