Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
29a714c1
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看板
提交
29a714c1
编写于
4月 16, 2013
作者:
C
chegar
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
f9756afb
3011c0e5
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
159 addition
and
75 deletion
+159
-75
src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h
src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h
+3
-3
src/share/npt/npt.h
src/share/npt/npt.h
+4
-4
src/solaris/javavm/export/jni_md.h
src/solaris/javavm/export/jni_md.h
+11
-2
src/solaris/native/sun/awt/awt_LoadLibrary.c
src/solaris/native/sun/awt/awt_LoadLibrary.c
+3
-3
src/windows/classes/java/net/DualStackPlainSocketImpl.java
src/windows/classes/java/net/DualStackPlainSocketImpl.java
+2
-1
src/windows/native/java/net/SocketInputStream.c
src/windows/native/java/net/SocketInputStream.c
+29
-26
test/java/net/Socket/asyncClose/Race.java
test/java/net/Socket/asyncClose/Race.java
+3
-3
test/java/util/concurrent/CompletableFuture/Basic.java
test/java/util/concurrent/CompletableFuture/Basic.java
+104
-33
未找到文件。
src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h
浏览文件 @
29a714c1
...
@@ -143,9 +143,9 @@ typedef struct _SurfaceType {
...
@@ -143,9 +143,9 @@ typedef struct _SurfaceType {
* structure from the information present in a given Java Composite
* structure from the information present in a given Java Composite
* object.
* object.
*/
*/
typedef
JNIEXPORT
void
(
JNICALL
CompInfoFunc
)(
JNIEnv
*
env
,
typedef
void
(
JNICALL
CompInfoFunc
)(
JNIEnv
*
env
,
CompositeInfo
*
pCompInfo
,
CompositeInfo
*
pCompInfo
,
jobject
Composite
);
jobject
Composite
);
/*
/*
* The additional information needed to implement a primitive that
* The additional information needed to implement a primitive that
...
...
src/share/npt/npt.h
浏览文件 @
29a714c1
...
@@ -94,13 +94,13 @@ typedef struct {
...
@@ -94,13 +94,13 @@ typedef struct {
JNIEXPORT
void
JNICALL
nptInitialize
JNIEXPORT
void
JNICALL
nptInitialize
(
NptEnv
**
pnpt
,
char
*
nptVersion
,
char
*
options
);
(
NptEnv
**
pnpt
,
char
*
nptVersion
,
char
*
options
);
typedef
JNIEXPORT
void
(
JNICALL
*
NptInitialize
)
typedef
void
(
JNICALL
*
NptInitialize
)
(
NptEnv
**
pnpt
,
char
*
nptVersion
,
char
*
options
);
(
NptEnv
**
pnpt
,
char
*
nptVersion
,
char
*
options
);
JNIEXPORT
void
JNICALL
nptTerminate
JNIEXPORT
void
JNICALL
nptTerminate
(
NptEnv
*
npt
,
char
*
options
);
(
NptEnv
*
npt
,
char
*
options
);
typedef
JNIEXPORT
void
(
JNICALL
*
NptTerminate
)
typedef
void
(
JNICALL
*
NptTerminate
)
(
NptEnv
*
npt
,
char
*
options
);
(
NptEnv
*
npt
,
char
*
options
);
#ifdef __cplusplus
#ifdef __cplusplus
}
/* extern "C" */
}
/* extern "C" */
...
...
src/solaris/javavm/export/jni_md.h
浏览文件 @
29a714c1
...
@@ -26,8 +26,17 @@
...
@@ -26,8 +26,17 @@
#ifndef _JAVASOFT_JNI_MD_H_
#ifndef _JAVASOFT_JNI_MD_H_
#define _JAVASOFT_JNI_MD_H_
#define _JAVASOFT_JNI_MD_H_
#define JNIEXPORT
#ifndef __has_attribute
#define JNIIMPORT
#define __has_attribute(x) 0
#endif
#if (defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ > 2))) || __has_attribute(visibility)
#define JNIEXPORT __attribute__((visibility("default")))
#define JNIIMPORT __attribute__((visibility("default")))
#else
#define JNIEXPORT
#define JNIIMPORT
#endif
#define JNICALL
#define JNICALL
typedef
int
jint
;
typedef
int
jint
;
...
...
src/solaris/native/sun/awt/awt_LoadLibrary.c
浏览文件 @
29a714c1
...
@@ -43,7 +43,7 @@
...
@@ -43,7 +43,7 @@
static
void
*
awtHandle
=
NULL
;
static
void
*
awtHandle
=
NULL
;
typedef
JNIEXPORT
jint
JNICALL
JNI_OnLoad_type
(
JavaVM
*
vm
,
void
*
reserved
);
typedef
jint
JNICALL
JNI_OnLoad_type
(
JavaVM
*
vm
,
void
*
reserved
);
/* Initialize the Java VM instance variable when the library is
/* Initialize the Java VM instance variable when the library is
first loaded */
first loaded */
...
@@ -206,7 +206,7 @@ Java_sun_awt_motif_XsessionWMcommand(JNIEnv *env, jobject this,
...
@@ -206,7 +206,7 @@ Java_sun_awt_motif_XsessionWMcommand(JNIEnv *env, jobject this,
jobject
frame
,
jstring
jcommand
)
jobject
frame
,
jstring
jcommand
)
{
{
/* type of the old backdoor function */
/* type of the old backdoor function */
typedef
JNIEXPORT
void
JNICALL
typedef
void
JNICALL
XsessionWMcommand_type
(
JNIEnv
*
env
,
jobject
this
,
XsessionWMcommand_type
(
JNIEnv
*
env
,
jobject
this
,
jobject
frame
,
jstring
jcommand
);
jobject
frame
,
jstring
jcommand
);
...
@@ -234,7 +234,7 @@ Java_sun_awt_motif_XsessionWMcommand(JNIEnv *env, jobject this,
...
@@ -234,7 +234,7 @@ Java_sun_awt_motif_XsessionWMcommand(JNIEnv *env, jobject this,
JNIEXPORT
void
JNICALL
JNIEXPORT
void
JNICALL
Java_sun_awt_motif_XsessionWMcommand_New
(
JNIEnv
*
env
,
jobjectArray
jargv
)
Java_sun_awt_motif_XsessionWMcommand_New
(
JNIEnv
*
env
,
jobjectArray
jargv
)
{
{
typedef
JNIEXPORT
void
JNICALL
typedef
void
JNICALL
XsessionWMcommand_New_type
(
JNIEnv
*
env
,
jobjectArray
jargv
);
XsessionWMcommand_New_type
(
JNIEnv
*
env
,
jobjectArray
jargv
);
static
XsessionWMcommand_New_type
*
XsessionWMcommand
=
NULL
;
static
XsessionWMcommand_New_type
*
XsessionWMcommand
=
NULL
;
...
...
src/windows/classes/java/net/DualStackPlainSocketImpl.java
浏览文件 @
29a714c1
...
@@ -152,8 +152,9 @@ class DualStackPlainSocketImpl extends AbstractPlainSocketImpl
...
@@ -152,8 +152,9 @@ class DualStackPlainSocketImpl extends AbstractPlainSocketImpl
if
(!
fd
.
valid
())
if
(!
fd
.
valid
())
return
;
return
;
close0
(
fdAccess
.
get
(
fd
)
);
final
int
nativefd
=
fdAccess
.
get
(
fd
);
fdAccess
.
set
(
fd
,
-
1
);
fdAccess
.
set
(
fd
,
-
1
);
close0
(
nativefd
);
}
}
void
socketShutdown
(
int
howto
)
throws
IOException
{
void
socketShutdown
(
int
howto
)
throws
IOException
{
...
...
src/windows/native/java/net/SocketInputStream.c
浏览文件 @
29a714c1
...
@@ -134,32 +134,35 @@ Java_java_net_SocketInputStream_socketRead0(JNIEnv *env, jobject this,
...
@@ -134,32 +134,35 @@ Java_java_net_SocketInputStream_socketRead0(JNIEnv *env, jobject this,
(
*
env
)
->
SetByteArrayRegion
(
env
,
data
,
off
,
nread
,
(
jbyte
*
)
bufP
);
(
*
env
)
->
SetByteArrayRegion
(
env
,
data
,
off
,
nread
,
(
jbyte
*
)
bufP
);
}
else
{
}
else
{
if
(
nread
<
0
)
{
if
(
nread
<
0
)
{
/*
// Check if the socket has been closed since we last checked.
* Recv failed.
// This could be a reason for recv failing.
*/
if
((
*
env
)
->
GetIntField
(
env
,
fdObj
,
IO_fd_fdID
)
==
-
1
)
{
switch
(
WSAGetLastError
())
{
NET_ThrowSocketException
(
env
,
"Socket closed"
);
case
WSAEINTR
:
}
else
{
JNU_ThrowByName
(
env
,
JNU_JAVANETPKG
"SocketException"
,
switch
(
WSAGetLastError
())
{
"socket closed"
);
case
WSAEINTR
:
break
;
JNU_ThrowByName
(
env
,
JNU_JAVANETPKG
"SocketException"
,
"socket closed"
);
case
WSAECONNRESET
:
break
;
case
WSAESHUTDOWN
:
/*
case
WSAECONNRESET
:
* Connection has been reset - Windows sometimes reports
case
WSAESHUTDOWN
:
* the reset as a shutdown error.
/*
*/
* Connection has been reset - Windows sometimes reports
JNU_ThrowByName
(
env
,
"sun/net/ConnectionResetException"
,
* the reset as a shutdown error.
""
);
*/
break
;
JNU_ThrowByName
(
env
,
"sun/net/ConnectionResetException"
,
""
);
case
WSAETIMEDOUT
:
break
;
JNU_ThrowByName
(
env
,
JNU_JAVANETPKG
"SocketTimeoutException"
,
"Read timed out"
);
case
WSAETIMEDOUT
:
break
;
JNU_ThrowByName
(
env
,
JNU_JAVANETPKG
"SocketTimeoutException"
,
"Read timed out"
);
default:
break
;
NET_ThrowCurrent
(
env
,
"recv failed"
);
default:
NET_ThrowCurrent
(
env
,
"recv failed"
);
}
}
}
}
}
}
}
...
...
test/java/net/Socket/asyncClose/Race.java
浏览文件 @
29a714c1
...
@@ -23,8 +23,8 @@
...
@@ -23,8 +23,8 @@
/*
/*
* @test
* @test
* @bug 8006395
* @bug 8006395
8012244
* @summary
Race in async socket close on Linux
* @summary
Tests racing code that reads and closes a Socket
*/
*/
import
java.io.InputStream
;
import
java.io.InputStream
;
...
@@ -58,7 +58,7 @@ public class Race {
...
@@ -58,7 +58,7 @@ public class Race {
Thread
.
sleep
(
50
);
Thread
.
sleep
(
50
);
}
catch
(
Exception
x
)
{
}
catch
(
Exception
x
)
{
if
(!(
x
instanceof
SocketException
if
(!(
x
instanceof
SocketException
&&
x
.
getMessage
().
equals
(
"S
ocket closed"
)))
&&
x
.
getMessage
().
equals
IgnoreCase
(
"s
ocket closed"
)))
x
.
printStackTrace
();
x
.
printStackTrace
();
// ok, expect Socket closed
// ok, expect Socket closed
}
}
...
...
test/java/util/concurrent/CompletableFuture/Basic.java
浏览文件 @
29a714c1
...
@@ -486,40 +486,61 @@ public class Basic {
...
@@ -486,40 +486,61 @@ public class Basic {
CompletableFuture
<
Integer
>
cf1
=
supplyAsync
(()
->
1
);
CompletableFuture
<
Integer
>
cf1
=
supplyAsync
(()
->
1
);
CompletableFuture
<
Integer
>
cf2
=
supplyAsync
(()
->
2
);
CompletableFuture
<
Integer
>
cf2
=
supplyAsync
(()
->
2
);
cf3
=
cf1
.
applyToEither
(
cf2
,
(
x
)
->
{
check
(
x
==
1
||
x
==
2
);
return
x
;
});
cf3
=
cf1
.
applyToEither
(
cf2
,
(
x
)
->
{
check
(
x
==
1
||
x
==
2
);
return
x
;
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
checkCompletedNormally
(
cf3
,
new
Object
[]
{
1
,
2
});
checkCompletedNormally
(
cf3
,
new
Object
[]
{
1
,
2
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
cf1
=
supplyAsync
(()
->
1
);
cf1
=
supplyAsync
(()
->
1
);
cf2
=
supplyAsync
(()
->
2
);
cf2
=
supplyAsync
(()
->
2
);
cf3
=
cf1
.
applyToEitherAsync
(
cf2
,
(
x
)
->
{
check
(
x
==
1
||
x
==
2
);
return
x
;
});
cf3
=
cf1
.
applyToEitherAsync
(
cf2
,
(
x
)
->
{
check
(
x
==
1
||
x
==
2
);
return
x
;
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
checkCompletedNormally
(
cf3
,
new
Object
[]
{
1
,
2
});
checkCompletedNormally
(
cf3
,
new
Object
[]
{
1
,
2
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
cf1
=
supplyAsync
(()
->
1
);
cf1
=
supplyAsync
(()
->
1
);
cf2
=
supplyAsync
(()
->
2
);
cf2
=
supplyAsync
(()
->
2
);
cf3
=
cf1
.
applyToEitherAsync
(
cf2
,
(
x
)
->
{
check
(
x
==
1
||
x
==
2
);
return
x
;
},
executor
);
cf3
=
cf1
.
applyToEitherAsync
(
cf2
,
(
x
)
->
{
check
(
x
==
1
||
x
==
2
);
return
x
;
},
executor
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
checkCompletedNormally
(
cf3
,
new
Object
[]
{
1
,
2
});
checkCompletedNormally
(
cf3
,
new
Object
[]
{
1
,
2
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
cf1
=
supplyAsync
(()
->
{
throw
new
RuntimeException
();
});
cf1
=
supplyAsync
(()
->
{
throw
new
RuntimeException
();
});
cf2
=
supplyAsync
(()
->
2
);
cf2
=
supplyAsync
(()
->
2
);
cf3
=
cf1
.
applyToEither
(
cf2
,
(
x
)
->
{
check
(
x
==
2
);
return
x
;
});
cf3
=
cf1
.
applyToEither
(
cf2
,
(
x
)
->
{
check
(
x
==
2
);
return
x
;
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
try
{
check
(
cf3
.
join
()
==
2
);
}
catch
(
CompletionException
x
)
{
pass
();
}
try
{
check
(
cf3
.
join
()
==
1
);
}
catch
(
CompletionException
x
)
{
pass
();
}
check
(
cf3
.
isDone
());
check
(
cf3
.
isDone
());
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
cf1
=
supplyAsync
(()
->
1
);
cf1
=
supplyAsync
(()
->
1
);
cf2
=
supplyAsync
(()
->
{
throw
new
RuntimeException
();
});
cf2
=
supplyAsync
(()
->
{
throw
new
RuntimeException
();
});
cf3
=
cf1
.
applyToEitherAsync
(
cf2
,
(
x
)
->
{
check
(
x
==
1
);
return
x
;
});
cf3
=
cf1
.
applyToEitherAsync
(
cf2
,
(
x
)
->
{
check
(
x
==
1
);
return
x
;
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
try
{
check
(
cf3
.
join
()
==
1
);
}
catch
(
CompletionException
x
)
{
pass
();
}
try
{
check
(
cf3
.
join
()
==
1
);
}
catch
(
CompletionException
x
)
{
pass
();
}
check
(
cf3
.
isDone
());
check
(
cf3
.
isDone
());
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
cf1
=
supplyAsync
(()
->
{
throw
new
RuntimeException
();
});
cf1
=
supplyAsync
(()
->
{
throw
new
RuntimeException
();
});
cf2
=
supplyAsync
(()
->
{
throw
new
RuntimeException
();
});
cf2
=
supplyAsync
(()
->
{
throw
new
RuntimeException
();
});
cf3
=
cf1
.
applyToEitherAsync
(
cf2
,
(
x
)
->
{
fail
();
return
x
;
});
cf3
=
cf1
.
applyToEitherAsync
(
cf2
,
(
x
)
->
{
fail
();
return
x
;
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
checkCompletedExceptionally
(
cf3
);
checkCompletedExceptionally
(
cf3
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
final
Phaser
cf3Done
=
new
Phaser
(
2
);
cf1
=
supplyAsync
(()
->
{
cf3Done
.
arriveAndAwaitAdvance
();
return
1
;
});
cf2
=
supplyAsync
(()
->
2
);
cf3
=
cf1
.
applyToEither
(
cf2
,
(
x
)
->
{
check
(
x
==
2
);
return
x
;
});
checkCompletedNormally
(
cf3
,
2
);
checkCompletedNormally
(
cf2
,
2
);
check
(!
cf1
.
isDone
());
cf3Done
.
arrive
();
checkCompletedNormally
(
cf1
,
1
);
checkCompletedNormally
(
cf3
,
2
);
cf1
=
supplyAsync
(()
->
1
);
cf2
=
supplyAsync
(()
->
{
cf3Done
.
arriveAndAwaitAdvance
();
return
2
;
});
cf3
=
cf1
.
applyToEitherAsync
(
cf2
,
(
x
)
->
{
check
(
x
==
1
);
return
x
;
});
checkCompletedNormally
(
cf3
,
1
);
checkCompletedNormally
(
cf1
,
1
);
check
(!
cf2
.
isDone
());
cf3Done
.
arrive
();
checkCompletedNormally
(
cf2
,
2
);
checkCompletedNormally
(
cf3
,
1
);
}
catch
(
Throwable
t
)
{
unexpected
(
t
);
}
}
catch
(
Throwable
t
)
{
unexpected
(
t
);
}
//----------------------------------------------------------------
//----------------------------------------------------------------
...
@@ -531,45 +552,66 @@ public class Basic {
...
@@ -531,45 +552,66 @@ public class Basic {
CompletableFuture
<
Integer
>
cf1
=
supplyAsync
(()
->
1
);
CompletableFuture
<
Integer
>
cf1
=
supplyAsync
(()
->
1
);
CompletableFuture
<
Integer
>
cf2
=
supplyAsync
(()
->
2
);
CompletableFuture
<
Integer
>
cf2
=
supplyAsync
(()
->
2
);
cf3
=
cf1
.
acceptEither
(
cf2
,
(
x
)
->
{
check
(
x
==
1
||
x
==
2
);
atomicInt
.
incrementAndGet
();
});
cf3
=
cf1
.
acceptEither
(
cf2
,
(
x
)
->
{
check
(
x
==
1
||
x
==
2
);
atomicInt
.
incrementAndGet
();
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
checkCompletedNormally
(
cf3
,
null
);
checkCompletedNormally
(
cf3
,
null
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
check
(
atomicInt
.
get
()
==
(
before
+
1
));
check
(
atomicInt
.
get
()
==
(
before
+
1
));
before
=
atomicInt
.
get
();
before
=
atomicInt
.
get
();
cf1
=
supplyAsync
(()
->
1
);
cf1
=
supplyAsync
(()
->
1
);
cf2
=
supplyAsync
(()
->
2
);
cf2
=
supplyAsync
(()
->
2
);
cf3
=
cf1
.
acceptEitherAsync
(
cf2
,
(
x
)
->
{
check
(
x
==
1
||
x
==
2
);
atomicInt
.
incrementAndGet
();
});
cf3
=
cf1
.
acceptEitherAsync
(
cf2
,
(
x
)
->
{
check
(
x
==
1
||
x
==
2
);
atomicInt
.
incrementAndGet
();
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
checkCompletedNormally
(
cf3
,
null
);
checkCompletedNormally
(
cf3
,
null
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
check
(
atomicInt
.
get
()
==
(
before
+
1
));
check
(
atomicInt
.
get
()
==
(
before
+
1
));
before
=
atomicInt
.
get
();
before
=
atomicInt
.
get
();
cf1
=
supplyAsync
(()
->
1
);
cf1
=
supplyAsync
(()
->
1
);
cf2
=
supplyAsync
(()
->
2
);
cf2
=
supplyAsync
(()
->
2
);
cf3
=
cf2
.
acceptEitherAsync
(
cf1
,
(
x
)
->
{
check
(
x
==
1
||
x
==
2
);
atomicInt
.
incrementAndGet
();
},
executor
);
cf3
=
cf2
.
acceptEitherAsync
(
cf1
,
(
x
)
->
{
check
(
x
==
1
||
x
==
2
);
atomicInt
.
incrementAndGet
();
},
executor
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
checkCompletedNormally
(
cf3
,
null
);
checkCompletedNormally
(
cf3
,
null
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
check
(
atomicInt
.
get
()
==
(
before
+
1
));
check
(
atomicInt
.
get
()
==
(
before
+
1
));
cf1
=
supplyAsync
(()
->
{
throw
new
RuntimeException
();
});
cf1
=
supplyAsync
(()
->
{
throw
new
RuntimeException
();
});
cf2
=
supplyAsync
(()
->
2
);
cf2
=
supplyAsync
(()
->
2
);
cf3
=
cf2
.
acceptEitherAsync
(
cf1
,
(
x
)
->
{
check
(
x
==
2
);
},
executor
);
cf3
=
cf2
.
acceptEitherAsync
(
cf1
,
(
x
)
->
{
check
(
x
==
2
);
},
executor
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
try
{
check
(
cf3
.
join
()
==
null
);
}
catch
(
CompletionException
x
)
{
pass
();
}
try
{
check
(
cf3
.
join
()
==
null
);
}
catch
(
CompletionException
x
)
{
pass
();
}
check
(
cf3
.
isDone
());
check
(
cf3
.
isDone
());
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
cf1
=
supplyAsync
(()
->
1
);
cf1
=
supplyAsync
(()
->
1
);
cf2
=
supplyAsync
(()
->
{
throw
new
RuntimeException
();
});
cf2
=
supplyAsync
(()
->
{
throw
new
RuntimeException
();
});
cf3
=
cf2
.
acceptEitherAsync
(
cf1
,
(
x
)
->
{
check
(
x
==
1
);
});
cf3
=
cf2
.
acceptEitherAsync
(
cf1
,
(
x
)
->
{
check
(
x
==
1
);
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
try
{
check
(
cf3
.
join
()
==
null
);
}
catch
(
CompletionException
x
)
{
pass
();
}
try
{
check
(
cf3
.
join
()
==
null
);
}
catch
(
CompletionException
x
)
{
pass
();
}
check
(
cf3
.
isDone
());
check
(
cf3
.
isDone
());
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
cf1
=
supplyAsync
(()
->
{
throw
new
RuntimeException
();
});
cf1
=
supplyAsync
(()
->
{
throw
new
RuntimeException
();
});
cf2
=
supplyAsync
(()
->
{
throw
new
RuntimeException
();
});
cf2
=
supplyAsync
(()
->
{
throw
new
RuntimeException
();
});
cf3
=
cf2
.
acceptEitherAsync
(
cf1
,
(
x
)
->
{
fail
();
});
cf3
=
cf2
.
acceptEitherAsync
(
cf1
,
(
x
)
->
{
fail
();
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
checkCompletedExceptionally
(
cf3
);
checkCompletedExceptionally
(
cf3
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
final
Phaser
cf3Done
=
new
Phaser
(
2
);
cf1
=
supplyAsync
(()
->
{
cf3Done
.
arriveAndAwaitAdvance
();
return
1
;
});
cf2
=
supplyAsync
(()
->
2
);
cf3
=
cf1
.
acceptEither
(
cf2
,
(
x
)
->
{
check
(
x
==
2
);
});
checkCompletedNormally
(
cf3
,
null
);
checkCompletedNormally
(
cf2
,
2
);
check
(!
cf1
.
isDone
());
cf3Done
.
arrive
();
checkCompletedNormally
(
cf1
,
1
);
checkCompletedNormally
(
cf3
,
null
);
cf1
=
supplyAsync
(()
->
1
);
cf2
=
supplyAsync
(()
->
{
cf3Done
.
arriveAndAwaitAdvance
();
return
2
;
});
cf3
=
cf1
.
acceptEitherAsync
(
cf2
,
(
x
)
->
{
check
(
x
==
1
);
});
checkCompletedNormally
(
cf3
,
null
);
checkCompletedNormally
(
cf1
,
1
);
check
(!
cf2
.
isDone
());
cf3Done
.
arrive
();
checkCompletedNormally
(
cf2
,
2
);
checkCompletedNormally
(
cf3
,
null
);
}
catch
(
Throwable
t
)
{
unexpected
(
t
);
}
}
catch
(
Throwable
t
)
{
unexpected
(
t
);
}
//----------------------------------------------------------------
//----------------------------------------------------------------
...
@@ -581,51 +623,80 @@ public class Basic {
...
@@ -581,51 +623,80 @@ public class Basic {
CompletableFuture
<
Void
>
cf1
=
runAsync
(()
->
{
});
CompletableFuture
<
Void
>
cf1
=
runAsync
(()
->
{
});
CompletableFuture
<
Void
>
cf2
=
runAsync
(()
->
{
});
CompletableFuture
<
Void
>
cf2
=
runAsync
(()
->
{
});
cf3
=
cf1
.
runAfterEither
(
cf2
,
()
->
{
atomicInt
.
incrementAndGet
();
});
cf3
=
cf1
.
runAfterEither
(
cf2
,
()
->
{
atomicInt
.
incrementAndGet
();
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
checkCompletedNormally
(
cf3
,
null
);
checkCompletedNormally
(
cf3
,
null
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
check
(
atomicInt
.
get
()
==
(
before
+
1
));
check
(
atomicInt
.
get
()
==
(
before
+
1
));
before
=
atomicInt
.
get
();
before
=
atomicInt
.
get
();
cf1
=
runAsync
(()
->
{
});
cf1
=
runAsync
(()
->
{
});
cf2
=
runAsync
(()
->
{
});
cf2
=
runAsync
(()
->
{
});
cf3
=
cf1
.
runAfterEitherAsync
(
cf2
,
()
->
{
atomicInt
.
incrementAndGet
();
});
cf3
=
cf1
.
runAfterEitherAsync
(
cf2
,
()
->
{
atomicInt
.
incrementAndGet
();
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
checkCompletedNormally
(
cf3
,
null
);
checkCompletedNormally
(
cf3
,
null
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
check
(
atomicInt
.
get
()
==
(
before
+
1
));
check
(
atomicInt
.
get
()
==
(
before
+
1
));
before
=
atomicInt
.
get
();
before
=
atomicInt
.
get
();
cf1
=
runAsync
(()
->
{
});
cf1
=
runAsync
(()
->
{
});
cf2
=
runAsync
(()
->
{
});
cf2
=
runAsync
(()
->
{
});
cf3
=
cf2
.
runAfterEitherAsync
(
cf1
,
()
->
{
atomicInt
.
incrementAndGet
();
},
executor
);
cf3
=
cf2
.
runAfterEitherAsync
(
cf1
,
()
->
{
atomicInt
.
incrementAndGet
();
},
executor
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
checkCompletedNormally
(
cf3
,
null
);
checkCompletedNormally
(
cf3
,
null
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
check
(
atomicInt
.
get
()
==
(
before
+
1
));
check
(
atomicInt
.
get
()
==
(
before
+
1
));
before
=
atomicInt
.
get
();
before
=
atomicInt
.
get
();
cf1
=
runAsync
(()
->
{
throw
new
RuntimeException
();
});
cf1
=
runAsync
(()
->
{
throw
new
RuntimeException
();
});
cf2
=
runAsync
(()
->
{
});
cf2
=
runAsync
(()
->
{
});
cf3
=
cf2
.
runAfterEither
(
cf1
,
()
->
{
atomicInt
.
incrementAndGet
();
});
cf3
=
cf2
.
runAfterEither
(
cf1
,
()
->
{
atomicInt
.
incrementAndGet
();
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
try
{
try
{
check
(
cf3
.
join
()
==
null
);
}
catch
(
CompletionException
x
)
{
pass
();
}
check
(
cf3
.
join
()
==
null
);
check
(
atomicInt
.
get
()
==
(
before
+
1
));
}
catch
(
CompletionException
x
)
{
pass
();
}
check
(
cf3
.
isDone
());
check
(
cf3
.
isDone
());
check
(
atomicInt
.
get
()
==
(
before
+
1
));
check
(
cf1
.
isDone
()
||
cf2
.
isDone
(
));
before
=
atomicInt
.
get
();
before
=
atomicInt
.
get
();
cf1
=
runAsync
(()
->
{
});
cf1
=
runAsync
(()
->
{
});
cf2
=
runAsync
(()
->
{
throw
new
RuntimeException
();
});
cf2
=
runAsync
(()
->
{
throw
new
RuntimeException
();
});
cf3
=
cf1
.
runAfterEitherAsync
(
cf2
,
()
->
{
atomicInt
.
incrementAndGet
();
});
cf3
=
cf1
.
runAfterEitherAsync
(
cf2
,
()
->
{
atomicInt
.
incrementAndGet
();
});
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
try
{
try
{
check
(
cf3
.
join
()
==
null
);
}
catch
(
CompletionException
x
)
{
pass
();
}
check
(
cf3
.
join
()
==
null
);
check
(
atomicInt
.
get
()
==
(
before
+
1
));
}
catch
(
CompletionException
x
)
{
pass
();
}
check
(
cf3
.
isDone
());
check
(
cf3
.
isDone
());
check
(
atomicInt
.
get
()
==
(
before
+
1
));
check
(
cf1
.
isDone
()
||
cf2
.
isDone
(
));
before
=
atomicInt
.
get
();
before
=
atomicInt
.
get
();
cf1
=
runAsync
(()
->
{
throw
new
RuntimeException
();
});
cf1
=
runAsync
(()
->
{
throw
new
RuntimeException
();
});
cf2
=
runAsync
(()
->
{
throw
new
RuntimeException
();
});
cf2
=
runAsync
(()
->
{
throw
new
RuntimeException
();
});
cf3
=
cf2
.
runAfterEitherAsync
(
cf1
,
()
->
{
atomicInt
.
incrementAndGet
();
},
executor
);
cf3
=
cf2
.
runAfterEitherAsync
(
cf1
,
()
->
{
atomicInt
.
incrementAndGet
();
},
executor
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
checkCompletedExceptionally
(
cf3
);
checkCompletedExceptionally
(
cf3
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
());
check
(
atomicInt
.
get
()
==
before
);
check
(
atomicInt
.
get
()
==
before
);
final
Phaser
cf3Done
=
new
Phaser
(
2
);
before
=
atomicInt
.
get
();
cf1
=
runAsync
(()
->
{
cf3Done
.
arriveAndAwaitAdvance
();
});
cf2
=
runAsync
(()
->
{
});
cf3
=
cf1
.
runAfterEither
(
cf2
,
()
->
{
atomicInt
.
incrementAndGet
();
});
checkCompletedNormally
(
cf3
,
null
);
checkCompletedNormally
(
cf2
,
null
);
check
(!
cf1
.
isDone
());
check
(
atomicInt
.
get
()
==
(
before
+
1
));
cf3Done
.
arrive
();
checkCompletedNormally
(
cf1
,
null
);
checkCompletedNormally
(
cf3
,
null
);
before
=
atomicInt
.
get
();
cf1
=
runAsync
(()
->
{
});
cf2
=
runAsync
(()
->
{
cf3Done
.
arriveAndAwaitAdvance
();
});
cf3
=
cf1
.
runAfterEitherAsync
(
cf2
,
()
->
{
atomicInt
.
incrementAndGet
();
});
checkCompletedNormally
(
cf3
,
null
);
checkCompletedNormally
(
cf1
,
null
);
check
(!
cf2
.
isDone
());
check
(
atomicInt
.
get
()
==
(
before
+
1
));
cf3Done
.
arrive
();
checkCompletedNormally
(
cf2
,
null
);
checkCompletedNormally
(
cf3
,
null
);
}
catch
(
Throwable
t
)
{
unexpected
(
t
);
}
}
catch
(
Throwable
t
)
{
unexpected
(
t
);
}
//----------------------------------------------------------------
//----------------------------------------------------------------
...
@@ -670,16 +741,16 @@ public class Basic {
...
@@ -670,16 +741,16 @@ public class Basic {
//----------------------------------------------------------------
//----------------------------------------------------------------
// anyOf tests
// anyOf tests
//----------------------------------------------------------------
//----------------------------------------------------------------
//
try {
try
{
//
CompletableFuture<Object> cf3;
CompletableFuture
<
Object
>
cf3
;
//
for (int k=0; k < 10; k++){
for
(
int
k
=
0
;
k
<
10
;
k
++){
//
CompletableFuture<Integer> cf1 = supplyAsync(() -> 1);
CompletableFuture
<
Integer
>
cf1
=
supplyAsync
(()
->
1
);
//
CompletableFuture<Integer> cf2 = supplyAsync(() -> 2);
CompletableFuture
<
Integer
>
cf2
=
supplyAsync
(()
->
2
);
//
cf3 = CompletableFuture.anyOf(cf1, cf2);
cf3
=
CompletableFuture
.
anyOf
(
cf1
,
cf2
);
// check(cf1.isDone() || cf2.isDone()
);
checkCompletedNormally
(
cf3
,
new
Object
[]
{
1
,
2
}
);
// checkCompletedNormally(cf3, new Object[] {1, 2}
);
check
(
cf1
.
isDone
()
||
cf2
.
isDone
()
);
//
}
}
//
} catch (Throwable t) { unexpected(t); }
}
catch
(
Throwable
t
)
{
unexpected
(
t
);
}
//----------------------------------------------------------------
//----------------------------------------------------------------
// allOf tests
// allOf tests
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录