Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
7fe61077
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看板
提交
7fe61077
编写于
1月 26, 2017
作者:
A
asaha
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
5fd9befb
76ddf87a
变更
23
隐藏空白更改
内联
并排
Showing
23 changed file
with
631 addition
and
241 deletion
+631
-241
.hgtags
.hgtags
+4
-0
src/macosx/classes/sun/lwawt/LWMouseInfoPeer.java
src/macosx/classes/sun/lwawt/LWMouseInfoPeer.java
+6
-2
src/macosx/classes/sun/lwawt/LWToolkit.java
src/macosx/classes/sun/lwawt/LWToolkit.java
+2
-0
src/macosx/classes/sun/lwawt/LWWindowPeer.java
src/macosx/classes/sun/lwawt/LWWindowPeer.java
+3
-5
src/macosx/classes/sun/lwawt/PlatformWindow.java
src/macosx/classes/sun/lwawt/PlatformWindow.java
+0
-2
src/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java
...cosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java
+0
-5
src/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java
src/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java
+0
-5
src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
+96
-26
src/macosx/classes/sun/lwawt/macosx/CRobot.java
src/macosx/classes/sun/lwawt/macosx/CRobot.java
+31
-2
src/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java
.../classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java
+0
-5
src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java
src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java
+5
-0
src/macosx/native/sun/awt/AWTWindow.m
src/macosx/native/sun/awt/AWTWindow.m
+51
-8
src/macosx/native/sun/awt/CCursorManager.m
src/macosx/native/sun/awt/CCursorManager.m
+5
-7
src/macosx/native/sun/awt/CRobot.m
src/macosx/native/sun/awt/CRobot.m
+1
-38
src/share/classes/java/awt/Window.java
src/share/classes/java/awt/Window.java
+4
-0
src/share/classes/sun/awt/AWTAccessor.java
src/share/classes/sun/awt/AWTAccessor.java
+6
-0
src/share/classes/sun/security/smartcardio/TerminalImpl.java
src/share/classes/sun/security/smartcardio/TerminalImpl.java
+3
-3
test/TEST.groups
test/TEST.groups
+2
-0
test/javax/xml/jaxp/transform/8167179/NamespacePrefixTest.java
...javax/xml/jaxp/transform/8167179/NamespacePrefixTest.java
+188
-0
test/sun/misc/URLClassPath/ClassnameCharTest.java
test/sun/misc/URLClassPath/ClassnameCharTest.java
+54
-10
test/sun/net/www/protocol/http/HttpInputStream.java
test/sun/net/www/protocol/http/HttpInputStream.java
+89
-71
test/sun/security/krb5/auto/UnboundSSL.java
test/sun/security/krb5/auto/UnboundSSL.java
+2
-2
test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/CloseSocket.java
...m/sun/net/ssl/internal/ssl/SSLSocketImpl/CloseSocket.java
+79
-50
未找到文件。
.hgtags
浏览文件 @
7fe61077
...
...
@@ -679,5 +679,9 @@ ec72a941be0a50ab77f5375cf710bc06e4f118d3 jdk8u121-b11
9561afc12df843ef21ecd9d7b3633371e7a2bfc4 jdk8u121-b12
2974746e56192cdd14fc2dd43179bcf28e4faf4a jdk8u121-b13
032874d46bf95478cb86690b3c91d335c0764b0b jdk8u131-b00
bea5b22daf5ddd941f3bcbf7a4e5fc5244ceb788 jdk8u131-b01
a01d217a232906e82f80e5bc3db4d60c4c74716e jdk8u131-b02
3d2dfed2b420a59c68e5deedd257eb630f88b3da jdk8u131-b03
0f7d02f565658a89b073ee77c296f33148c50da3 jdk8u131-b04
a160009bbe1417d85f1c0eec890fdb17391b3637 jdk8u141-b00
072e084bceeedeb75467e40ca77786ac9ef5227a jdk8u151-b00
src/macosx/classes/sun/lwawt/LWMouseInfoPeer.java
浏览文件 @
7fe61077
...
...
@@ -51,8 +51,12 @@ public class LWMouseInfoPeer implements MouseInfoPeer {
return
false
;
}
final
Object
windowPeer
=
AWTAccessor
.
getComponentAccessor
().
getPeer
(
w
);
return
LWWindowPeer
.
getWindowUnderCursor
()
==
windowPeer
;
LWWindowPeer
windowPeer
=
(
LWWindowPeer
)
AWTAccessor
.
getComponentAccessor
().
getPeer
(
w
);
if
(
windowPeer
==
null
)
{
return
false
;
}
return
LWToolkit
.
getLWToolkit
().
getPlatformWindowUnderMouse
()
==
windowPeer
.
getPlatformWindow
();
}
}
...
...
src/macosx/classes/sun/lwawt/LWToolkit.java
浏览文件 @
7fe61077
...
...
@@ -385,6 +385,8 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
return
new
LWMouseInfoPeer
();
}
protected
abstract
PlatformWindow
getPlatformWindowUnderMouse
();
@Override
public
final
PrintJob
getPrintJob
(
Frame
frame
,
String
doctitle
,
Properties
props
)
{
...
...
src/macosx/classes/sun/lwawt/LWWindowPeer.java
浏览文件 @
7fe61077
...
...
@@ -749,11 +749,10 @@ public class LWWindowPeer
lastMouseEventPeer
=
targetPeer
;
}
}
else
{
PlatformWindow
topmostPlatforWindow
=
platformWindow
.
getTopmostPlatformWindowUnderMouse
();
PlatformWindow
topmostPlatformWindow
=
LWToolkit
.
getLWToolkit
().
getPlatformWindowUnderMouse
();
LWWindowPeer
topmostWindowPeer
=
topmostPlatfor
Window
!=
null
?
topmostPlatfor
Window
.
getPeer
()
:
null
;
topmostPlatfor
mWindow
!=
null
?
topmostPlatform
Window
.
getPeer
()
:
null
;
// topmostWindowPeer == null condition is added for the backward
// compatibility with applets. It can be removed when the
...
...
@@ -764,8 +763,7 @@ public class LWWindowPeer
screenX
,
screenY
,
modifiers
,
clickCount
,
popupTrigger
,
targetPeer
);
}
else
{
LWComponentPeer
<?,
?>
topmostTargetPeer
=
topmostWindowPeer
!=
null
?
topmostWindowPeer
.
findPeerAt
(
r
.
x
+
x
,
r
.
y
+
y
)
:
null
;
LWComponentPeer
<?,
?>
topmostTargetPeer
=
topmostWindowPeer
.
findPeerAt
(
r
.
x
+
x
,
r
.
y
+
y
);
topmostWindowPeer
.
generateMouseEnterExitEventsForComponents
(
when
,
button
,
x
,
y
,
screenX
,
screenY
,
modifiers
,
clickCount
,
popupTrigger
,
topmostTargetPeer
);
...
...
src/macosx/classes/sun/lwawt/PlatformWindow.java
浏览文件 @
7fe61077
...
...
@@ -107,8 +107,6 @@ public interface PlatformWindow {
public
void
setAlwaysOnTop
(
boolean
value
);
public
PlatformWindow
getTopmostPlatformWindowUnderMouse
();
public
void
updateFocusableWindowState
();
public
boolean
rejectFocusRequest
(
CausedFocusEvent
.
Cause
cause
);
...
...
src/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java
浏览文件 @
7fe61077
...
...
@@ -129,11 +129,6 @@ public class CPlatformEmbeddedFrame implements PlatformWindow {
@Override
public
void
setAlwaysOnTop
(
boolean
value
)
{}
// This method should be properly implemented for applets.
// It returns null just as a stub.
@Override
public
PlatformWindow
getTopmostPlatformWindowUnderMouse
()
{
return
null
;
}
@Override
public
void
updateFocusableWindowState
()
{}
...
...
src/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java
浏览文件 @
7fe61077
...
...
@@ -156,11 +156,6 @@ public class CPlatformLWWindow extends CPlatformWindow {
public
void
setAlwaysOnTop
(
boolean
isAlwaysOnTop
)
{
}
@Override
public
PlatformWindow
getTopmostPlatformWindowUnderMouse
(){
return
null
;
}
@Override
public
void
setOpacity
(
float
opacity
)
{
}
...
...
src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
浏览文件 @
7fe61077
...
...
@@ -31,6 +31,8 @@ import java.awt.event.*;
import
java.awt.peer.WindowPeer
;
import
java.beans.*
;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
java.util.concurrent.atomic.AtomicLong
;
import
java.util.concurrent.atomic.AtomicReference
;
...
...
@@ -40,6 +42,8 @@ import java.util.Objects;
import
javax.swing.*
;
import
sun.awt.*
;
import
sun.awt.AWTAccessor.ComponentAccessor
;
import
sun.awt.AWTAccessor.WindowAccessor
;
import
sun.java2d.SurfaceData
;
import
sun.java2d.opengl.CGLSurfaceData
;
import
sun.lwawt.*
;
...
...
@@ -65,9 +69,9 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
private
static
native
void
nativeSetEnabled
(
long
nsWindowPtr
,
boolean
isEnabled
);
private
static
native
void
nativeSynthesizeMouseEnteredExitedEvents
();
private
static
native
void
nativeDispose
(
long
nsWindowPtr
);
private
static
native
CPlatformWindow
nativeGetTopmostPlatformWindowUnderMouse
();
private
static
native
void
nativeEnterFullScreenMode
(
long
nsWindowPtr
);
private
static
native
void
nativeExitFullScreenMode
(
long
nsWindowPtr
);
static
native
CPlatformWindow
nativeGetTopmostPlatformWindowUnderMouse
();
// Loger to report issues happened during execution but that do not affect functionality
private
static
final
PlatformLogger
logger
=
PlatformLogger
.
getLogger
(
"sun.lwawt.macosx.CPlatformWindow"
);
...
...
@@ -208,6 +212,8 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
private
volatile
boolean
isFullScreenMode
;
private
boolean
isFullScreenAnimationOn
;
private
volatile
boolean
isIconifyAnimationActive
;
private
Window
target
;
private
LWWindowPeer
peer
;
protected
CPlatformView
contentView
;
...
...
@@ -769,10 +775,6 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
setStyleBits
(
ALWAYS_ON_TOP
,
isAlwaysOnTop
);
}
public
PlatformWindow
getTopmostPlatformWindowUnderMouse
(){
return
CPlatformWindow
.
nativeGetTopmostPlatformWindowUnderMouse
();
}
@Override
public
void
setOpacity
(
float
opacity
)
{
execute
(
ptr
->
CWrapper
.
NSWindow
.
setAlphaValue
(
ptr
,
opacity
));
...
...
@@ -992,6 +994,9 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
if
(
peer
!=
null
)
{
peer
.
notifyIconify
(
iconify
);
}
if
(
iconify
)
{
isIconifyAnimationActive
=
false
;
}
}
private
void
deliverZoom
(
final
boolean
isZoomed
)
{
...
...
@@ -1061,31 +1066,92 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
return
true
;
}
private
void
orderAboveSiblings
()
{
if
(
owner
==
null
)
{
return
;
private
boolean
isIconified
()
{
boolean
isIconified
=
false
;
if
(
target
instanceof
Frame
)
{
int
state
=
((
Frame
)
target
).
getExtendedState
();
if
((
state
&
Frame
.
ICONIFIED
)
!=
0
)
{
isIconified
=
true
;
}
}
return
isIconifyAnimationActive
||
isIconified
;
}
private
boolean
isOneOfOwnersOrSelf
(
CPlatformWindow
window
)
{
while
(
window
!=
null
)
{
if
(
this
==
window
)
{
return
true
;
}
window
=
window
.
owner
;
}
return
false
;
}
// NOTE: the logic will fail if we have a hierarchy like:
// visible root owner
// invisible owner
// visible dialog
// However, this is an unlikely scenario for real life apps
if
(
owner
.
isVisible
())
{
// Recursively pop up the windows from the very bottom so that only
// the very top-most one becomes the main window
owner
.
orderAboveSiblings
();
// Order the window to front of the stack of child windows
owner
.
execute
(
nsWindowOwnerPtr
->{
execute
(
nsWindowSelfPtr
->{
CWrapper
.
NSWindow
.
orderFront
(
nsWindowOwnerPtr
);
CWrapper
.
NSWindow
.
orderWindow
(
nsWindowSelfPtr
,
CWrapper
.
NSWindow
.
NSWindowAbove
,
nsWindowOwnerPtr
);
});
});
private
CPlatformWindow
getRootOwner
()
{
CPlatformWindow
rootOwner
=
this
;
while
(
rootOwner
.
owner
!=
null
)
{
rootOwner
=
rootOwner
.
owner
;
}
return
rootOwner
;
}
private
void
orderAboveSiblings
()
{
// Recursively pop up the windows from the very bottom, (i.e. root owner) so that
// the windows are ordered above their nearest owner; ancestors of the window,
// which is going to become 'main window', are placed above their siblings.
CPlatformWindow
rootOwner
=
getRootOwner
();
if
(
rootOwner
.
isVisible
()
&&
!
rootOwner
.
isIconified
())
{
rootOwner
.
execute
(
CWrapper
.
NSWindow
::
orderFront
);
}
// Do not order child windows of iconified owner.
if
(!
rootOwner
.
isIconified
())
{
final
WindowAccessor
windowAccessor
=
AWTAccessor
.
getWindowAccessor
();
orderAboveSiblingsImpl
(
windowAccessor
.
getOwnedWindows
(
rootOwner
.
target
));
}
}
applyWindowLevel
(
target
);
private
void
orderAboveSiblingsImpl
(
Window
[]
windows
)
{
ArrayList
<
Window
>
childWindows
=
new
ArrayList
<
Window
>();
final
ComponentAccessor
componentAccessor
=
AWTAccessor
.
getComponentAccessor
();
final
WindowAccessor
windowAccessor
=
AWTAccessor
.
getWindowAccessor
();
// Go through the list of windows and perform ordering.
for
(
Window
w
:
windows
)
{
boolean
iconified
=
false
;
final
Object
p
=
componentAccessor
.
getPeer
(
w
);
if
(
p
instanceof
LWWindowPeer
)
{
CPlatformWindow
pw
=
(
CPlatformWindow
)((
LWWindowPeer
)
p
).
getPlatformWindow
();
iconified
=
isIconified
();
if
(
pw
!=
null
&&
pw
.
isVisible
()
&&
!
iconified
)
{
// If the window is one of ancestors of 'main window' or is going to become main by itself,
// the window should be ordered above its siblings; otherwise the window is just ordered
// above its nearest parent.
if
(
pw
.
isOneOfOwnersOrSelf
(
this
))
{
pw
.
execute
(
CWrapper
.
NSWindow
::
orderFront
);
}
else
{
pw
.
owner
.
execute
(
ownerPtr
->
{
pw
.
execute
(
ptr
->
{
CWrapper
.
NSWindow
.
orderWindow
(
ptr
,
CWrapper
.
NSWindow
.
NSWindowAbove
,
ownerPtr
);
});
});
}
pw
.
applyWindowLevel
(
w
);
}
}
// Retrieve the child windows for each window from the list except iconified ones
// and store them for future use.
// Note: we collect data about child windows even for invisible owners, since they may have
// visible children.
if
(!
iconified
)
{
childWindows
.
addAll
(
Arrays
.
asList
(
windowAccessor
.
getOwnedWindows
(
w
)));
}
}
// If some windows, which have just been ordered, have any child windows, let's start new iteration
// and order these child windows.
if
(!
childWindows
.
isEmpty
())
{
orderAboveSiblingsImpl
(
childWindows
.
toArray
(
new
Window
[
0
]));
}
}
protected
void
applyWindowLevel
(
Window
target
)
{
...
...
@@ -1100,6 +1166,10 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
// NATIVE CALLBACKS
// ----------------------------------------------------------------------
private
void
windowWillMiniaturize
()
{
isIconifyAnimationActive
=
true
;
}
private
void
windowDidBecomeMain
()
{
assert
CThreading
.
assertAppKit
();
...
...
src/macosx/classes/sun/lwawt/macosx/CRobot.java
浏览文件 @
7fe61077
...
...
@@ -78,7 +78,7 @@ class CRobot implements RobotPeer {
@Override
public
void
mousePress
(
int
buttons
)
{
mouseButtonsState
|=
buttons
;
checkMousePos
();
mouseEvent
(
fDevice
.
getCGDisplayID
(),
mouseLastX
,
mouseLastY
,
buttons
,
true
,
false
);
}
...
...
@@ -92,11 +92,40 @@ class CRobot implements RobotPeer {
@Override
public
void
mouseRelease
(
int
buttons
)
{
mouseButtonsState
&=
~
buttons
;
checkMousePos
();
mouseEvent
(
fDevice
.
getCGDisplayID
(),
mouseLastX
,
mouseLastY
,
buttons
,
false
,
false
);
}
/**
* Set unknown mouse location, if needed.
*/
private
void
checkMousePos
()
{
if
(
mouseLastX
==
MOUSE_LOCATION_UNKNOWN
||
mouseLastY
==
MOUSE_LOCATION_UNKNOWN
)
{
Rectangle
deviceBounds
=
fDevice
.
getDefaultConfiguration
().
getBounds
();
Point
mousePos
=
CCursorManager
.
getInstance
().
getCursorPosition
();
if
(
mousePos
.
x
<
deviceBounds
.
x
)
{
mousePos
.
x
=
deviceBounds
.
x
;
}
else
if
(
mousePos
.
x
>
deviceBounds
.
x
+
deviceBounds
.
width
)
{
mousePos
.
x
=
deviceBounds
.
x
+
deviceBounds
.
width
;
}
if
(
mousePos
.
y
<
deviceBounds
.
y
)
{
mousePos
.
y
=
deviceBounds
.
y
;
}
else
if
(
mousePos
.
y
>
deviceBounds
.
y
+
deviceBounds
.
height
)
{
mousePos
.
y
=
deviceBounds
.
y
+
deviceBounds
.
height
;
}
mouseLastX
=
mousePos
.
x
;
mouseLastY
=
mousePos
.
y
;
}
}
@Override
public
native
void
mouseWheel
(
int
wheelAmt
);
...
...
src/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java
浏览文件 @
7fe61077
...
...
@@ -143,11 +143,6 @@ public class CViewPlatformEmbeddedFrame implements PlatformWindow {
public
void
setAlwaysOnTop
(
boolean
value
)
{
}
@Override
public
PlatformWindow
getTopmostPlatformWindowUnderMouse
()
{
return
null
;
}
@Override
public
void
updateFocusableWindowState
()
{
}
...
...
src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java
浏览文件 @
7fe61077
...
...
@@ -917,4 +917,9 @@ public final class LWCToolkit extends LWToolkit {
!
path
.
endsWith
(
"/"
)
&&
!
path
.
endsWith
(
"."
);
}
@Override
protected
PlatformWindow
getPlatformWindowUnderMouse
()
{
return
CPlatformWindow
.
nativeGetTopmostPlatformWindowUnderMouse
();
}
}
src/macosx/native/sun/awt/AWTWindow.m
浏览文件 @
7fe61077
...
...
@@ -326,10 +326,44 @@ AWT_ASSERT_APPKIT_THREAD;
return
[
window
isKindOfClass
:
[
AWTWindow_Panel
class
]]
||
[
window
isKindOfClass
:
[
AWTWindow_Normal
class
]];
}
// Retrieves the list of possible window layers (levels)
+
(
NSArray
*
)
getWindowLayers
{
static
NSArray
*
windowLayers
;
static
dispatch_once_t
token
;
// Initialize the list of possible window layers
dispatch_once
(
&
token
,
^
{
// The layers are ordered from front to back, (i.e. the toppest one is the first)
windowLayers
=
[
NSArray
arrayWithObjects
:
[
NSNumber
numberWithInt
:
CGWindowLevelForKey
(
kCGPopUpMenuWindowLevelKey
)],
[
NSNumber
numberWithInt
:
CGWindowLevelForKey
(
kCGFloatingWindowLevelKey
)],
[
NSNumber
numberWithInt
:
CGWindowLevelForKey
(
kCGNormalWindowLevelKey
)],
nil
];
[
windowLayers
retain
];
});
return
windowLayers
;
}
// returns id for the topmost window under mouse
+
(
NSInteger
)
getTopmostWindowUnderMouseID
{
NSInteger
result
=
-
1
;
NSArray
*
windowLayers
=
[
AWTWindow
getWindowLayers
];
// Looking for the window under mouse starting from the toppest layer
for
(
NSNumber
*
layer
in
windowLayers
)
{
result
=
[
AWTWindow
getTopmostWindowUnderMouseIDImpl
:[
layer
integerValue
]];
if
(
result
!=
-
1
)
{
break
;
}
}
return
result
;
}
+
(
NSInteger
)
getTopmostWindowUnderMouseIDImpl
:(
NSInteger
)
windowLayer
{
NSInteger
result
=
-
1
;
NSRect
screenRect
=
[[
NSScreen
mainScreen
]
frame
];
NSPoint
nsMouseLocation
=
[
NSEvent
mouseLocation
];
CGPoint
cgMouseLocation
=
CGPointMake
(
nsMouseLocation
.
x
,
screenRect
.
size
.
height
-
nsMouseLocation
.
y
);
...
...
@@ -338,7 +372,7 @@ AWT_ASSERT_APPKIT_THREAD;
for
(
NSDictionary
*
window
in
windows
)
{
NSInteger
layer
=
[[
window
objectForKey
:(
id
)
kCGWindowLayer
]
integerValue
];
if
(
layer
==
0
)
{
if
(
layer
==
windowLayer
)
{
CGRect
rect
;
CGRectMakeWithDictionaryRepresentation
((
CFDictionaryRef
)[
window
objectForKey
:(
id
)
kCGWindowBounds
],
&
rect
);
if
(
CGRectContainsPoint
(
rect
,
cgMouseLocation
))
{
...
...
@@ -614,6 +648,14 @@ AWT_ASSERT_APPKIT_THREAD;
AWT_ASSERT_APPKIT_THREAD
;
self
.
isMinimizing
=
YES
;
JNIEnv
*
env
=
[
ThreadUtilities
getJNIEnv
];
jobject
platformWindow
=
[
self
.
javaPlatformWindow
jObjectWithEnv
:
env
];
if
(
platformWindow
!=
NULL
)
{
static
JNF_MEMBER_CACHE
(
jm_windowWillMiniaturize
,
jc_CPlatformWindow
,
"windowWillMiniaturize"
,
"()V"
);
JNFCallVoidMethod
(
env
,
platformWindow
,
jm_windowWillMiniaturize
);
(
*
env
)
->
DeleteLocalRef
(
env
,
platformWindow
);
}
// Excplicitly make myself a key window to avoid possible
// negative visual effects during iconify operation
[
self
.
nsWindow
makeKeyAndOrderFront
:
self
.
nsWindow
];
...
...
@@ -1255,15 +1297,16 @@ JNIEXPORT jobject
JNICALL
Java_sun_lwawt_macosx_CPlatformWindow_nativeGetTopmostPlatformWindowUnderMouse
(
JNIEnv
*
env
,
jclass
clazz
)
{
jobject
topmostWindowUnderMouse
=
nil
;
__block
jobject
topmostWindowUnderMouse
=
nil
;
JNF_COCOA_ENTER
(
env
);
AWT_ASSERT_APPKIT_THREAD
;
AWTWindow
*
awtWindow
=
[
AWTWindow
getTopmostWindowUnderMouse
];
if
(
awtWindow
!=
nil
)
{
topmostWindowUnderMouse
=
[
awtWindow
.
javaPlatformWindow
jObject
];
}
[
ThreadUtilities
performOnMainThreadWaiting
:
YES
block
:
^
{
AWTWindow
*
awtWindow
=
[
AWTWindow
getTopmostWindowUnderMouse
];
if
(
awtWindow
!=
nil
)
{
topmostWindowUnderMouse
=
[
awtWindow
.
javaPlatformWindow
jObject
];
}
}];
JNF_COCOA_EXIT
(
env
);
...
...
src/macosx/native/sun/awt/CCursorManager.m
浏览文件 @
7fe61077
...
...
@@ -118,13 +118,11 @@ Java_sun_lwawt_macosx_CCursorManager_nativeGetCursorPosition
JNF_COCOA_ENTER
(
env
);
__block
NSPoint
pt
=
NSZeroPoint
;
[
ThreadUtilities
performOnMainThreadWaiting
:
YES
block
:
^
(){
pt
=
ConvertNSScreenPoint
(
env
,
[
NSEvent
mouseLocation
]);
}];
jpt
=
NSToJavaPoint
(
env
,
pt
);
CGEventRef
event
=
CGEventCreate
(
NULL
);
CGPoint
globalPos
=
CGEventGetLocation
(
event
);
CFRelease
(
event
);
jpt
=
NSToJavaPoint
(
env
,
globalPos
);
JNF_COCOA_EXIT
(
env
);
...
...
src/macosx/native/sun/awt/CRobot.m
浏览文件 @
7fe61077
...
...
@@ -146,47 +146,10 @@ Java_sun_lwawt_macosx_CRobot_mouseEvent
// This is the native method called when Robot mouse events occur.
// The CRobot tracks the mouse position, and which button was
// pressed. If the mouse position is unknown it is obtained from
// CGEvents. The peer also tracks the mouse button desired state,
// pressed. The peer also tracks the mouse button desired state,
// the appropriate key modifier state, and whether the mouse action
// is simply a mouse move with no mouse button state changes.
CGError
err
=
kCGErrorSuccess
;
CGRect
globalDeviceBounds
=
CGDisplayBounds
(
displayID
);
// Set unknown mouse location, if needed.
if
((
mouseLastX
==
sun_lwawt_macosx_CRobot_MOUSE_LOCATION_UNKNOWN
)
||
(
mouseLastY
==
sun_lwawt_macosx_CRobot_MOUSE_LOCATION_UNKNOWN
))
{
CGEventRef
event
=
CGEventCreate
(
NULL
);
if
(
event
==
NULL
)
{
return
;
}
CGPoint
globalPos
=
CGEventGetLocation
(
event
);
CFRelease
(
event
);
// Normalize the coords within this display device, as
// per Robot rules.
if
(
globalPos
.
x
<
CGRectGetMinX
(
globalDeviceBounds
))
{
globalPos
.
x
=
CGRectGetMinX
(
globalDeviceBounds
);
}
else
if
(
globalPos
.
x
>
CGRectGetMaxX
(
globalDeviceBounds
))
{
globalPos
.
x
=
CGRectGetMaxX
(
globalDeviceBounds
);
}
if
(
globalPos
.
y
<
CGRectGetMinY
(
globalDeviceBounds
))
{
globalPos
.
y
=
CGRectGetMinY
(
globalDeviceBounds
);
}
else
if
(
globalPos
.
y
>
CGRectGetMaxY
(
globalDeviceBounds
))
{
globalPos
.
y
=
CGRectGetMaxY
(
globalDeviceBounds
);
}
mouseLastX
=
(
jint
)
globalPos
.
x
;
mouseLastY
=
(
jint
)
globalPos
.
y
;
}
// volatile, otherwise it warns that it might be clobbered by 'longjmp'
volatile
CGPoint
point
;
...
...
src/share/classes/java/awt/Window.java
浏览文件 @
7fe61077
...
...
@@ -4100,6 +4100,10 @@ public class Window extends Container implements Accessible {
public
void
setTrayIconWindow
(
Window
w
,
boolean
isTrayIconWindow
)
{
w
.
isTrayIconWindow
=
isTrayIconWindow
;
}
public
Window
[]
getOwnedWindows
(
Window
w
)
{
return
w
.
getOwnedWindows_NoClientCode
();
}
});
// WindowAccessor
}
// static
...
...
src/share/classes/sun/awt/AWTAccessor.java
浏览文件 @
7fe61077
...
...
@@ -334,6 +334,12 @@ public final class AWTAccessor {
* Marks the specified window as an utility window for TrayIcon.
*/
void
setTrayIconWindow
(
Window
w
,
boolean
isTrayIconWindow
);
/**
* Return an array containing all the windows this
* window currently owns.
*/
Window
[]
getOwnedWindows
(
Window
w
);
}
/**
...
...
src/share/classes/sun/security/smartcardio/TerminalImpl.java
浏览文件 @
7fe61077
/*
* Copyright (c) 2005, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 201
6
, 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
...
...
@@ -75,10 +75,10 @@ final class TerminalImpl extends CardTerminal {
}
}
try
{
card
=
new
CardImpl
(
this
,
protocol
);
card
=
new
CardImpl
(
this
,
protocol
);
return
card
;
}
catch
(
PCSCException
e
)
{
if
(
e
.
code
==
SCARD_W_REMOVED_CARD
)
{
if
(
e
.
code
==
SCARD_W_REMOVED_CARD
||
e
.
code
==
SCARD_E_NO_SMARTCARD
)
{
throw
new
CardNotPresentException
(
"No card present"
,
e
);
}
else
{
throw
new
CardException
(
"connect() failed"
,
e
);
...
...
test/TEST.groups
浏览文件 @
7fe61077
...
...
@@ -394,6 +394,7 @@ needs_jre = \
javax/management/mxbean/LeakTest.java \
javax/management/mxbean/MXBeanTest.java \
javax/management/mxbean/PropertyNamesTest.java \
javax/xml/bind/marshal/8134111/UnmarshalTest.java \
javax/xml/ws/8043129 \
jdk/lambda/vm/InterfaceAccessFlagsTest.java \
sun/misc/URLClassPath/ClassnameCharTest.java \
...
...
@@ -566,6 +567,7 @@ needs_compact2 = \
java/net/HttpCookie/IllegalCookieNameTest.java \
java/net/HttpURLConnection/UnmodifiableMaps.java \
java/net/ResponseCache/Test.java \
java/net/SetFactoryPermission/SetFactoryPermission.java \
java/net/URLClassLoader/ClassLoad.java \
java/net/URLClassLoader/closetest/CloseTest.java \
java/net/URLPermission/URLTest.java \
...
...
test/javax/xml/jaxp/transform/8167179/NamespacePrefixTest.java
0 → 100644
浏览文件 @
7fe61077
/*
* Copyright (c) 2016, 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.io.StringReader
;
import
java.io.StringWriter
;
import
java.util.concurrent.CyclicBarrier
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
javax.xml.transform.Source
;
import
javax.xml.transform.Templates
;
import
javax.xml.transform.Transformer
;
import
javax.xml.transform.TransformerFactory
;
import
javax.xml.transform.stream.StreamResult
;
import
javax.xml.transform.stream.StreamSource
;
import
org.testng.annotations.Test
;
import
static
org
.
testng
.
Assert
.
assertTrue
;
/*
* @test
* @bug 8167179
* @run testng/othervm NamespacePrefixTest
* @summary This class tests the generation of namespace prefixes
*/
public
class
NamespacePrefixTest
{
@Test
public
void
testReuseTemplates
()
throws
Exception
{
final
TransformerFactory
tf
=
TransformerFactory
.
newInstance
();
final
Source
xslsrc
=
new
StreamSource
(
new
StringReader
(
XSL
));
final
Templates
tmpl
=
tf
.
newTemplates
(
xslsrc
);
for
(
int
i
=
0
;
i
<
TRANSF_COUNT
;
i
++)
{
checkResult
(
doTransformation
(
tmpl
.
newTransformer
()));
}
}
@Test
public
void
testReuseTransformer
()
throws
Exception
{
final
TransformerFactory
tf
=
TransformerFactory
.
newInstance
();
final
Source
xslsrc
=
new
StreamSource
(
new
StringReader
(
XSL
));
final
Transformer
t
=
tf
.
newTransformer
(
xslsrc
);
for
(
int
i
=
0
;
i
<
TRANSF_COUNT
;
i
++)
{
checkResult
(
doTransformation
(
t
));
}
}
@Test
public
void
testConcurrentTransformations
()
throws
Exception
{
final
TransformerFactory
tf
=
TransformerFactory
.
newInstance
();
final
Source
xslsrc
=
new
StreamSource
(
new
StringReader
(
XSL
));
final
Templates
tmpl
=
tf
.
newTemplates
(
xslsrc
);
concurrentTestPassed
.
set
(
true
);
// Execute multiple TestWorker tasks
for
(
int
id
=
0
;
id
<
THREADS_COUNT
;
id
++)
{
EXECUTOR
.
execute
(
new
TransformerThread
(
tmpl
.
newTransformer
(),
id
));
}
// Initiate shutdown of previously submitted task
EXECUTOR
.
shutdown
();
// Wait for termination of submitted tasks
if
(!
EXECUTOR
.
awaitTermination
(
THREADS_COUNT
,
TimeUnit
.
SECONDS
))
{
// If not all tasks terminates during the time out force them to shutdown
EXECUTOR
.
shutdownNow
();
}
// Check if all transformation threads generated the correct namespace prefix
assertTrue
(
concurrentTestPassed
.
get
());
}
// Do one transformation with the provided transformer
private
static
String
doTransformation
(
Transformer
t
)
throws
Exception
{
StringWriter
resWriter
=
new
StringWriter
();
Source
xmlSrc
=
new
StreamSource
(
new
StringReader
(
XML
));
t
.
transform
(
xmlSrc
,
new
StreamResult
(
resWriter
));
return
resWriter
.
toString
();
}
// Check if the transformation result string contains the
// element with the exact namespace prefix generated.
private
static
void
checkResult
(
String
result
)
{
// Check prefix of 'Element2' element, it should always be the same
assertTrue
(
result
.
contains
(
EXPECTED_CONTENT
));
}
// Check if the transformation result string contains the element with
// the exact namespace prefix generated by current thread.
// If the expected prefix is not found and there was no failures observed by
// other test threads then mark concurrent test as failed.
private
static
void
checkThreadResult
(
String
result
,
int
id
)
{
boolean
res
=
result
.
contains
(
EXPECTED_CONTENT
);
System
.
out
.
printf
(
"%d: transformation result: %s%n"
,
id
,
res
?
"Pass"
:
"Fail"
);
if
(!
res
)
{
System
.
out
.
printf
(
"%d result:%s%n"
,
id
,
result
);
}
concurrentTestPassed
.
compareAndSet
(
true
,
res
);
}
// TransformerThread task that does the transformation similar
// to testReuseTransformer test method
private
class
TransformerThread
implements
Runnable
{
private
final
Transformer
transformer
;
private
final
int
id
;
TransformerThread
(
Transformer
transformer
,
int
id
)
{
this
.
transformer
=
transformer
;
this
.
id
=
id
;
}
@Override
public
void
run
()
{
try
{
System
.
out
.
printf
(
"%d: waiting for barrier%n"
,
id
);
//Synchronize startup of all tasks
BARRIER
.
await
();
System
.
out
.
printf
(
"%d: starting transformation%n"
,
id
);
checkThreadResult
(
doTransformation
(
transformer
),
id
);
}
catch
(
Exception
ex
)
{
throw
new
RuntimeException
(
"TransformerThread "
+
id
+
" failed"
,
ex
);
}
}
}
// Number of subsequent transformations
private
static
final
int
TRANSF_COUNT
=
10
;
// Number of transformer threads running concurently
private
static
final
int
THREADS_COUNT
=
10
;
// Variable for storing the concurrent transformation test result. It is
// updated by transformer threads
private
static
final
AtomicBoolean
concurrentTestPassed
=
new
AtomicBoolean
(
true
);
// Cyclic barrier for threads startup synchronization
private
static
final
CyclicBarrier
BARRIER
=
new
CyclicBarrier
(
THREADS_COUNT
);
// Thread pool
private
static
final
ExecutorService
EXECUTOR
=
Executors
.
newCachedThreadPool
();
// XSL that transforms XML and produces unique namespace prefixes for each element
private
final
static
String
XSL
=
"<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n"
+
" <xsl:template match=\"node()|@*\" priority=\"1\">\n"
+
" <xsl:copy>\n"
+
" <xsl:apply-templates select=\"node()|@*\"/>\n"
+
" </xsl:copy>\n"
+
" </xsl:template>\n"
+
" <xsl:template match=\"*\" priority=\"2\">\n"
+
" <xsl:element name=\"{name()}\" namespace=\"{namespace-uri()}\">\n"
+
" <xsl:apply-templates select=\"node()|@*\"/>\n"
+
" </xsl:element>\n"
+
" </xsl:template>\n"
+
"</xsl:stylesheet>"
;
// Simple XML content with root and two child elements
private
final
static
String
XML
=
"<TestRoot xmlns=\"test.xmlns\">\n"
+
" <Element1 xmlns=\"test.xmlns\">\n"
+
" </Element1>\n"
+
" <Element2 xmlns=\"test.xmlns\">\n"
+
" </Element2>\n"
+
"</TestRoot>"
;
// With thread local namespace prefix index each transformation result should
// be the same and contain the same prefix for Element2
private
final
static
String
EXPECTED_CONTENT
=
"</ns2:Element2>"
;
}
test/sun/misc/URLClassPath/ClassnameCharTest.java
浏览文件 @
7fe61077
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012,
2016,
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
...
...
@@ -102,16 +102,60 @@ public class ClassnameCharTest {
//--------------------- Infrastructure ---------------------------
static
volatile
int
passed
=
0
,
failed
=
0
;
static
boolean
pass
()
{
passed
++;
return
true
;}
static
boolean
fail
()
{
failed
++;
server
.
stop
(
0
);
Thread
.
dumpStack
();
return
false
;}
static
boolean
fail
(
String
msg
)
{
System
.
out
.
println
(
msg
);
return
fail
();}
static
void
unexpected
(
Throwable
t
)
{
failed
++;
server
.
stop
(
0
);
t
.
printStackTrace
();}
static
boolean
check
(
boolean
cond
)
{
if
(
cond
)
pass
();
else
fail
();
return
cond
;}
static
boolean
pass
()
{
passed
++;
return
true
;
}
static
boolean
fail
()
{
failed
++;
if
(
server
!=
null
)
{
server
.
stop
(
0
);
}
Thread
.
dumpStack
();
return
false
;
}
static
boolean
fail
(
String
msg
)
{
System
.
out
.
println
(
msg
);
return
fail
();
}
static
void
unexpected
(
Throwable
t
)
{
failed
++;
if
(
server
!=
null
)
{
server
.
stop
(
0
);
}
t
.
printStackTrace
();
}
static
boolean
check
(
boolean
cond
)
{
if
(
cond
)
{
pass
();
}
else
{
fail
();
}
return
cond
;
}
static
boolean
equal
(
Object
x
,
Object
y
)
{
if
(
x
==
null
?
y
==
null
:
x
.
equals
(
y
))
return
pass
();
else
return
fail
(
x
+
" not equal to "
+
y
);}
if
(
x
==
null
?
y
==
null
:
x
.
equals
(
y
))
{
return
pass
();
}
else
{
return
fail
(
x
+
" not equal to "
+
y
);
}
}
public
static
void
main
(
String
[]
args
)
throws
Throwable
{
try
{
realMain
(
args
);}
catch
(
Throwable
t
)
{
unexpected
(
t
);}
try
{
realMain
(
args
);
}
catch
(
Throwable
t
)
{
unexpected
(
t
);
}
System
.
out
.
println
(
"\nPassed = "
+
passed
+
" failed = "
+
failed
);
if
(
failed
>
0
)
throw
new
AssertionError
(
"Some tests failed"
);}
if
(
failed
>
0
)
{
throw
new
AssertionError
(
"Some tests failed"
);
}
}
}
test/sun/net/www/protocol/http/HttpInputStream.java
浏览文件 @
7fe61077
/*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003,
2016,
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
...
...
@@ -23,77 +23,95 @@
/* @test
* @bug 4937598
* @summary http://www.clipstream.com v
edi
o does not play; read() problem
* @summary http://www.clipstream.com v
ide
o does not play; read() problem
*/
import
java.util.*
;
import
java.io.*
;
import
java.net.*
;
import
java.text.*
;
public
class
HttpInputStream
implements
Runnable
{
ServerSocket
serverSock
;
public
void
run
()
{
try
{
Socket
s
=
serverSock
.
accept
();
InputStream
in
=
s
.
getInputStream
();
byte
b
[]
=
new
byte
[
4096
];
// assume we read the entire http request
// (bad assumption but okay for test case)
int
nread
=
in
.
read
(
b
);
OutputStream
o
=
s
.
getOutputStream
();
o
.
write
(
"HTTP/1.1 200 OK"
.
getBytes
()
);
o
.
write
(
"Content-Length: 20"
.
getBytes
()
);
o
.
write
(
(
byte
)
'\r'
);
o
.
write
(
(
byte
)
'\n'
);
o
.
write
(
(
byte
)
'\r'
);
o
.
write
(
(
byte
)
'\n'
);
for
(
int
i
=
0
;
i
<
20
;
i
++)
{
o
.
write
((
byte
)
0xff
);
}
o
.
flush
();
o
.
close
();
}
catch
(
Exception
e
)
{
}
}
public
HttpInputStream
()
throws
Exception
{
serverSock
=
new
ServerSocket
(
0
);
int
port
=
serverSock
.
getLocalPort
();
Thread
thr
=
new
Thread
(
this
);
thr
.
start
();
Date
date
=
new
Date
(
new
Date
().
getTime
()-
1440000
);
// this time yesterday
URL
url
;
HttpURLConnection
con
;
url
=
new
URL
(
"http://localhost:"
+
String
.
valueOf
(
port
)
+
"/anything"
);
con
=
(
HttpURLConnection
)
url
.
openConnection
();
int
ret
=
con
.
getResponseCode
();
byte
[]
b
=
new
byte
[
20
];
InputStream
is
=
con
.
getInputStream
();
int
i
=
0
,
count
=
0
;
while
((
i
=
is
.
read
())
!=
-
1
)
{
System
.
out
.
println
(
"i = "
+
i
);
count
++;
}
if
(
count
!=
20
)
{
throw
new
RuntimeException
(
"HttpInputStream.read() failed with 0xff"
);
}
}
public
static
void
main
(
String
args
[])
throws
Exception
{
new
HttpInputStream
();
}
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.net.ServerSocket
;
import
java.net.Socket
;
import
java.net.URL
;
public
class
HttpInputStream
{
private
static
final
int
CONTENT_LENGTH
=
20
;
static
class
Server
implements
AutoCloseable
,
Runnable
{
final
ServerSocket
serverSocket
;
static
final
byte
[]
requestEnd
=
new
byte
[]{
'\r'
,
'\n'
,
'\r'
,
'\n'
};
static
final
int
TIMEOUT
=
10
*
1000
;
Server
()
throws
IOException
{
serverSocket
=
new
ServerSocket
(
0
);
}
void
readOneRequest
(
InputStream
is
)
throws
IOException
{
int
requestEndCount
=
0
,
r
;
while
((
r
=
is
.
read
())
!=
-
1
)
{
if
(
r
==
requestEnd
[
requestEndCount
])
{
requestEndCount
++;
if
(
requestEndCount
==
4
)
{
break
;
}
}
else
{
requestEndCount
=
0
;
}
}
}
@Override
public
void
run
()
{
try
(
Socket
s
=
serverSocket
.
accept
())
{
s
.
setSoTimeout
(
TIMEOUT
);
readOneRequest
(
s
.
getInputStream
());
try
(
OutputStream
os
=
s
.
getOutputStream
())
{
os
.
write
(
"HTTP/1.1 200 OK"
.
getBytes
());
os
.
write
((
"Content-Length: "
+
CONTENT_LENGTH
).
getBytes
());
os
.
write
(
"\r\n\r\n"
.
getBytes
());
for
(
int
i
=
0
;
i
<
CONTENT_LENGTH
;
i
++)
{
os
.
write
(
0xff
);
}
os
.
flush
();
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
@Override
public
void
close
()
throws
IOException
{
if
(!
serverSocket
.
isClosed
())
{
serverSocket
.
close
();
}
}
public
int
getPort
()
{
return
serverSocket
.
getLocalPort
();
}
}
private
static
int
read
(
InputStream
is
)
throws
IOException
{
int
len
=
0
;
while
(
is
.
read
()
!=
-
1
)
{
len
++;
}
return
len
;
}
public
static
void
main
(
String
args
[])
throws
IOException
{
try
(
Server
server
=
new
Server
())
{
(
new
Thread
(
server
)).
start
();
URL
url
=
new
URL
(
"http://localhost:"
+
server
.
getPort
()
+
"/anything"
);
try
(
InputStream
is
=
url
.
openConnection
().
getInputStream
())
{
if
(
read
(
is
)
!=
CONTENT_LENGTH
)
{
throw
new
RuntimeException
(
"HttpInputStream.read() failed with 0xff"
);
}
}
}
}
}
test/sun/security/krb5/auto/UnboundSSL.java
浏览文件 @
7fe61077
...
...
@@ -34,9 +34,9 @@ import javax.security.auth.login.LoginException;
* @bug 8025123
* @summary Checks if an unbound server can handle connections
* only for allowed service principals
* @run main/othervm/policy=unbound.ssl.policy UnboundSSL
* @run main/othervm/
java.security.
policy=unbound.ssl.policy UnboundSSL
* unbound.ssl.jaas.conf server_star
* @run main/othervm/policy=unbound.ssl.policy UnboundSSL
* @run main/othervm/
java.security.
policy=unbound.ssl.policy UnboundSSL
* unbound.ssl.jaas.conf server_multiple_principals
*/
public
class
UnboundSSL
{
...
...
test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/CloseSocket.java
浏览文件 @
7fe61077
/*
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002,
2016,
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,67 +26,96 @@
* @bug 4674913
* @summary Verify that EOFException are correctly handled during the handshake
* @author Andreas Sterbenz
* @run main/othervm CloseSocket
*/
import
java.io.*
;
import
java.net.*
;
import
javax.net.ssl.*
;
import
javax.net.SocketFactory
;
import
javax.net.ssl.SSLSocket
;
import
javax.net.ssl.SSLSocketFactory
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.net.ServerSocket
;
import
java.net.Socket
;
import
java.util.ArrayList
;
public
class
CloseSocket
{
private
static
ArrayList
<
TestCase
>
testCases
=
new
ArrayList
<>();
static
{
testCases
.
add
(
socket
->
socket
.
startHandshake
());
testCases
.
add
(
socket
->
{
InputStream
in
=
socket
.
getInputStream
();
in
.
read
();
});
testCases
.
add
(
socket
->
{
OutputStream
out
=
socket
.
getOutputStream
();
out
.
write
(
43
);
});
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
final
ServerSocket
serverSocket
=
new
ServerSocket
(
0
);
int
serverPort
=
serverSocket
.
getLocalPort
();
new
Thread
()
{
public
void
run
()
{
try
{
Socket
s
=
serverSocket
.
accept
();
System
.
out
.
println
(
"Server accepted connection"
);
// wait a bit before closing the socket to give
// the client time to send its hello message
Thread
.
currentThread
().
sleep
(
100
);
s
.
close
();
System
.
out
.
println
(
"Server closed socket, done."
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"Server exception:"
);
e
.
printStackTrace
();
try
(
Server
server
=
new
Server
())
{
new
Thread
(
server
).
start
();
SocketFactory
factory
=
SSLSocketFactory
.
getDefault
();
try
(
SSLSocket
socket
=
(
SSLSocket
)
factory
.
createSocket
(
"localhost"
,
server
.
getPort
()))
{
socket
.
setSoTimeout
(
2000
);
System
.
out
.
println
(
"Client established TCP connection"
);
boolean
failed
=
false
;
for
(
TestCase
testCase
:
testCases
)
{
try
{
testCase
.
test
(
socket
);
System
.
out
.
println
(
"ERROR: no exception"
);
failed
=
true
;
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"Failed as expected: "
+
e
);
}
}
if
(
failed
)
{
throw
new
Exception
(
"One or more tests failed"
);
}
}
}.
start
();
SSLSocketFactory
factory
=
(
SSLSocketFactory
)
SSLSocketFactory
.
getDefault
();
SSLSocket
socket
=
(
SSLSocket
)
factory
.
createSocket
(
"localhost"
,
serverPort
);
System
.
out
.
println
(
"Client established TCP connection"
);
boolean
failed
=
false
;
try
{
System
.
out
.
println
(
"Starting handshake..."
);
socket
.
startHandshake
();
System
.
out
.
println
(
"ERROR: no exception"
);
failed
=
true
;
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"Failed as expected: "
+
e
);
}
try
{
System
.
out
.
println
(
"Trying read..."
);
InputStream
in
=
socket
.
getInputStream
();
int
b
=
in
.
read
();
System
.
out
.
println
(
"ERROR: no exception, read: "
+
b
)
;
failed
=
true
;
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"Failed as expected: "
+
e
);
}
static
class
Server
implements
AutoCloseable
,
Runnable
{
final
ServerSocket
serverSocket
;
Server
()
throws
IOException
{
serverSocket
=
new
ServerSocket
(
0
);
}
try
{
System
.
out
.
println
(
"Trying read..."
);
OutputStream
out
=
socket
.
getOutputStream
();
out
.
write
(
43
);
System
.
out
.
println
(
"ERROR: no exception"
);
failed
=
true
;
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"Failed as expected: "
+
e
);
public
int
getPort
()
{
return
serverSocket
.
getLocalPort
();
}
if
(
failed
)
{
throw
new
Exception
(
"One or more tests failed"
);
@Override
public
void
run
()
{
try
(
Socket
s
=
serverSocket
.
accept
())
{
System
.
out
.
println
(
"Server accepted connection"
);
// wait a bit before closing the socket to give
// the client time to send its hello message
Thread
.
currentThread
().
sleep
(
100
);
s
.
close
();
System
.
out
.
println
(
"Server closed socket, done."
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"Problem in test execution"
,
e
);
}
}
@Override
public
void
close
()
throws
Exception
{
if
(!
serverSocket
.
isClosed
())
{
serverSocket
.
close
();
}
}
}
interface
TestCase
{
void
test
(
SSLSocket
socket
)
throws
IOException
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录