Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell11
提交
cb72a052
D
dragonwell11
项目概览
openanolis
/
dragonwell11
通知
7
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell11
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cb72a052
编写于
2月 28, 2017
作者:
J
jwilhelm
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
9d06e61f
56cb7a18
变更
24
隐藏空白更改
内联
并排
Showing
24 changed file
with
694 addition
and
47 deletion
+694
-47
jdk/src/java.base/share/classes/java/util/ServiceLoader.java
jdk/src/java.base/share/classes/java/util/ServiceLoader.java
+12
-2
jdk/src/java.base/share/classes/jdk/internal/loader/BootLoader.java
...va.base/share/classes/jdk/internal/loader/BootLoader.java
+8
-0
jdk/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java
...share/classes/jdk/internal/loader/BuiltinClassLoader.java
+13
-5
jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Exchange.java
...httpclient/share/classes/jdk/incubator/http/Exchange.java
+4
-2
jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/ExchangeImpl.java
...client/share/classes/jdk/incubator/http/ExchangeImpl.java
+3
-3
jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http1Exchange.java
...lient/share/classes/jdk/incubator/http/Http1Exchange.java
+4
-4
jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http1Response.java
...lient/share/classes/jdk/incubator/http/Http1Response.java
+1
-0
jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpConnection.java
...ient/share/classes/jdk/incubator/http/HttpConnection.java
+1
-1
jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpRequestImpl.java
...ent/share/classes/jdk/incubator/http/HttpRequestImpl.java
+5
-0
jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/PlainTunnelingConnection.java
.../classes/jdk/incubator/http/PlainTunnelingConnection.java
+1
-1
jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Stream.java
...r.httpclient/share/classes/jdk/incubator/http/Stream.java
+5
-5
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleSorter.java
.../share/classes/jdk/tools/jlink/internal/ModuleSorter.java
+10
-7
jdk/test/ProblemList.txt
jdk/test/ProblemList.txt
+0
-2
jdk/test/java/net/httpclient/websocket/ConnectionHandover.java
...est/java/net/httpclient/websocket/ConnectionHandover.java
+68
-0
jdk/test/java/net/httpclient/websocket/DummyWebSocketServer.java
...t/java/net/httpclient/websocket/DummyWebSocketServer.java
+278
-0
jdk/test/java/net/httpclient/websocket/LoggingHelper.java
jdk/test/java/net/httpclient/websocket/LoggingHelper.java
+38
-0
jdk/test/java/net/httpclient/websocket/logging.properties
jdk/test/java/net/httpclient/websocket/logging.properties
+5
-0
jdk/test/java/nio/file/WatchService/LotsOfEvents.java
jdk/test/java/nio/file/WatchService/LotsOfEvents.java
+35
-14
jdk/test/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java
...jlink/plugins/SystemModuleDescriptors/UserModuleTest.java
+45
-1
jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m3/module-info.java
...k/plugins/SystemModuleDescriptors/src/m3/module-info.java
+1
-0
jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m3/p3/Foo.java
.../jlink/plugins/SystemModuleDescriptors/src/m3/p3/Foo.java
+36
-0
jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m3/p3/Lib.java
.../jlink/plugins/SystemModuleDescriptors/src/m3/p3/Lib.java
+30
-0
jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m5/module-info.java
...k/plugins/SystemModuleDescriptors/src/m5/module-info.java
+27
-0
jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m5/p5/Main.java
...jlink/plugins/SystemModuleDescriptors/src/m5/p5/Main.java
+64
-0
未找到文件。
jdk/src/java.base/share/classes/java/util/ServiceLoader.java
浏览文件 @
cb72a052
...
...
@@ -48,6 +48,7 @@ import java.util.stream.Stream;
import
java.util.stream.StreamSupport
;
import
jdk.internal.loader.BootLoader
;
import
jdk.internal.loader.ClassLoaders
;
import
jdk.internal.misc.JavaLangAccess
;
import
jdk.internal.misc.JavaLangReflectModuleAccess
;
import
jdk.internal.misc.SharedSecrets
;
...
...
@@ -1076,10 +1077,19 @@ public final class ServiceLoader<S>
if
(
configs
==
null
)
{
try
{
String
fullName
=
PREFIX
+
service
.
getName
();
if
(
loader
==
null
)
if
(
loader
==
null
)
{
configs
=
ClassLoader
.
getSystemResources
(
fullName
);
else
}
else
if
(
loader
==
ClassLoaders
.
platformClassLoader
())
{
// The platform classloader doesn't have a class path,
// but the boot loader might.
if
(
BootLoader
.
hasClassPath
())
{
configs
=
BootLoader
.
findResources
(
fullName
);
}
else
{
configs
=
Collections
.
emptyEnumeration
();
}
}
else
{
configs
=
loader
.
getResources
(
fullName
);
}
}
catch
(
IOException
x
)
{
fail
(
service
,
"Error locating configuration files"
,
x
);
}
...
...
jdk/src/java.base/share/classes/jdk/internal/loader/BootLoader.java
浏览文件 @
cb72a052
...
...
@@ -187,6 +187,14 @@ public class BootLoader {
.
map
(
name
->
getDefinedPackage
(
name
.
replace
(
'/'
,
'.'
)));
}
/**
* Returns {@code true} if there is a class path associated with the
* BootLoader.
*/
public
static
boolean
hasClassPath
()
{
return
ClassLoaders
.
bootLoader
().
hasClassPath
();
}
/**
* Helper class to define {@code Package} objects for packages in modules
* defined to the boot loader.
...
...
jdk/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java
浏览文件 @
cb72a052
...
...
@@ -425,7 +425,7 @@ public class BuiltinClassLoader
* Returns a URL to a resource on the class path.
*/
private
URL
findResourceOnClassPath
(
String
name
)
{
if
(
ucp
!=
null
)
{
if
(
hasClassPath
()
)
{
if
(
System
.
getSecurityManager
()
==
null
)
{
return
ucp
.
findResource
(
name
,
false
);
}
else
{
...
...
@@ -442,7 +442,7 @@ public class BuiltinClassLoader
* Returns the URLs of all resources of the given name on the class path.
*/
private
Enumeration
<
URL
>
findResourcesOnClassPath
(
String
name
)
{
if
(
ucp
!=
null
)
{
if
(
hasClassPath
()
)
{
if
(
System
.
getSecurityManager
()
==
null
)
{
return
ucp
.
findResources
(
name
,
false
);
}
else
{
...
...
@@ -481,7 +481,7 @@ public class BuiltinClassLoader
}
else
{
// search class path
if
(
ucp
!=
null
)
{
if
(
hasClassPath
()
)
{
c
=
findClassOnClassPathOrNull
(
cn
);
}
...
...
@@ -514,7 +514,7 @@ public class BuiltinClassLoader
}
// search class path
if
(
ucp
!=
null
)
{
if
(
hasClassPath
()
)
{
return
findClassOnClassPathOrNull
(
cn
);
}
...
...
@@ -569,7 +569,7 @@ public class BuiltinClassLoader
}
// check class path
if
(
c
==
null
&&
ucp
!=
null
&&
VM
.
isModuleSystemInited
())
{
if
(
c
==
null
&&
hasClassPath
()
&&
VM
.
isModuleSystemInited
())
{
c
=
findClassOnClassPathOrNull
(
cn
);
}
}
...
...
@@ -869,6 +869,14 @@ public class BuiltinClassLoader
sealBase
);
}
/**
* Returns {@code true} if there is a class path associated with this
* class loader.
*/
boolean
hasClassPath
()
{
return
ucp
!=
null
;
}
/**
* Returns {@code true} if the specified package name is sealed according to
* the given manifest.
...
...
jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Exchange.java
浏览文件 @
cb72a052
...
...
@@ -133,11 +133,13 @@ final class Exchange<T> {
}
public
T
readBody
(
HttpResponse
.
BodyHandler
<
T
>
responseHandler
)
throws
IOException
{
return
exchImpl
.
readBody
(
responseHandler
,
true
);
// The connection will not be returned to the pool in the case of WebSocket
return
exchImpl
.
readBody
(
responseHandler
,
!
request
.
isWebSocket
());
}
public
CompletableFuture
<
T
>
readBodyAsync
(
HttpResponse
.
BodyHandler
<
T
>
handler
)
{
return
exchImpl
.
readBodyAsync
(
handler
,
true
,
parentExecutor
);
// The connection will not be returned to the pool in the case of WebSocket
return
exchImpl
.
readBodyAsync
(
handler
,
!
request
.
isWebSocket
(),
parentExecutor
);
}
public
void
cancel
()
{
...
...
jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/ExchangeImpl.java
浏览文件 @
cb72a052
...
...
@@ -117,11 +117,11 @@ abstract class ExchangeImpl<T> {
*/
abstract
Response
getResponse
()
throws
IOException
;
abstract
T
readBody
(
HttpResponse
.
BodyHandler
<
T
>
handler
,
boolean
returnToCache
)
throws
IOException
;
abstract
T
readBody
(
HttpResponse
.
BodyHandler
<
T
>
handler
,
boolean
returnConnectionToPool
)
throws
IOException
;
abstract
CompletableFuture
<
T
>
readBodyAsync
(
HttpResponse
.
BodyHandler
<
T
>
handler
,
boolean
return
ToCache
,
boolean
return
ConnectionToPool
,
Executor
executor
);
// Builtin processors need access to HttpClientImpl
...
...
jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http1Exchange.java
浏览文件 @
cb72a052
...
...
@@ -88,14 +88,14 @@ class Http1Exchange<T> extends ExchangeImpl<T> {
@Override
T
readBody
(
BodyHandler
<
T
>
handler
,
boolean
return
ToCache
)
T
readBody
(
BodyHandler
<
T
>
handler
,
boolean
return
ConnectionToPool
)
throws
IOException
{
BodyProcessor
<
T
>
processor
=
handler
.
apply
(
response
.
responseCode
(),
response
.
responseHeaders
());
setClientForResponse
(
processor
);
CompletableFuture
<
T
>
bodyCF
=
response
.
readBody
(
processor
,
return
ToCache
,
return
ConnectionToPool
,
this
::
executeInline
);
try
{
return
bodyCF
.
join
();
...
...
@@ -114,14 +114,14 @@ class Http1Exchange<T> extends ExchangeImpl<T> {
@Override
CompletableFuture
<
T
>
readBodyAsync
(
BodyHandler
<
T
>
handler
,
boolean
return
ToCache
,
boolean
return
ConnectionToPool
,
Executor
executor
)
{
BodyProcessor
<
T
>
processor
=
handler
.
apply
(
response
.
responseCode
(),
response
.
responseHeaders
());
setClientForResponse
(
processor
);
CompletableFuture
<
T
>
bodyCF
=
response
.
readBody
(
processor
,
return
ToCache
,
return
ConnectionToPool
,
executor
);
return
bodyCF
;
}
...
...
jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http1Response.java
浏览文件 @
cb72a052
...
...
@@ -164,6 +164,7 @@ class Http1Response<T> {
private
void
onFinished
()
{
if
(
return2Cache
)
{
Log
.
logTrace
(
"Returning connection to the pool: {0}"
,
connection
);
connection
.
returnToCache
(
headers
);
}
}
...
...
jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpConnection.java
浏览文件 @
cb72a052
...
...
@@ -115,7 +115,7 @@ abstract class HttpConnection implements Closeable {
}
/* Returns either a plain HTTP connection or a plain tunnelling connection
* for proxied
websockets
*/
* for proxied
WebSocket
*/
private
static
HttpConnection
getPlainConnection
(
InetSocketAddress
addr
,
InetSocketAddress
proxy
,
HttpRequestImpl
request
,
...
...
jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpRequestImpl.java
浏览文件 @
cb72a052
...
...
@@ -81,6 +81,7 @@ class HttpRequestImpl extends HttpRequest implements WebSocketRequest {
this
.
userHeaders
=
request
.
headers
();
if
(
request
instanceof
HttpRequestImpl
)
{
this
.
systemHeaders
=
((
HttpRequestImpl
)
request
).
systemHeaders
;
this
.
isWebSocket
=
((
HttpRequestImpl
)
request
).
isWebSocket
;
}
else
{
this
.
systemHeaders
=
new
HttpHeadersImpl
();
}
...
...
@@ -102,6 +103,7 @@ class HttpRequestImpl extends HttpRequest implements WebSocketRequest {
HttpRequestImpl
other
)
{
this
.
method
=
method
==
null
?
"GET"
:
method
;
this
.
userHeaders
=
other
.
userHeaders
;
this
.
isWebSocket
=
other
.
isWebSocket
;
this
.
systemHeaders
=
other
.
systemHeaders
;
this
.
uri
=
uri
;
this
.
expectContinue
=
other
.
expectContinue
;
...
...
@@ -115,6 +117,9 @@ class HttpRequestImpl extends HttpRequest implements WebSocketRequest {
/* used for creating CONNECT requests */
HttpRequestImpl
(
String
method
,
HttpClientImpl
client
,
InetSocketAddress
authority
)
{
// TODO: isWebSocket flag is not specified, but the assumption is that
// such a request will never be made on a connection that will be returned
// to the connection pool (we might need to revisit this constructor later)
this
.
method
=
method
;
this
.
systemHeaders
=
new
HttpHeadersImpl
();
this
.
userHeaders
=
ImmutableHeaders
.
empty
();
...
...
jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/PlainTunnelingConnection.java
浏览文件 @
cb72a052
...
...
@@ -36,7 +36,7 @@ import java.util.concurrent.CompletableFuture;
/**
* A plain text socket tunnel through a proxy. Uses "CONNECT" but does not
* encrypt. Used by WebSocket
s
. Subclassed in SSLTunnelConnection for encryption.
* encrypt. Used by WebSocket. Subclassed in SSLTunnelConnection for encryption.
*/
class
PlainTunnelingConnection
extends
HttpConnection
{
...
...
jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Stream.java
浏览文件 @
cb72a052
...
...
@@ -148,7 +148,7 @@ class Stream<T> extends ExchangeImpl<T> {
@Override
CompletableFuture
<
T
>
readBodyAsync
(
HttpResponse
.
BodyHandler
<
T
>
handler
,
boolean
return
ToCache
,
boolean
return
ConnectionToPool
,
Executor
executor
)
{
Log
.
logTrace
(
"Reading body on stream {0}"
,
streamid
);
...
...
@@ -166,11 +166,11 @@ class Stream<T> extends ExchangeImpl<T> {
}
@Override
T
readBody
(
HttpResponse
.
BodyHandler
<
T
>
handler
,
boolean
return
ToCache
)
T
readBody
(
HttpResponse
.
BodyHandler
<
T
>
handler
,
boolean
return
ConnectionToPool
)
throws
IOException
{
CompletableFuture
<
T
>
cf
=
readBodyAsync
(
handler
,
return
ToCache
,
return
ConnectionToPool
,
null
);
try
{
return
cf
.
join
();
...
...
@@ -871,10 +871,10 @@ class Stream<T> extends ExchangeImpl<T> {
@Override
CompletableFuture
<
T
>
readBodyAsync
(
HttpResponse
.
BodyHandler
<
T
>
handler
,
boolean
return
ToCache
,
boolean
return
ConnectionToPool
,
Executor
executor
)
{
return
super
.
readBodyAsync
(
handler
,
return
ToCache
,
executor
)
return
super
.
readBodyAsync
(
handler
,
return
ConnectionToPool
,
executor
)
.
whenComplete
((
v
,
t
)
->
pushGroup
.
pushError
(
t
));
}
...
...
jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModuleSorter.java
浏览文件 @
cb72a052
...
...
@@ -30,6 +30,8 @@ import jdk.tools.jlink.plugin.ResourcePoolModule;
import
jdk.tools.jlink.plugin.ResourcePoolModuleView
;
import
java.lang.module.ModuleDescriptor
;
import
java.lang.module.ModuleDescriptor.Requires.Modifier
;
import
java.nio.ByteBuffer
;
import
java.util.Deque
;
import
java.util.HashMap
;
...
...
@@ -67,14 +69,15 @@ public final class ModuleSorter {
private
ModuleSorter
addModule
(
ResourcePoolModule
module
)
{
addNode
(
module
);
readModuleDescriptor
(
module
).
requires
().
stream
()
.
forEach
(
req
->
{
String
dm
=
req
.
name
();
ResourcePoolModule
dep
=
moduleView
.
findModule
(
dm
)
.
orElseThrow
(()
->
new
PluginException
(
dm
+
" not found"
));
readModuleDescriptor
(
module
).
requires
().
forEach
(
req
->
{
ResourcePoolModule
dep
=
moduleView
.
findModule
(
req
.
name
()).
orElse
(
null
);
if
(
dep
!=
null
)
{
addNode
(
dep
);
edges
.
get
(
module
.
name
()).
add
(
dep
);
});
}
else
if
(!
req
.
modifiers
().
contains
(
Modifier
.
STATIC
))
{
throw
new
PluginException
(
req
.
name
()
+
" not found"
);
}
});
return
this
;
}
...
...
@@ -113,7 +116,7 @@ public final class ModuleSorter {
return
;
}
visited
.
add
(
node
);
edges
.
get
(
node
.
name
())
.
stream
()
edges
.
get
(
node
.
name
())
.
forEach
(
x
->
visit
(
x
,
visited
,
done
));
done
.
add
(
node
);
result
.
addLast
(
node
);
...
...
jdk/test/ProblemList.txt
浏览文件 @
cb72a052
...
...
@@ -309,8 +309,6 @@ com/sun/jndi/ldap/DeadSSLLdapTimeoutTest.java 8169942 linux-i5
javax/rmi/PortableRemoteObject/8146975/RmiIiopReturnValueTest.java 8169737 linux-all
javax/xml/ws/clientjar/TestWsImport.java 8173317 generic-all
org/omg/CORBA/OrbPropertiesTest.java 8175177 generic-all
############################################################################
jdk/test/java/net/httpclient/websocket/ConnectionHandover.java
0 → 100644
浏览文件 @
cb72a052
/*
* Copyright (c) 2017, 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
jdk.incubator.http.HttpClient
;
import
jdk.incubator.http.WebSocket
;
import
java.io.IOException
;
import
java.net.URI
;
/*
* @test
* @bug 8164625
* @summary Verifies HttpClient yields the connection to the WebSocket
* @run main/othervm -Djdk.httpclient.HttpClient.log=trace ConnectionHandover
*/
public
class
ConnectionHandover
{
static
{
LoggingHelper
.
setupLogging
();
}
/*
* An I/O channel associated with the connection is closed by WebSocket.abort().
* If this connection is returned to the connection pool, then the second
* attempt to use it would fail with a ClosedChannelException.
*
* The assumption is that since the WebSocket client is connecting to the
* same URI, the pooled connection is to be used.
*/
public
static
void
main
(
String
[]
args
)
throws
IOException
{
try
(
DummyWebSocketServer
server
=
new
DummyWebSocketServer
())
{
server
.
open
();
URI
uri
=
server
.
getURI
();
WebSocket
.
Builder
webSocketBuilder
=
HttpClient
.
newHttpClient
().
newWebSocketBuilder
(
uri
,
new
WebSocket
.
Listener
()
{
});
WebSocket
ws1
=
webSocketBuilder
.
buildAsync
().
join
();
try
{
ws1
.
abort
();
}
catch
(
IOException
ignored
)
{
}
WebSocket
ws2
=
webSocketBuilder
.
buildAsync
().
join
();
// Exception here if the connection was pooled
try
{
ws2
.
abort
();
}
catch
(
IOException
ignored
)
{
}
}
}
}
jdk/test/java/net/httpclient/
HandshakePhase
.java
→
jdk/test/java/net/httpclient/
websocket/DummyWebSocketServer
.java
浏览文件 @
cb72a052
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016,
2017,
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
...
...
@@ -21,16 +21,17 @@
* questions.
*/
import
java.io.Closeable
;
import
java.io.IOException
;
import
java.io.UncheckedIOException
;
import
java.net.InetSocketAddress
;
import
java.net.URI
;
import
java.nio.ByteBuffer
;
import
java.nio.CharBuffer
;
import
java.nio.channels.ClosedByInterruptException
;
import
java.nio.channels.ServerSocketChannel
;
import
java.nio.channels.SocketChannel
;
import
java.nio.charset.CharacterCodingException
;
import
java.nio.charset.StandardCharsets
;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.Arrays
;
...
...
@@ -40,81 +41,167 @@ import java.util.Iterator;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.
CompletableFuture
;
import
java.util.concurrent.
atomic.AtomicBoolean
;
import
java.util.function.Function
;
import
java.util.regex.Pattern
;
import
java.util.stream.Collectors
;
import
static
java
.
lang
.
String
.
format
;
import
static
java
.
lang
.
System
.
Logger
.
Level
.
ERROR
;
import
static
java
.
lang
.
System
.
Logger
.
Level
.
INFO
;
import
static
java
.
lang
.
System
.
Logger
.
Level
.
TRACE
;
import
static
java
.
nio
.
charset
.
StandardCharsets
.
ISO_8859_1
;
import
static
java
.
util
.
Arrays
.
asList
;
import
static
java
.
util
.
Objects
.
requireNonNull
;
//
// Performs a simple opening handshake and yields the channel.
//
// Client Request:
//
// GET /chat HTTP/1.1
// Host: server.example.com
// Upgrade: websocket
// Connection: Upgrade
// Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
// Origin: http://example.com
// Sec-WebSocket-Protocol: chat, superchat
// Sec-WebSocket-Version: 13
//
//
// Server Response:
//
// HTTP/1.1 101 Switching Protocols
// Upgrade: websocket
// Connection: Upgrade
// Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
// Sec-WebSocket-Protocol: chat
//
final
class
HandshakePhase
{
/**
* Dummy WebSocket Server.
*
* Performs simpler version of the WebSocket Opening Handshake over HTTP (i.e.
* no proxying, cookies, etc.) Supports sequential connections, one at a time,
* i.e. in order for a client to connect to the server the previous client must
* disconnect first.
*
* Expected client request:
*
* GET /chat HTTP/1.1
* Host: server.example.com
* Upgrade: websocket
* Connection: Upgrade
* Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
* Origin: http://example.com
* Sec-WebSocket-Protocol: chat, superchat
* Sec-WebSocket-Version: 13
*
* This server response:
*
* HTTP/1.1 101 Switching Protocols
* Upgrade: websocket
* Connection: Upgrade
* Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
* Sec-WebSocket-Protocol: chat
*/
public
final
class
DummyWebSocketServer
implements
Closeable
{
private
final
ServerSocketChannel
ssc
;
private
final
static
System
.
Logger
log
=
System
.
getLogger
(
DummyWebSocketServer
.
class
.
getName
());
private
final
AtomicBoolean
started
=
new
AtomicBoolean
();
private
final
Thread
thread
;
private
volatile
ServerSocketChannel
ssc
;
private
volatile
InetSocketAddress
address
;
HandshakePhase
(
InetSocketAddress
address
)
{
requireNonNull
(
address
);
try
{
ssc
=
ServerSocketChannel
.
open
();
ssc
.
bind
(
address
);
}
catch
(
IOException
e
)
{
throw
new
UncheckedIOException
(
e
);
}
public
DummyWebSocketServer
()
{
this
(
defaultMapping
());
}
//
// Returned CF completes normally after the handshake has been performed
//
CompletableFuture
<
SocketChannel
>
afterHandshake
(
Function
<
List
<
String
>,
List
<
String
>>
mapping
)
{
return
CompletableFuture
.
supplyAsync
(
()
->
{
SocketChannel
socketChannel
=
accept
(
);
public
DummyWebSocketServer
(
Function
<
List
<
String
>,
List
<
String
>>
mapping
)
{
requireNonNull
(
mapping
);
thread
=
new
Thread
(()
->
{
try
{
while
(!
Thread
.
currentThread
().
isInterrupted
()
)
{
log
.
log
(
INFO
,
"Accepting next connection at: "
+
ssc
);
SocketChannel
channel
=
ssc
.
accept
();
log
.
log
(
INFO
,
"Accepted: "
+
channel
);
try
{
channel
.
configureBlocking
(
true
);
StringBuilder
request
=
new
StringBuilder
();
if
(!
readRequest
(
socketC
hannel
,
request
))
{
throw
new
I
llegalStateException
(
);
if
(!
readRequest
(
c
hannel
,
request
))
{
throw
new
I
OException
(
"Bad request"
);
}
List
<
String
>
strings
=
Arrays
.
asList
(
request
.
toString
().
split
(
"\r\n"
)
);
List
<
String
>
strings
=
asList
(
request
.
toString
().
split
(
"\r\n"
));
List
<
String
>
response
=
mapping
.
apply
(
strings
);
writeResponse
(
socketChannel
,
response
);
return
socketChannel
;
}
catch
(
Throwable
t
)
{
try
{
socketChannel
.
close
();
}
catch
(
IOException
ignored
)
{
}
throw
t
;
writeResponse
(
channel
,
response
);
// Read until the thread is interrupted or an error occurred
// or the input is shutdown
ByteBuffer
b
=
ByteBuffer
.
allocate
(
1024
);
while
(
channel
.
read
(
b
)
!=
-
1
)
{
b
.
clear
();
}
}
catch
(
IOException
e
)
{
log
.
log
(
TRACE
,
()
->
"Error in connection: "
+
channel
,
e
);
}
finally
{
log
.
log
(
INFO
,
"Closed: "
+
channel
);
close
(
channel
);
}
});
}
}
catch
(
ClosedByInterruptException
ignored
)
{
}
catch
(
IOException
e
)
{
log
.
log
(
ERROR
,
e
);
}
finally
{
close
(
ssc
);
log
.
log
(
INFO
,
"Stopped at: "
+
getURI
());
}
});
thread
.
setName
(
"DummyWebSocketServer"
);
thread
.
setDaemon
(
false
);
}
public
void
open
()
throws
IOException
{
log
.
log
(
INFO
,
"Starting"
);
if
(!
started
.
compareAndSet
(
false
,
true
))
{
throw
new
IllegalStateException
(
"Already started"
);
}
ssc
=
ServerSocketChannel
.
open
();
try
{
ssc
.
configureBlocking
(
true
);
ssc
.
bind
(
new
InetSocketAddress
(
"localhost"
,
0
));
address
=
(
InetSocketAddress
)
ssc
.
getLocalAddress
();
thread
.
start
();
}
catch
(
IOException
e
)
{
close
(
ssc
);
}
log
.
log
(
INFO
,
"Started at: "
+
getURI
());
}
CompletableFuture
<
SocketChannel
>
afterHandshake
()
{
return
afterHandshake
((
request
)
->
{
@Override
public
void
close
()
{
log
.
log
(
INFO
,
"Stopping: "
+
getURI
());
thread
.
interrupt
();
}
URI
getURI
()
{
if
(!
started
.
get
())
{
throw
new
IllegalStateException
(
"Not yet started"
);
}
return
URI
.
create
(
"ws://"
+
address
.
getHostName
()
+
":"
+
address
.
getPort
());
}
private
boolean
readRequest
(
SocketChannel
channel
,
StringBuilder
request
)
throws
IOException
{
ByteBuffer
buffer
=
ByteBuffer
.
allocate
(
512
);
int
num
=
channel
.
read
(
buffer
);
if
(
num
==
-
1
)
{
return
false
;
}
CharBuffer
decoded
;
buffer
.
flip
();
try
{
decoded
=
ISO_8859_1
.
newDecoder
().
decode
(
buffer
);
}
catch
(
CharacterCodingException
e
)
{
throw
new
UncheckedIOException
(
e
);
}
request
.
append
(
decoded
);
return
Pattern
.
compile
(
"\r\n\r\n"
).
matcher
(
request
).
find
();
}
private
void
writeResponse
(
SocketChannel
channel
,
List
<
String
>
response
)
throws
IOException
{
String
s
=
response
.
stream
().
collect
(
Collectors
.
joining
(
"\r\n"
))
+
"\r\n\r\n"
;
ByteBuffer
encoded
;
try
{
encoded
=
ISO_8859_1
.
newEncoder
().
encode
(
CharBuffer
.
wrap
(
s
));
}
catch
(
CharacterCodingException
e
)
{
throw
new
UncheckedIOException
(
e
);
}
while
(
encoded
.
hasRemaining
())
{
channel
.
write
(
encoded
);
}
}
private
static
Function
<
List
<
String
>,
List
<
String
>>
defaultMapping
()
{
return
request
->
{
List
<
String
>
response
=
new
LinkedList
<>();
Iterator
<
String
>
iterator
=
request
.
iterator
();
if
(!
iterator
.
hasNext
())
{
...
...
@@ -132,7 +219,7 @@ final class HandshakePhase {
if
(
split
.
length
!=
2
)
{
throw
new
IllegalStateException
(
"Unexpected header: "
+
header
+
", split="
+
Arrays
.
toString
(
split
));
+
", split="
+
Arrays
.
toString
(
split
));
}
if
(
requestHeaders
.
put
(
split
[
0
],
split
[
1
])
!=
null
)
{
throw
new
IllegalStateException
...
...
@@ -161,105 +248,31 @@ final class HandshakePhase {
throw
new
InternalError
(
e
);
}
String
x
=
key
+
"258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
;
sha1
.
update
(
x
.
getBytes
(
StandardCharsets
.
ISO_8859_1
));
sha1
.
update
(
x
.
getBytes
(
ISO_8859_1
));
String
v
=
Base64
.
getEncoder
().
encodeToString
(
sha1
.
digest
());
response
.
add
(
"Sec-WebSocket-Accept: "
+
v
);
return
response
;
}
)
;
};
}
pr
ivate
String
expectHeader
(
Map
<
String
,
String
>
headers
,
String
name
,
String
value
)
{
pr
otected
static
String
expectHeader
(
Map
<
String
,
String
>
headers
,
String
name
,
String
value
)
{
String
v
=
headers
.
get
(
name
);
if
(!
value
.
equals
(
v
))
{
throw
new
IllegalStateException
(
format
(
"Expected '%s: %s', actual: '%s: %s'"
,
name
,
value
,
name
,
v
)
name
,
value
,
name
,
v
)
);
}
return
v
;
}
URI
getURI
()
{
InetSocketAddress
a
;
try
{
a
=
(
InetSocketAddress
)
ssc
.
getLocalAddress
();
}
catch
(
IOException
e
)
{
throw
new
UncheckedIOException
(
e
);
}
return
URI
.
create
(
"ws://"
+
a
.
getHostName
()
+
":"
+
a
.
getPort
());
}
private
int
read
(
SocketChannel
socketChannel
,
ByteBuffer
buffer
)
{
try
{
int
num
=
socketChannel
.
read
(
buffer
);
if
(
num
==
-
1
)
{
throw
new
IllegalStateException
(
"Unexpected EOF"
);
}
assert
socketChannel
.
isBlocking
()
&&
num
>
0
;
return
num
;
}
catch
(
IOException
e
)
{
throw
new
UncheckedIOException
(
e
);
}
}
private
SocketChannel
accept
()
{
SocketChannel
socketChannel
=
null
;
try
{
socketChannel
=
ssc
.
accept
();
socketChannel
.
configureBlocking
(
true
);
}
catch
(
IOException
e
)
{
if
(
socketChannel
!=
null
)
{
try
{
socketChannel
.
close
();
}
catch
(
IOException
ignored
)
{
}
}
throw
new
UncheckedIOException
(
e
);
}
return
socketChannel
;
}
private
boolean
readRequest
(
SocketChannel
socketChannel
,
StringBuilder
request
)
{
ByteBuffer
buffer
=
ByteBuffer
.
allocateDirect
(
512
);
read
(
socketChannel
,
buffer
);
CharBuffer
decoded
;
buffer
.
flip
();
try
{
decoded
=
StandardCharsets
.
ISO_8859_1
.
newDecoder
().
decode
(
buffer
);
}
catch
(
CharacterCodingException
e
)
{
throw
new
UncheckedIOException
(
e
);
}
request
.
append
(
decoded
);
return
Pattern
.
compile
(
"\r\n\r\n"
).
matcher
(
request
).
find
();
}
private
void
writeResponse
(
SocketChannel
socketChannel
,
List
<
String
>
response
)
{
String
s
=
response
.
stream
().
collect
(
Collectors
.
joining
(
"\r\n"
))
+
"\r\n\r\n"
;
ByteBuffer
encoded
;
try
{
encoded
=
StandardCharsets
.
ISO_8859_1
.
newEncoder
().
encode
(
CharBuffer
.
wrap
(
s
));
}
catch
(
CharacterCodingException
e
)
{
throw
new
UncheckedIOException
(
e
);
}
write
(
socketChannel
,
encoded
);
}
private
void
write
(
SocketChannel
socketChannel
,
ByteBuffer
buffer
)
{
try
{
while
(
buffer
.
hasRemaining
())
{
socketChannel
.
write
(
buffer
);
}
}
catch
(
IOException
e
)
{
private
static
void
close
(
AutoCloseable
...
acs
)
{
for
(
AutoCloseable
ac
:
acs
)
{
try
{
socketChannel
.
close
();
}
catch
(
IOException
ignored
)
{
}
throw
new
UncheckedIOException
(
e
);
ac
.
close
();
}
catch
(
Exception
ignored
)
{
}
}
}
}
jdk/test/java/net/httpclient/websocket/LoggingHelper.java
0 → 100644
浏览文件 @
cb72a052
/*
* Copyright (c) 2017, 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.File
;
public
final
class
LoggingHelper
{
/*
* I wish we had a support for java.util.logging in jtreg similar to what we
* have for security policy files:
*
* @run main/othervm/jul=logging.properties ClassUnderTest
*/
public
static
void
setupLogging
()
{
String
path
=
System
.
getProperty
(
"test.src"
)
+
File
.
separator
+
"logging.properties"
;
System
.
setProperty
(
"java.util.logging.config.file"
,
path
);
}
}
jdk/test/java/net/httpclient/websocket/logging.properties
0 → 100644
浏览文件 @
cb72a052
handlers
=
java.util.logging.ConsoleHandler
.level
=
ALL
java.util.logging.ConsoleHandler.level
=
ALL
java.util.logging.ConsoleHandler.formatter
=
java.util.logging.SimpleFormatter
java.util.logging.SimpleFormatter.format
=
%4$s: %5$s [%1$tc]%n
jdk/test/java/nio/file/WatchService/LotsOfEvents.java
浏览文件 @
cb72a052
/*
* Copyright (c) 2010, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 201
7
, 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,22 +23,25 @@
/* @test
* @bug 6907760 6929532
* @summary Tests WatchService behavior when lots of events are pending
* @summary Tests WatchService behavior when lots of events are pending
(use -Dseed=X to set PRNG seed)
* @library ..
* @library /lib/testlibrary/
* @build jdk.testlibrary.*
* @run main/timeout=180 LotsOfEvents
* @key randomness
*/
import
java.nio.file.*
;
import
static
java
.
nio
.
file
.
StandardWatchEventKinds
.*;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.nio.file.*
;
import
static
java
.
nio
.
file
.
StandardWatchEventKinds
.*;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
jdk.testlibrary.RandomFactory
;
public
class
LotsOfEvents
{
static
final
Random
rand
=
new
Random
();
private
static
final
Random
RAND
=
RandomFactory
.
get
Random
();
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Path
dir
=
TestUtil
.
createTemporaryDirectory
();
...
...
@@ -70,7 +73,7 @@ public class LotsOfEvents {
Thread
.
sleep
(
1000
);
// check that we see the create events (or overflow)
drainAndCheckOverflowEvents
(
watcher
,
ENTRY_CREATE
,
n
);
drainAndCheckOverflowEvents
(
dir
,
watcher
,
ENTRY_CREATE
,
n
);
// delete the files
for
(
int
i
=
0
;
i
<
n
;
i
++)
{
...
...
@@ -81,11 +84,12 @@ public class LotsOfEvents {
Thread
.
sleep
(
1000
);
// check that we see the delete events (or overflow)
drainAndCheckOverflowEvents
(
watcher
,
ENTRY_DELETE
,
n
);
drainAndCheckOverflowEvents
(
dir
,
watcher
,
ENTRY_DELETE
,
n
);
}
}
static
void
drainAndCheckOverflowEvents
(
WatchService
watcher
,
static
void
drainAndCheckOverflowEvents
(
Path
dir
,
WatchService
watcher
,
WatchEvent
.
Kind
<?>
expectedKind
,
int
count
)
throws
IOException
,
InterruptedException
...
...
@@ -123,8 +127,25 @@ public class LotsOfEvents {
}
// check that all expected events were received or there was an overflow
if
(
nread
<
count
&&
!
gotOverflow
)
throw
new
RuntimeException
(
"Insufficient events"
);
if
(
nread
<
count
&&
!
gotOverflow
)
{
System
.
err
.
printf
(
"Test directory %s contains %d files%n"
,
dir
,
Files
.
list
(
dir
).
count
());
long
timeBeforePoll
=
System
.
nanoTime
();
key
=
watcher
.
poll
(
15
,
TimeUnit
.
SECONDS
);
long
timeAfterPoll
=
System
.
nanoTime
();
if
(
key
==
null
)
{
System
.
err
.
println
(
"key still null after extra polling"
);
}
else
{
List
<
WatchEvent
<?>>
events
=
key
.
pollEvents
();
System
.
err
.
printf
(
"Retrieved key with %d events after %d ns%n"
,
events
.
size
(),
timeAfterPoll
-
timeBeforePoll
);
}
throw
new
RuntimeException
(
"Insufficient "
+
expectedKind
.
name
()
+
" events: expected "
+
count
+
", received "
+
nread
);
}
}
/**
...
...
@@ -134,14 +155,14 @@ public class LotsOfEvents {
throws
IOException
,
InterruptedException
{
// this test uses a random number of files
final
int
nfiles
=
5
+
rand
.
nextInt
(
10
);
final
int
nfiles
=
5
+
RAND
.
nextInt
(
10
);
DirectoryEntry
[]
entries
=
new
DirectoryEntry
[
nfiles
];
for
(
int
i
=
0
;
i
<
nfiles
;
i
++)
{
entries
[
i
]
=
new
DirectoryEntry
(
dir
.
resolve
(
"foo"
+
i
));
// "some" of the files exist, some do not.
entries
[
i
].
deleteIfExists
();
if
(
rand
.
nextBoolean
())
if
(
RAND
.
nextBoolean
())
entries
[
i
].
create
();
}
...
...
@@ -153,8 +174,8 @@ public class LotsOfEvents {
// make some noise!!!
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
DirectoryEntry
entry
=
entries
[
rand
.
nextInt
(
nfiles
)];
int
action
=
rand
.
nextInt
(
10
);
DirectoryEntry
entry
=
entries
[
RAND
.
nextInt
(
nfiles
)];
int
action
=
RAND
.
nextInt
(
10
);
switch
(
action
)
{
case
0
:
entry
.
create
();
break
;
case
1
:
entry
.
deleteIfExists
();
break
;
...
...
jdk/test/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java
浏览文件 @
cb72a052
...
...
@@ -64,7 +64,7 @@ public class UserModuleTest {
private
static
final
String
MAIN_MID
=
"m1/p1.Main"
;
// the names of the modules in this test
private
static
String
[]
modules
=
new
String
[]
{
"m1"
,
"m2"
,
"m3"
,
"m4"
};
private
static
String
[]
modules
=
new
String
[]
{
"m1"
,
"m2"
,
"m3"
,
"m4"
,
"m5"
};
private
static
boolean
hasJmods
()
{
...
...
@@ -160,6 +160,50 @@ public class UserModuleTest {
.
getExitValue
()
==
0
);
}
@Test
public
void
testRequiresStatic
()
throws
Throwable
{
if
(!
hasJmods
())
return
;
Path
dir
=
Paths
.
get
(
"requiresStatic"
);
createImage
(
dir
,
"m5"
);
Path
java
=
dir
.
resolve
(
"bin"
).
resolve
(
"java"
);
assertTrue
(
executeProcess
(
java
.
toString
(),
"-m"
,
"m5/p5.Main"
)
.
outputTo
(
System
.
out
)
.
errorTo
(
System
.
out
)
.
getExitValue
()
==
0
);
// run with m3 present
assertTrue
(
executeProcess
(
java
.
toString
(),
"--module-path"
,
MODS_DIR
.
toString
(),
"--add-modules"
,
"m3"
,
"-m"
,
"m5/p5.Main"
)
.
outputTo
(
System
.
out
)
.
errorTo
(
System
.
out
)
.
getExitValue
()
==
0
);
}
@Test
public
void
testRequiresStatic2
()
throws
Throwable
{
if
(!
hasJmods
())
return
;
Path
dir
=
Paths
.
get
(
"requiresStatic2"
);
createImage
(
dir
,
"m3"
,
"m5"
);
Path
java
=
dir
.
resolve
(
"bin"
).
resolve
(
"java"
);
assertTrue
(
executeProcess
(
java
.
toString
(),
"-m"
,
"m5/p5.Main"
)
.
outputTo
(
System
.
out
)
.
errorTo
(
System
.
out
)
.
getExitValue
()
==
0
);
// boot layer with m3 and m5
assertTrue
(
executeProcess
(
java
.
toString
(),
"--add-modules"
,
"m3"
,
"-m"
,
"m5/p5.Main"
)
.
outputTo
(
System
.
out
)
.
errorTo
(
System
.
out
)
.
getExitValue
()
==
0
);
}
private
void
createJmods
(
String
...
modules
)
throws
IOException
{
// use the same target platform as in java.base
ModuleDescriptor
md
=
Layer
.
boot
().
findModule
(
"java.base"
).
get
()
...
...
jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m3/module-info.java
浏览文件 @
cb72a052
...
...
@@ -23,4 +23,5 @@
module
m3
{
requires
m4
;
exports
p3
;
}
jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m3/p3/Foo.java
0 → 100644
浏览文件 @
cb72a052
/*
* Copyright (c) 2017, 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.
*/
package
p3
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
@Documented
@Target
(
ElementType
.
FIELD
)
@Retention
(
RetentionPolicy
.
SOURCE
)
public
@interface
Foo
{
}
jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m3/p3/Lib.java
0 → 100644
浏览文件 @
cb72a052
/*
* Copyright (c) 2017, 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.
*/
package
p3
;
public
class
Lib
{
public
static
String
concat
(
String
x
,
String
y
)
{
return
x
+
y
;
}
}
jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m5/module-info.java
0 → 100644
浏览文件 @
cb72a052
/*
* Copyright (c) 2017, 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.
*/
module
m5
{
requires
static
m3
;
exports
p5
;
}
jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m5/p5/Main.java
0 → 100644
浏览文件 @
cb72a052
/*
* Copyright (c) 2017, 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.
*/
package
p5
;
import
java.lang.reflect.Layer
;
import
p3.Foo
;
import
p3.Lib
;
/**
* This test verifies jlink support of requires static.
*/
public
class
Main
{
public
static
void
main
(
String
...
args
)
{
boolean
libPresent
=
Layer
.
boot
().
findModule
(
"m3"
).
isPresent
();
if
(
LibHelper
.
libClassFound
!=
libPresent
)
{
throw
new
RuntimeException
(
"Expected module m3 not in the boot layer"
);
}
if
(
libPresent
)
{
// p3.Lib must be present
LibHelper
.
concat
(
"x"
,
"y"
);
}
}
static
class
LibHelper
{
@Foo
static
final
boolean
libClassFound
;
static
{
boolean
found
=
false
;
try
{
Class
<?>
c
=
Class
.
forName
(
"p3.Lib"
);
found
=
true
;
}
catch
(
ClassNotFoundException
e
)
{
}
libClassFound
=
found
;
}
public
static
String
concat
(
String
x
,
String
y
)
{
return
Lib
.
concat
(
x
,
y
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录