Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
4d0e56aa
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看板
You need to sign in or sign up before continuing.
提交
4d0e56aa
编写于
7月 11, 2013
作者:
V
valeriep
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
f027b4ff
63675107
变更
55
展开全部
隐藏空白更改
内联
并排
Showing
55 changed file
with
4265 addition
and
2596 deletion
+4265
-2596
src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java
...hare/classes/com/sun/java/util/jar/pack/UnpackerImpl.java
+1
-1
src/share/classes/com/sun/jmx/mbeanserver/Introspector.java
src/share/classes/com/sun/jmx/mbeanserver/Introspector.java
+38
-14
src/share/classes/com/sun/jmx/mbeanserver/MBeanAnalyzer.java
src/share/classes/com/sun/jmx/mbeanserver/MBeanAnalyzer.java
+6
-1
src/share/classes/com/sun/security/sasl/util/AbstractSaslImpl.java
.../classes/com/sun/security/sasl/util/AbstractSaslImpl.java
+14
-8
src/share/classes/java/io/File.java
src/share/classes/java/io/File.java
+20
-13
src/share/classes/java/lang/management/LockInfo.java
src/share/classes/java/lang/management/LockInfo.java
+3
-3
src/share/classes/java/lang/management/ManagementFactory.java
...share/classes/java/lang/management/ManagementFactory.java
+16
-6
src/share/classes/java/lang/management/MemoryMXBean.java
src/share/classes/java/lang/management/MemoryMXBean.java
+8
-8
src/share/classes/java/lang/management/MemoryNotificationInfo.java
.../classes/java/lang/management/MemoryNotificationInfo.java
+2
-2
src/share/classes/java/lang/management/MemoryPoolMXBean.java
src/share/classes/java/lang/management/MemoryPoolMXBean.java
+7
-7
src/share/classes/java/lang/management/MemoryUsage.java
src/share/classes/java/lang/management/MemoryUsage.java
+4
-6
src/share/classes/java/lang/management/MonitorInfo.java
src/share/classes/java/lang/management/MonitorInfo.java
+3
-3
src/share/classes/java/lang/management/RuntimeMXBean.java
src/share/classes/java/lang/management/RuntimeMXBean.java
+3
-3
src/share/classes/java/lang/management/ThreadInfo.java
src/share/classes/java/lang/management/ThreadInfo.java
+5
-5
src/share/classes/java/lang/management/ThreadMXBean.java
src/share/classes/java/lang/management/ThreadMXBean.java
+5
-5
src/share/classes/java/math/BigDecimal.java
src/share/classes/java/math/BigDecimal.java
+6
-2
src/share/classes/java/net/CookieStore.java
src/share/classes/java/net/CookieStore.java
+3
-1
src/share/classes/java/net/HttpURLPermission.java
src/share/classes/java/net/HttpURLPermission.java
+8
-6
src/share/classes/java/net/Inet4Address.java
src/share/classes/java/net/Inet4Address.java
+2
-2
src/share/classes/java/net/Inet6Address.java
src/share/classes/java/net/Inet6Address.java
+2
-2
src/share/classes/java/net/InetAddress.java
src/share/classes/java/net/InetAddress.java
+2
-3
src/share/classes/java/net/ProtocolFamily.java
src/share/classes/java/net/ProtocolFamily.java
+3
-1
src/share/classes/java/net/SocketOption.java
src/share/classes/java/net/SocketOption.java
+5
-1
src/share/classes/java/net/URI.java
src/share/classes/java/net/URI.java
+7
-7
src/share/classes/java/util/Collections.java
src/share/classes/java/util/Collections.java
+82
-0
src/share/classes/java/util/Formatter.java
src/share/classes/java/util/Formatter.java
+1
-1
src/share/classes/java/util/Spliterator.java
src/share/classes/java/util/Spliterator.java
+3
-2
src/share/classes/java/util/concurrent/ConcurrentHashMap.java
...share/classes/java/util/concurrent/ConcurrentHashMap.java
+2476
-2250
src/share/classes/java/util/concurrent/ConcurrentMap.java
src/share/classes/java/util/concurrent/ConcurrentMap.java
+6
-6
src/share/classes/java/util/concurrent/ConcurrentNavigableMap.java
.../classes/java/util/concurrent/ConcurrentNavigableMap.java
+1
-1
src/share/classes/java/util/stream/AbstractShortCircuitTask.java
...re/classes/java/util/stream/AbstractShortCircuitTask.java
+41
-12
src/share/classes/java/util/stream/AbstractTask.java
src/share/classes/java/util/stream/AbstractTask.java
+41
-67
src/share/classes/java/util/stream/ForEachOps.java
src/share/classes/java/util/stream/ForEachOps.java
+76
-53
src/share/classes/java/util/stream/Nodes.java
src/share/classes/java/util/stream/Nodes.java
+14
-19
src/share/classes/javax/management/JMX.java
src/share/classes/javax/management/JMX.java
+22
-20
src/share/classes/javax/management/MBeanServerInvocationHandler.java
...lasses/javax/management/MBeanServerInvocationHandler.java
+1
-1
src/share/classes/javax/management/MXBean.java
src/share/classes/javax/management/MXBean.java
+5
-3
src/share/classes/javax/management/package.html
src/share/classes/javax/management/package.html
+2
-2
src/share/classes/javax/script/ScriptEngineFactory.java
src/share/classes/javax/script/ScriptEngineFactory.java
+4
-5
src/share/classes/sun/management/ManagementFactoryHelper.java
...share/classes/sun/management/ManagementFactoryHelper.java
+14
-12
test/com/sun/management/HotSpotDiagnosticMXBean/SetVMOption.java
...m/sun/management/HotSpotDiagnosticMXBean/SetVMOption.java
+3
-12
test/java/io/File/CheckPermission.java
test/java/io/File/CheckPermission.java
+379
-0
test/java/io/File/NulFile.java
test/java/io/File/NulFile.java
+6
-1
test/java/io/File/createTempFile/SpecialTempFile.java
test/java/io/File/createTempFile/SpecialTempFile.java
+12
-2
test/java/lang/ref/OOMEInReferenceHandler.java
test/java/lang/ref/OOMEInReferenceHandler.java
+3
-3
test/java/math/BigDecimal/StrippingZerosTest.java
test/java/math/BigDecimal/StrippingZerosTest.java
+11
-2
test/java/util/Collections/UnmodifiableMapEntrySet.java
test/java/util/Collections/UnmodifiableMapEntrySet.java
+164
-0
test/javax/management/MBeanServer/MBeanFallbackTest.java
test/javax/management/MBeanServer/MBeanFallbackTest.java
+94
-0
test/javax/management/MBeanServer/MBeanTest.java
test/javax/management/MBeanServer/MBeanTest.java
+158
-0
test/javax/management/mxbean/MXBeanFallbackTest.java
test/javax/management/mxbean/MXBeanFallbackTest.java
+85
-0
test/javax/management/mxbean/MXBeanTest.java
test/javax/management/mxbean/MXBeanTest.java
+52
-2
test/javax/management/proxy/JMXProxyFallbackTest.java
test/javax/management/proxy/JMXProxyFallbackTest.java
+100
-0
test/javax/management/proxy/JMXProxyTest.java
test/javax/management/proxy/JMXProxyTest.java
+191
-0
test/sun/security/krb5/auto/SaslGSS.java
test/sun/security/krb5/auto/SaslGSS.java
+39
-8
test/sun/security/pkcs11/Signature/TestRSAKeyLength.java
test/sun/security/pkcs11/Signature/TestRSAKeyLength.java
+6
-2
未找到文件。
src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java
浏览文件 @
4d0e56aa
...
@@ -134,7 +134,7 @@ public class UnpackerImpl extends TLGlobals implements Pack200.Unpacker {
...
@@ -134,7 +134,7 @@ public class UnpackerImpl extends TLGlobals implements Pack200.Unpacker {
}
else
{
}
else
{
try
{
try
{
(
new
NativeUnpack
(
this
)).
run
(
in0
,
out
);
(
new
NativeUnpack
(
this
)).
run
(
in0
,
out
);
}
catch
(
UnsatisfiedLinkError
ule
)
{
}
catch
(
UnsatisfiedLinkError
|
NoClassDefFoundError
ex
)
{
// failover to java implementation
// failover to java implementation
(
new
DoUnpack
()).
run
(
in0
,
out
);
(
new
DoUnpack
()).
run
(
in0
,
out
);
}
}
...
...
src/share/classes/com/sun/jmx/mbeanserver/Introspector.java
浏览文件 @
4d0e56aa
...
@@ -52,6 +52,7 @@ import javax.management.NotCompliantMBeanException;
...
@@ -52,6 +52,7 @@ import javax.management.NotCompliantMBeanException;
import
com.sun.jmx.remote.util.EnvHelp
;
import
com.sun.jmx.remote.util.EnvHelp
;
import
java.lang.reflect.Array
;
import
java.lang.reflect.Array
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.InvocationTargetException
;
import
java.security.AccessController
;
import
javax.management.AttributeNotFoundException
;
import
javax.management.AttributeNotFoundException
;
import
javax.management.openmbean.CompositeData
;
import
javax.management.openmbean.CompositeData
;
import
sun.reflect.misc.MethodUtil
;
import
sun.reflect.misc.MethodUtil
;
...
@@ -64,7 +65,11 @@ import sun.reflect.misc.ReflectUtil;
...
@@ -64,7 +65,11 @@ import sun.reflect.misc.ReflectUtil;
* @since 1.5
* @since 1.5
*/
*/
public
class
Introspector
{
public
class
Introspector
{
final
public
static
boolean
ALLOW_NONPUBLIC_MBEAN
;
static
{
String
val
=
AccessController
.
doPrivileged
(
new
GetPropertyAction
(
"jdk.jmx.mbeans.allowNonPublic"
));
ALLOW_NONPUBLIC_MBEAN
=
Boolean
.
parseBoolean
(
val
);
}
/*
/*
* ------------------------------------------
* ------------------------------------------
...
@@ -223,11 +228,27 @@ public class Introspector {
...
@@ -223,11 +228,27 @@ public class Introspector {
return
testCompliance
(
baseClass
,
null
);
return
testCompliance
(
baseClass
,
null
);
}
}
/**
* Tests the given interface class for being a compliant MXBean interface.
* A compliant MXBean interface is any publicly accessible interface
* following the {@link MXBean} conventions.
* @param interfaceClass An interface class to test for the MXBean compliance
* @throws NotCompliantMBeanException Thrown when the tested interface
* is not public or contradicts the {@link MXBean} conventions.
*/
public
static
void
testComplianceMXBeanInterface
(
Class
<?>
interfaceClass
)
public
static
void
testComplianceMXBeanInterface
(
Class
<?>
interfaceClass
)
throws
NotCompliantMBeanException
{
throws
NotCompliantMBeanException
{
MXBeanIntrospector
.
getInstance
().
getAnalyzer
(
interfaceClass
);
MXBeanIntrospector
.
getInstance
().
getAnalyzer
(
interfaceClass
);
}
}
/**
* Tests the given interface class for being a compliant MBean interface.
* A compliant MBean interface is any publicly accessible interface
* following the {@code MBean} conventions.
* @param interfaceClass An interface class to test for the MBean compliance
* @throws NotCompliantMBeanException Thrown when the tested interface
* is not public or contradicts the {@code MBean} conventions.
*/
public
static
void
testComplianceMBeanInterface
(
Class
<?>
interfaceClass
)
public
static
void
testComplianceMBeanInterface
(
Class
<?>
interfaceClass
)
throws
NotCompliantMBeanException
{
throws
NotCompliantMBeanException
{
StandardMBeanIntrospector
.
getInstance
().
getAnalyzer
(
interfaceClass
);
StandardMBeanIntrospector
.
getInstance
().
getAnalyzer
(
interfaceClass
);
...
@@ -299,18 +320,18 @@ public class Introspector {
...
@@ -299,18 +320,18 @@ public class Introspector {
* not a JMX compliant Standard MBean.
* not a JMX compliant Standard MBean.
*/
*/
public
static
<
T
>
Class
<?
super
T
>
getStandardMBeanInterface
(
Class
<
T
>
baseClass
)
public
static
<
T
>
Class
<?
super
T
>
getStandardMBeanInterface
(
Class
<
T
>
baseClass
)
throws
NotCompliantMBeanException
{
throws
NotCompliantMBeanException
{
Class
<?
super
T
>
current
=
baseClass
;
Class
<?
super
T
>
current
=
baseClass
;
Class
<?
super
T
>
mbeanInterface
=
null
;
Class
<?
super
T
>
mbeanInterface
=
null
;
while
(
current
!=
null
)
{
while
(
current
!=
null
)
{
mbeanInterface
=
mbeanInterface
=
findMBeanInterface
(
current
,
current
.
getName
());
findMBeanInterface
(
current
,
current
.
getName
());
if
(
mbeanInterface
!=
null
)
break
;
if
(
mbeanInterface
!=
null
)
break
;
current
=
current
.
getSuperclass
();
current
=
current
.
getSuperclass
();
}
}
if
(
mbeanInterface
!=
null
)
{
if
(
mbeanInterface
!=
null
)
{
return
mbeanInterface
;
return
mbeanInterface
;
}
else
{
}
else
{
final
String
msg
=
final
String
msg
=
"Class "
+
baseClass
.
getName
()
+
"Class "
+
baseClass
.
getName
()
+
" is not a JMX compliant Standard MBean"
;
" is not a JMX compliant Standard MBean"
;
...
@@ -507,8 +528,11 @@ public class Introspector {
...
@@ -507,8 +528,11 @@ public class Introspector {
}
}
Class
<?>[]
interfaces
=
c
.
getInterfaces
();
Class
<?>[]
interfaces
=
c
.
getInterfaces
();
for
(
int
i
=
0
;
i
<
interfaces
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
interfaces
.
length
;
i
++)
{
if
(
interfaces
[
i
].
getName
().
equals
(
clMBeanName
))
if
(
interfaces
[
i
].
getName
().
equals
(
clMBeanName
)
&&
(
Modifier
.
isPublic
(
interfaces
[
i
].
getModifiers
())
||
ALLOW_NONPUBLIC_MBEAN
))
{
return
Util
.
cast
(
interfaces
[
i
]);
return
Util
.
cast
(
interfaces
[
i
]);
}
}
}
return
null
;
return
null
;
...
...
src/share/classes/com/sun/jmx/mbeanserver/MBeanAnalyzer.java
浏览文件 @
4d0e56aa
...
@@ -28,6 +28,8 @@ package com.sun.jmx.mbeanserver;
...
@@ -28,6 +28,8 @@ package com.sun.jmx.mbeanserver;
import
static
com
.
sun
.
jmx
.
mbeanserver
.
Util
.*;
import
static
com
.
sun
.
jmx
.
mbeanserver
.
Util
.*;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Modifier
;
import
java.security.AccessController
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Comparator
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.List
;
...
@@ -50,7 +52,6 @@ import javax.management.NotCompliantMBeanException;
...
@@ -50,7 +52,6 @@ import javax.management.NotCompliantMBeanException;
* @since 1.6
* @since 1.6
*/
*/
class
MBeanAnalyzer
<
M
>
{
class
MBeanAnalyzer
<
M
>
{
static
interface
MBeanVisitor
<
M
>
{
static
interface
MBeanVisitor
<
M
>
{
public
void
visitAttribute
(
String
attributeName
,
public
void
visitAttribute
(
String
attributeName
,
M
getter
,
M
getter
,
...
@@ -107,6 +108,10 @@ class MBeanAnalyzer<M> {
...
@@ -107,6 +108,10 @@ class MBeanAnalyzer<M> {
if
(!
mbeanType
.
isInterface
())
{
if
(!
mbeanType
.
isInterface
())
{
throw
new
NotCompliantMBeanException
(
"Not an interface: "
+
throw
new
NotCompliantMBeanException
(
"Not an interface: "
+
mbeanType
.
getName
());
mbeanType
.
getName
());
}
else
if
(!
Modifier
.
isPublic
(
mbeanType
.
getModifiers
())
&&
!
Introspector
.
ALLOW_NONPUBLIC_MBEAN
)
{
throw
new
NotCompliantMBeanException
(
"Interface is not public: "
+
mbeanType
.
getName
());
}
}
try
{
try
{
...
...
src/share/classes/com/sun/security/sasl/util/AbstractSaslImpl.java
浏览文件 @
4d0e56aa
...
@@ -252,13 +252,12 @@ public abstract class AbstractSaslImpl {
...
@@ -252,13 +252,12 @@ public abstract class AbstractSaslImpl {
/**
/**
* Outputs a byte array
and converts
* Outputs a byte array
. Can be null.
*/
*/
protected
static
final
void
traceOutput
(
String
srcClass
,
String
srcMethod
,
protected
static
final
void
traceOutput
(
String
srcClass
,
String
srcMethod
,
String
traceTag
,
byte
[]
output
)
{
String
traceTag
,
byte
[]
output
)
{
if
(
output
!=
null
)
{
traceOutput
(
srcClass
,
srcMethod
,
traceTag
,
output
,
0
,
traceOutput
(
srcClass
,
srcMethod
,
traceTag
,
output
,
0
,
output
.
length
);
output
==
null
?
0
:
output
.
length
);
}
}
}
protected
static
final
void
traceOutput
(
String
srcClass
,
String
srcMethod
,
protected
static
final
void
traceOutput
(
String
srcClass
,
String
srcMethod
,
...
@@ -274,13 +273,20 @@ public abstract class AbstractSaslImpl {
...
@@ -274,13 +273,20 @@ public abstract class AbstractSaslImpl {
lev
=
Level
.
FINEST
;
lev
=
Level
.
FINEST
;
}
}
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
(
len
);
String
content
;
new
HexDumpEncoder
().
encodeBuffer
(
new
ByteArrayInputStream
(
output
,
offset
,
len
),
out
);
if
(
output
!=
null
)
{
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
(
len
);
new
HexDumpEncoder
().
encodeBuffer
(
new
ByteArrayInputStream
(
output
,
offset
,
len
),
out
);
content
=
out
.
toString
();
}
else
{
content
=
"NULL"
;
}
// Message id supplied by caller as part of traceTag
// Message id supplied by caller as part of traceTag
logger
.
logp
(
lev
,
srcClass
,
srcMethod
,
"{0} ( {1} ): {2}"
,
logger
.
logp
(
lev
,
srcClass
,
srcMethod
,
"{0} ( {1} ): {2}"
,
new
Object
[]
{
traceTag
,
new
Integer
(
origlen
),
out
.
toString
()
});
new
Object
[]
{
traceTag
,
new
Integer
(
origlen
),
content
});
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
logp
(
Level
.
WARNING
,
srcClass
,
srcMethod
,
logger
.
logp
(
Level
.
WARNING
,
srcClass
,
srcMethod
,
"SASLIMPL09:Error generating trace output: {0}"
,
e
);
"SASLIMPL09:Error generating trace output: {0}"
,
e
);
...
...
src/share/classes/java/io/File.java
浏览文件 @
4d0e56aa
...
@@ -1910,7 +1910,7 @@ public class File
...
@@ -1910,7 +1910,7 @@ public class File
}
}
String
name
=
prefix
+
Long
.
toString
(
n
)
+
suffix
;
String
name
=
prefix
+
Long
.
toString
(
n
)
+
suffix
;
File
f
=
new
File
(
dir
,
name
);
File
f
=
new
File
(
dir
,
name
);
if
(!
name
.
equals
(
f
.
getName
()))
if
(!
name
.
equals
(
f
.
getName
())
||
f
.
isInvalid
()
)
throw
new
IOException
(
"Unable to create temporary file"
);
throw
new
IOException
(
"Unable to create temporary file"
);
return
f
;
return
f
;
}
}
...
@@ -1996,19 +1996,26 @@ public class File
...
@@ -1996,19 +1996,26 @@ public class File
File
tmpdir
=
(
directory
!=
null
)
?
directory
File
tmpdir
=
(
directory
!=
null
)
?
directory
:
TempDirectory
.
location
();
:
TempDirectory
.
location
();
SecurityManager
sm
=
System
.
getSecurityManager
();
File
f
;
File
f
;
try
{
do
{
do
{
f
=
TempDirectory
.
generateFile
(
prefix
,
suffix
,
tmpdir
);
f
=
TempDirectory
.
generateFile
(
prefix
,
suffix
,
tmpdir
);
}
while
(
f
.
exists
());
if
(
sm
!=
null
)
{
if
(!
f
.
createNewFile
())
try
{
throw
new
IOException
(
"Unable to create temporary file"
);
sm
.
checkWrite
(
f
.
getPath
());
}
catch
(
SecurityException
se
)
{
}
catch
(
SecurityException
se
)
{
// don't reveal temporary directory location
// don't reveal temporary directory location
if
(
directory
==
null
)
if
(
directory
==
null
)
throw
new
SecurityException
(
"Unable to create temporary file"
);
throw
new
SecurityException
(
"Unable to create temporary file"
);
throw
se
;
throw
se
;
}
}
}
}
while
((
fs
.
getBooleanAttributes
(
f
)
&
FileSystem
.
BA_EXISTS
)
!=
0
);
if
(!
fs
.
createFileExclusively
(
f
.
getPath
()))
throw
new
IOException
(
"Unable to create temporary file"
);
return
f
;
return
f
;
}
}
...
...
src/share/classes/java/lang/management/LockInfo.java
浏览文件 @
4d0e56aa
/*
/*
* Copyright (c) 2005, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -42,7 +42,7 @@ import sun.management.LockInfoCompositeData;
...
@@ -42,7 +42,7 @@ import sun.management.LockInfoCompositeData;
* {@link ReentrantReadWriteLock ReentrantReadWriteLock} are
* {@link ReentrantReadWriteLock ReentrantReadWriteLock} are
* two examples of ownable synchronizers provided by the platform.
* two examples of ownable synchronizers provided by the platform.
*
*
* <h
4><a name="MappedType">MXBean Mapping</a></h4
>
* <h
3><a name="MappedType">MXBean Mapping</a></h3
>
* <tt>LockInfo</tt> is mapped to a {@link CompositeData CompositeData}
* <tt>LockInfo</tt> is mapped to a {@link CompositeData CompositeData}
* as specified in the {@link #from from} method.
* as specified in the {@link #from from} method.
*
*
...
@@ -105,7 +105,7 @@ public class LockInfo {
...
@@ -105,7 +105,7 @@ public class LockInfo {
* given {@code CompositeData}.
* given {@code CompositeData}.
* The given {@code CompositeData} must contain the following attributes:
* The given {@code CompositeData} must contain the following attributes:
* <blockquote>
* <blockquote>
* <table border>
* <table border
summary="The attributes and the types the given CompositeData contains"
>
* <tr>
* <tr>
* <th align=left>Attribute Name</th>
* <th align=left>Attribute Name</th>
* <th align=left>Type</th>
* <th align=left>Type</th>
...
...
src/share/classes/java/lang/management/ManagementFactory.java
浏览文件 @
4d0e56aa
...
@@ -61,7 +61,7 @@ import sun.management.ManagementFactoryHelper;
...
@@ -61,7 +61,7 @@ import sun.management.ManagementFactoryHelper;
* the management interface of a component of the Java virtual
* the management interface of a component of the Java virtual
* machine.
* machine.
* <p>
* <p>
* <h
4><a name="MXBean">Platform MXBeans</a></h4
>
* <h
3><a name="MXBean">Platform MXBeans</a></h3
>
* <p>
* <p>
* A platform MXBean is a <i>managed bean</i> that
* A platform MXBean is a <i>managed bean</i> that
* conforms to the <a href="../../../javax/management/package-summary.html">JMX</a>
* conforms to the <a href="../../../javax/management/package-summary.html">JMX</a>
...
@@ -87,7 +87,7 @@ import sun.management.ManagementFactoryHelper;
...
@@ -87,7 +87,7 @@ import sun.management.ManagementFactoryHelper;
*
*
* <p>
* <p>
* An application can access a platform MXBean in the following ways:
* An application can access a platform MXBean in the following ways:
* <h
5>1. Direct access to an MXBean interface</h5
>
* <h
4>1. Direct access to an MXBean interface</h4
>
* <blockquote>
* <blockquote>
* <ul>
* <ul>
* <li>Get an MXBean instance by calling the
* <li>Get an MXBean instance by calling the
...
@@ -107,7 +107,7 @@ import sun.management.ManagementFactoryHelper;
...
@@ -107,7 +107,7 @@ import sun.management.ManagementFactoryHelper;
* an MXBean of another running virtual machine.
* an MXBean of another running virtual machine.
* </li>
* </li>
* </ul>
* </ul>
* <h
5>2. Indirect access to an MXBean interface via MBeanServer</h5
>
* <h
4>2. Indirect access to an MXBean interface via MBeanServer</h4
>
* <ul>
* <ul>
* <li>Go through the platform {@code MBeanServer} to access MXBeans
* <li>Go through the platform {@code MBeanServer} to access MXBeans
* locally or a specific <tt>MBeanServerConnection</tt> to access
* locally or a specific <tt>MBeanServerConnection</tt> to access
...
@@ -135,7 +135,7 @@ import sun.management.ManagementFactoryHelper;
...
@@ -135,7 +135,7 @@ import sun.management.ManagementFactoryHelper;
* interfaces:
* interfaces:
*
*
* <blockquote>
* <blockquote>
* <table border>
* <table border
summary="The list of Management Interfaces and their single instances"
>
* <tr>
* <tr>
* <th>Management Interface</th>
* <th>Management Interface</th>
* <th>ObjectName</th>
* <th>ObjectName</th>
...
@@ -178,7 +178,7 @@ import sun.management.ManagementFactoryHelper;
...
@@ -178,7 +178,7 @@ import sun.management.ManagementFactoryHelper;
* the following management interfaces.
* the following management interfaces.
*
*
* <blockquote>
* <blockquote>
* <table border>
* <table border
summary="The list of Management Interfaces and their single instances"
>
* <tr>
* <tr>
* <th>Management Interface</th>
* <th>Management Interface</th>
* <th>ObjectName</th>
* <th>ObjectName</th>
...
@@ -195,7 +195,7 @@ import sun.management.ManagementFactoryHelper;
...
@@ -195,7 +195,7 @@ import sun.management.ManagementFactoryHelper;
* A Java virtual machine may have one or more instances of the following
* A Java virtual machine may have one or more instances of the following
* management interfaces.
* management interfaces.
* <blockquote>
* <blockquote>
* <table border>
* <table border
summary="The list of Management Interfaces and their single instances"
>
* <tr>
* <tr>
* <th>Management Interface</th>
* <th>Management Interface</th>
* <th>ObjectName</th>
* <th>ObjectName</th>
...
@@ -561,6 +561,12 @@ public class ManagementFactory {
...
@@ -561,6 +561,12 @@ public class ManagementFactory {
* in the format of {@link ObjectName ObjectName}.
* in the format of {@link ObjectName ObjectName}.
* @param mxbeanInterface the MXBean interface to be implemented
* @param mxbeanInterface the MXBean interface to be implemented
* by the proxy.
* by the proxy.
* @param <T> an {@code mxbeanInterface} type parameter
*
* @return a proxy for a platform MXBean interface of a
* given <a href="#MXBeanNames">MXBean name</a>
* that forwards its method calls through the given
* <tt>MBeanServerConnection</tt>, or {@code null} if not exist.
*
*
* @throws IllegalArgumentException if
* @throws IllegalArgumentException if
* <ul>
* <ul>
...
@@ -635,6 +641,7 @@ public class ManagementFactory {
...
@@ -635,6 +641,7 @@ public class ManagementFactory {
* @param mxbeanInterface a management interface for a platform
* @param mxbeanInterface a management interface for a platform
* MXBean with one single instance in the Java virtual machine
* MXBean with one single instance in the Java virtual machine
* if implemented.
* if implemented.
* @param <T> an {@code mxbeanInterface} type parameter
*
*
* @return the platform MXBean that implements
* @return the platform MXBean that implements
* {@code mxbeanInterface}, or {@code null} if not exist.
* {@code mxbeanInterface}, or {@code null} if not exist.
...
@@ -670,6 +677,7 @@ public class ManagementFactory {
...
@@ -670,6 +677,7 @@ public class ManagementFactory {
*
*
* @param mxbeanInterface a management interface for a platform
* @param mxbeanInterface a management interface for a platform
* MXBean
* MXBean
* @param <T> an {@code mxbeanInterface} type parameter
*
*
* @return the list of platform MXBeans that implement
* @return the list of platform MXBeans that implement
* {@code mxbeanInterface}.
* {@code mxbeanInterface}.
...
@@ -707,6 +715,7 @@ public class ManagementFactory {
...
@@ -707,6 +715,7 @@ public class ManagementFactory {
* @param mxbeanInterface a management interface for a platform
* @param mxbeanInterface a management interface for a platform
* MXBean with one single instance in the Java virtual machine
* MXBean with one single instance in the Java virtual machine
* being monitored, if implemented.
* being monitored, if implemented.
* @param <T> an {@code mxbeanInterface} type parameter
*
*
* @return the platform MXBean proxy for
* @return the platform MXBean proxy for
* forwarding the method calls of the {@code mxbeanInterface}
* forwarding the method calls of the {@code mxbeanInterface}
...
@@ -750,6 +759,7 @@ public class ManagementFactory {
...
@@ -750,6 +759,7 @@ public class ManagementFactory {
* @param connection the {@code MBeanServerConnection} to forward to.
* @param connection the {@code MBeanServerConnection} to forward to.
* @param mxbeanInterface a management interface for a platform
* @param mxbeanInterface a management interface for a platform
* MXBean
* MXBean
* @param <T> an {@code mxbeanInterface} type parameter
*
*
* @return the list of platform MXBean proxies for
* @return the list of platform MXBean proxies for
* forwarding the method calls of the {@code mxbeanInterface}
* forwarding the method calls of the {@code mxbeanInterface}
...
...
src/share/classes/java/lang/management/MemoryMXBean.java
浏览文件 @
4d0e56aa
/*
/*
* Copyright (c) 2003, 20
08
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 20
13
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -49,11 +49,11 @@ import javax.management.openmbean.CompositeData;
...
@@ -49,11 +49,11 @@ import javax.management.openmbean.CompositeData;
* It can be obtained by calling the
* It can be obtained by calling the
* {@link PlatformManagedObject#getObjectName} method.
* {@link PlatformManagedObject#getObjectName} method.
*
*
* <h
4> Memory </h4
>
* <h
3> Memory </h3
>
* The memory system of the Java virtual machine manages
* The memory system of the Java virtual machine manages
* the following kinds of memory:
* the following kinds of memory:
*
*
* <h
4> 1. Heap </h4
>
* <h
3> 1. Heap </h3
>
* The Java virtual machine has a <i>heap</i> that is the runtime
* The Java virtual machine has a <i>heap</i> that is the runtime
* data area from which memory for all class instances and arrays
* data area from which memory for all class instances and arrays
* are allocated. It is created at the Java virtual machine start-up.
* are allocated. It is created at the Java virtual machine start-up.
...
@@ -63,7 +63,7 @@ import javax.management.openmbean.CompositeData;
...
@@ -63,7 +63,7 @@ import javax.management.openmbean.CompositeData;
* <p>The heap may be of a fixed size or may be expanded and shrunk.
* <p>The heap may be of a fixed size or may be expanded and shrunk.
* The memory for the heap does not need to be contiguous.
* The memory for the heap does not need to be contiguous.
*
*
* <h
4> 2. Non-Heap Memory</h4
>
* <h
3> 2. Non-Heap Memory</h3
>
* The Java virtual machine manages memory other than the heap
* The Java virtual machine manages memory other than the heap
* (referred as <i>non-heap memory</i>).
* (referred as <i>non-heap memory</i>).
*
*
...
@@ -87,7 +87,7 @@ import javax.management.openmbean.CompositeData;
...
@@ -87,7 +87,7 @@ import javax.management.openmbean.CompositeData;
* machine code translated from the Java virtual machine code for
* machine code translated from the Java virtual machine code for
* high performance.
* high performance.
*
*
* <h
4>Memory Pools and Memory Managers</h4
>
* <h
3>Memory Pools and Memory Managers</h3
>
* {@link MemoryPoolMXBean Memory pools} and
* {@link MemoryPoolMXBean Memory pools} and
* {@link MemoryManagerMXBean memory managers} are the abstract entities
* {@link MemoryManagerMXBean memory managers} are the abstract entities
* that monitor and manage the memory system
* that monitor and manage the memory system
...
@@ -105,7 +105,7 @@ import javax.management.openmbean.CompositeData;
...
@@ -105,7 +105,7 @@ import javax.management.openmbean.CompositeData;
* add or remove memory managers during execution.
* add or remove memory managers during execution.
* A memory pool can be managed by more than one memory manager.
* A memory pool can be managed by more than one memory manager.
*
*
* <h
4>Memory Usage Monitoring</h4
>
* <h
3>Memory Usage Monitoring</h3
>
*
*
* Memory usage is a very important monitoring attribute for the memory system.
* Memory usage is a very important monitoring attribute for the memory system.
* The memory usage, for example, could indicate:
* The memory usage, for example, could indicate:
...
@@ -131,7 +131,7 @@ import javax.management.openmbean.CompositeData;
...
@@ -131,7 +131,7 @@ import javax.management.openmbean.CompositeData;
* certain threshold. It is not intended for an application to detect
* certain threshold. It is not intended for an application to detect
* and recover from a low memory condition.
* and recover from a low memory condition.
*
*
* <h
4>Notifications</h4
>
* <h
3>Notifications</h3
>
*
*
* <p>This <tt>MemoryMXBean</tt> is a
* <p>This <tt>MemoryMXBean</tt> is a
* {@link javax.management.NotificationEmitter NotificationEmitter}
* {@link javax.management.NotificationEmitter NotificationEmitter}
...
@@ -169,7 +169,7 @@ import javax.management.openmbean.CompositeData;
...
@@ -169,7 +169,7 @@ import javax.management.openmbean.CompositeData;
* MemoryNotificationInfo}.
* MemoryNotificationInfo}.
*
*
* <hr>
* <hr>
* <h
4>NotificationEmitter</h4
>
* <h
3>NotificationEmitter</h3
>
* The <tt>MemoryMXBean</tt> object returned by
* The <tt>MemoryMXBean</tt> object returned by
* {@link ManagementFactory#getMemoryMXBean} implements
* {@link ManagementFactory#getMemoryMXBean} implements
* the {@link javax.management.NotificationEmitter NotificationEmitter}
* the {@link javax.management.NotificationEmitter NotificationEmitter}
...
...
src/share/classes/java/lang/management/MemoryNotificationInfo.java
浏览文件 @
4d0e56aa
/*
/*
* Copyright (c) 2003, 20
06
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 20
13
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -212,7 +212,7 @@ public class MemoryNotificationInfo {
...
@@ -212,7 +212,7 @@ public class MemoryNotificationInfo {
* The given <tt>CompositeData</tt> must contain
* The given <tt>CompositeData</tt> must contain
* the following attributes:
* the following attributes:
* <blockquote>
* <blockquote>
* <table border>
* <table border
summary="The attributes and the types the given CompositeData contains"
>
* <tr>
* <tr>
* <th align=left>Attribute Name</th>
* <th align=left>Attribute Name</th>
* <th align=left>Type</th>
* <th align=left>Type</th>
...
...
src/share/classes/java/lang/management/MemoryPoolMXBean.java
浏览文件 @
4d0e56aa
/*
/*
* Copyright (c) 2003, 20
08
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 20
13
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -49,7 +49,7 @@ package java.lang.management;
...
@@ -49,7 +49,7 @@ package java.lang.management;
* It can be obtained by calling the
* It can be obtained by calling the
* {@link PlatformManagedObject#getObjectName} method.
* {@link PlatformManagedObject#getObjectName} method.
*
*
* <h
4>Memory Type</h4
>
* <h
3>Memory Type</h3
>
* <p>The Java virtual machine has a heap for object allocation and also
* <p>The Java virtual machine has a heap for object allocation and also
* maintains non-heap memory for the method area and the Java virtual
* maintains non-heap memory for the method area and the Java virtual
* machine execution. The Java virtual machine can have one or more
* machine execution. The Java virtual machine can have one or more
...
@@ -60,7 +60,7 @@ package java.lang.management;
...
@@ -60,7 +60,7 @@ package java.lang.management;
* <li>{@link MemoryType#NON_HEAP non-heap}</li>
* <li>{@link MemoryType#NON_HEAP non-heap}</li>
* </ul>
* </ul>
*
*
* <h
4>Memory Usage Monitoring</h4
>
* <h
3>Memory Usage Monitoring</h3
>
*
*
* A memory pool has the following attributes:
* A memory pool has the following attributes:
* <ul>
* <ul>
...
@@ -71,7 +71,7 @@ package java.lang.management;
...
@@ -71,7 +71,7 @@ package java.lang.management;
* (only supported by some <em>garbage-collected</em> memory pools)</li>
* (only supported by some <em>garbage-collected</em> memory pools)</li>
* </ul>
* </ul>
*
*
* <h
4><a name="Usage">1. Memory Usage</a></h4
>
* <h
3><a name="Usage">1. Memory Usage</a></h3
>
*
*
* The {@link #getUsage} method provides an estimate
* The {@link #getUsage} method provides an estimate
* of the current usage of a memory pool.
* of the current usage of a memory pool.
...
@@ -86,14 +86,14 @@ package java.lang.management;
...
@@ -86,14 +86,14 @@ package java.lang.management;
* the current memory usage. An implementation should document when
* the current memory usage. An implementation should document when
* this is the case.
* this is the case.
*
*
* <h
4><a name="PeakUsage">2. Peak Memory Usage</a></h4
>
* <h
3><a name="PeakUsage">2. Peak Memory Usage</a></h3
>
*
*
* The Java virtual machine maintains the peak memory usage of a memory
* The Java virtual machine maintains the peak memory usage of a memory
* pool since the virtual machine was started or the peak was reset.
* pool since the virtual machine was started or the peak was reset.
* The peak memory usage is returned by the {@link #getPeakUsage} method
* The peak memory usage is returned by the {@link #getPeakUsage} method
* and reset by calling the {@link #resetPeakUsage} method.
* and reset by calling the {@link #resetPeakUsage} method.
*
*
* <h
4><a name="UsageThreshold">3. Usage Threshold</a></h4
>
* <h
3><a name="UsageThreshold">3. Usage Threshold</a></h3
>
*
*
* Each memory pool has a manageable attribute
* Each memory pool has a manageable attribute
* called the <i>usage threshold</i> which has a default value supplied
* called the <i>usage threshold</i> which has a default value supplied
...
@@ -304,7 +304,7 @@ package java.lang.management;
...
@@ -304,7 +304,7 @@ package java.lang.management;
* </li>
* </li>
* </ol>
* </ol>
*
*
* <h
4><a name="CollectionThreshold">4. Collection Usage Threshold</a></h4
>
* <h
3><a name="CollectionThreshold">4. Collection Usage Threshold</a></h3
>
*
*
* Collection usage threshold is a manageable attribute only applicable
* Collection usage threshold is a manageable attribute only applicable
* to some garbage-collected memory pools.
* to some garbage-collected memory pools.
...
...
src/share/classes/java/lang/management/MemoryUsage.java
浏览文件 @
4d0e56aa
/*
/*
* Copyright (c) 2003, 20
04
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 20
13
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -36,8 +36,7 @@ import sun.management.MemoryUsageCompositeData;
...
@@ -36,8 +36,7 @@ import sun.management.MemoryUsageCompositeData;
* the heap or non-heap memory of the Java virtual machine as a whole.
* the heap or non-heap memory of the Java virtual machine as a whole.
*
*
* <p> A <tt>MemoryUsage</tt> object contains four values:
* <p> A <tt>MemoryUsage</tt> object contains four values:
* <ul>
* <table summary="Describes the MemoryUsage object content">
* <table>
* <tr>
* <tr>
* <td valign=top> <tt>init</tt> </td>
* <td valign=top> <tt>init</tt> </td>
* <td valign=top> represents the initial amount of memory (in bytes) that
* <td valign=top> represents the initial amount of memory (in bytes) that
...
@@ -78,7 +77,6 @@ import sun.management.MemoryUsageCompositeData;
...
@@ -78,7 +77,6 @@ import sun.management.MemoryUsageCompositeData;
* </td>
* </td>
* </tr>
* </tr>
* </table>
* </table>
* </ul>
*
*
* Below is a picture showing an example of a memory pool:
* Below is a picture showing an example of a memory pool:
* <p>
* <p>
...
@@ -98,7 +96,7 @@ import sun.management.MemoryUsageCompositeData;
...
@@ -98,7 +96,7 @@ import sun.management.MemoryUsageCompositeData;
* max
* max
* </pre>
* </pre>
*
*
* <h
4>MXBean Mapping</h4
>
* <h
3>MXBean Mapping</h3
>
* <tt>MemoryUsage</tt> is mapped to a {@link CompositeData CompositeData}
* <tt>MemoryUsage</tt> is mapped to a {@link CompositeData CompositeData}
* with attributes as specified in the {@link #from from} method.
* with attributes as specified in the {@link #from from} method.
*
*
...
@@ -254,7 +252,7 @@ public class MemoryUsage {
...
@@ -254,7 +252,7 @@ public class MemoryUsage {
* must contain the following attributes:
* must contain the following attributes:
* <p>
* <p>
* <blockquote>
* <blockquote>
* <table border>
* <table border
summary="The attributes and the types the given CompositeData contains"
>
* <tr>
* <tr>
* <th align=left>Attribute Name</th>
* <th align=left>Attribute Name</th>
* <th align=left>Type</th>
* <th align=left>Type</th>
...
...
src/share/classes/java/lang/management/MonitorInfo.java
浏览文件 @
4d0e56aa
/*
/*
* Copyright (c) 2005, 20
06
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 20
13
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -32,7 +32,7 @@ import sun.management.MonitorInfoCompositeData;
...
@@ -32,7 +32,7 @@ import sun.management.MonitorInfoCompositeData;
* Information about an object monitor lock. An object monitor is locked
* Information about an object monitor lock. An object monitor is locked
* when entering a synchronization block or method on that object.
* when entering a synchronization block or method on that object.
*
*
* <h
4>MXBean Mapping</h4
>
* <h
3>MXBean Mapping</h3
>
* <tt>MonitorInfo</tt> is mapped to a {@link CompositeData CompositeData}
* <tt>MonitorInfo</tt> is mapped to a {@link CompositeData CompositeData}
* with attributes as specified in
* with attributes as specified in
* the {@link #from from} method.
* the {@link #from from} method.
...
@@ -106,7 +106,7 @@ public class MonitorInfo extends LockInfo {
...
@@ -106,7 +106,7 @@ public class MonitorInfo extends LockInfo {
* <a href="LockInfo.html#MappedType">
* <a href="LockInfo.html#MappedType">
* mapped type</a> for the {@link LockInfo} class:
* mapped type</a> for the {@link LockInfo} class:
* <blockquote>
* <blockquote>
* <table border>
* <table border
summary="The attributes and their types the given CompositeData contains"
>
* <tr>
* <tr>
* <th align=left>Attribute Name</th>
* <th align=left>Attribute Name</th>
* <th align=left>Type</th>
* <th align=left>Type</th>
...
...
src/share/classes/java/lang/management/RuntimeMXBean.java
浏览文件 @
4d0e56aa
/*
/*
* Copyright (c) 2003, 20
08
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 20
13
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -272,7 +272,7 @@ public interface RuntimeMXBean extends PlatformManagedObject {
...
@@ -272,7 +272,7 @@ public interface RuntimeMXBean extends PlatformManagedObject {
*
*
* <p>
* <p>
* <b>MBeanServer access</b>:<br>
* <b>MBeanServer access</b>:<br>
* The mapped type of
<tt>List<String></tt>
is <tt>String[]</tt>.
* The mapped type of
{@code List<String>}
is <tt>String[]</tt>.
*
*
* @return a list of <tt>String</tt> objects; each element
* @return a list of <tt>String</tt> objects; each element
* is an argument passed to the Java virtual machine.
* is an argument passed to the Java virtual machine.
...
@@ -312,7 +312,7 @@ public interface RuntimeMXBean extends PlatformManagedObject {
...
@@ -312,7 +312,7 @@ public interface RuntimeMXBean extends PlatformManagedObject {
* {@link javax.management.openmbean.TabularData TabularData}
* {@link javax.management.openmbean.TabularData TabularData}
* with two items in each row as follows:
* with two items in each row as follows:
* <blockquote>
* <blockquote>
* <table border>
* <table border
summary="Name and Type for each item"
>
* <tr>
* <tr>
* <th>Item Name</th>
* <th>Item Name</th>
* <th>Item Type</th>
* <th>Item Type</th>
...
...
src/share/classes/java/lang/management/ThreadInfo.java
浏览文件 @
4d0e56aa
/*
/*
* Copyright (c) 2003, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -33,13 +33,13 @@ import static java.lang.Thread.State.*;
...
@@ -33,13 +33,13 @@ import static java.lang.Thread.State.*;
/**
/**
* Thread information. <tt>ThreadInfo</tt> contains the information
* Thread information. <tt>ThreadInfo</tt> contains the information
* about a thread including:
* about a thread including:
* <h
4>General thread information</h4
>
* <h
3>General thread information</h3
>
* <ul>
* <ul>
* <li>Thread ID.</li>
* <li>Thread ID.</li>
* <li>Name of the thread.</li>
* <li>Name of the thread.</li>
* </ul>
* </ul>
*
*
* <h
4>Execution information</h4
>
* <h
3>Execution information</h3
>
* <ul>
* <ul>
* <li>Thread state.</li>
* <li>Thread state.</li>
* <li>The object upon which the thread is blocked due to:
* <li>The object upon which the thread is blocked due to:
...
@@ -652,7 +652,7 @@ public class ThreadInfo {
...
@@ -652,7 +652,7 @@ public class ThreadInfo {
* The given <tt>CompositeData</tt> must contain the following attributes
* The given <tt>CompositeData</tt> must contain the following attributes
* unless otherwise specified below:
* unless otherwise specified below:
* <blockquote>
* <blockquote>
* <table border>
* <table border
summary="The attributes and their types the given CompositeData contains"
>
* <tr>
* <tr>
* <th align=left>Attribute Name</th>
* <th align=left>Attribute Name</th>
* <th align=left>Type</th>
* <th align=left>Type</th>
...
@@ -722,7 +722,7 @@ public class ThreadInfo {
...
@@ -722,7 +722,7 @@ public class ThreadInfo {
* Each element is a <tt>CompositeData</tt> representing
* Each element is a <tt>CompositeData</tt> representing
* StackTraceElement containing the following attributes:
* StackTraceElement containing the following attributes:
* <blockquote>
* <blockquote>
* <table cellspacing=1 cellpadding=0>
* <table cellspacing=1 cellpadding=0
summary="The attributes and their types the given CompositeData contains"
>
* <tr>
* <tr>
* <th align=left>Attribute Name</th>
* <th align=left>Attribute Name</th>
* <th align=left>Type</th>
* <th align=left>Type</th>
...
...
src/share/classes/java/lang/management/ThreadMXBean.java
浏览文件 @
4d0e56aa
/*
/*
* Copyright (c) 2003, 20
08
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 20
13
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -49,7 +49,7 @@ import java.util.Map;
...
@@ -49,7 +49,7 @@ import java.util.Map;
* It can be obtained by calling the
* It can be obtained by calling the
* {@link PlatformManagedObject#getObjectName} method.
* {@link PlatformManagedObject#getObjectName} method.
*
*
* <h
4>Thread ID</h4
>
* <h
3>Thread ID</h3
>
* Thread ID is a positive long value returned by calling the
* Thread ID is a positive long value returned by calling the
* {@link java.lang.Thread#getId} method for a thread.
* {@link java.lang.Thread#getId} method for a thread.
* The thread ID is unique during its lifetime. When a thread
* The thread ID is unique during its lifetime. When a thread
...
@@ -58,7 +58,7 @@ import java.util.Map;
...
@@ -58,7 +58,7 @@ import java.util.Map;
* <p> Some methods in this interface take a thread ID or an array
* <p> Some methods in this interface take a thread ID or an array
* of thread IDs as the input parameter and return per-thread information.
* of thread IDs as the input parameter and return per-thread information.
*
*
* <h
4>Thread CPU time</h4
>
* <h
3>Thread CPU time</h3
>
* A Java virtual machine implementation may support measuring
* A Java virtual machine implementation may support measuring
* the CPU time for the current thread, for any thread, or for no threads.
* the CPU time for the current thread, for any thread, or for no threads.
*
*
...
@@ -83,7 +83,7 @@ import java.util.Map;
...
@@ -83,7 +83,7 @@ import java.util.Map;
* Enabling thread CPU measurement could be expensive in some
* Enabling thread CPU measurement could be expensive in some
* Java virtual machine implementations.
* Java virtual machine implementations.
*
*
* <h
4>Thread Contention Monitoring</h4
>
* <h
3>Thread Contention Monitoring</h3
>
* Some Java virtual machines may support thread contention monitoring.
* Some Java virtual machines may support thread contention monitoring.
* When thread contention monitoring is enabled, the accumulated elapsed
* When thread contention monitoring is enabled, the accumulated elapsed
* time that the thread has blocked for synchronization or waited for
* time that the thread has blocked for synchronization or waited for
...
@@ -96,7 +96,7 @@ import java.util.Map;
...
@@ -96,7 +96,7 @@ import java.util.Map;
* {@link #setThreadContentionMonitoringEnabled} method can be used to enable
* {@link #setThreadContentionMonitoringEnabled} method can be used to enable
* thread contention monitoring.
* thread contention monitoring.
*
*
* <h
4>Synchronization Information and Deadlock Detection</h4
>
* <h
3>Synchronization Information and Deadlock Detection</h3
>
* Some Java virtual machines may support monitoring of
* Some Java virtual machines may support monitoring of
* {@linkplain #isObjectMonitorUsageSupported object monitor usage} and
* {@linkplain #isObjectMonitorUsageSupported object monitor usage} and
* {@linkplain #isSynchronizerUsageSupported ownable synchronizer usage}.
* {@linkplain #isSynchronizerUsageSupported ownable synchronizer usage}.
...
...
src/share/classes/java/math/BigDecimal.java
浏览文件 @
4d0e56aa
...
@@ -2592,14 +2592,18 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
...
@@ -2592,14 +2592,18 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
* the {@code BigDecimal} value {@code 600.0}, which has
* the {@code BigDecimal} value {@code 600.0}, which has
* [{@code BigInteger}, {@code scale}] components equals to
* [{@code BigInteger}, {@code scale}] components equals to
* [6000, 1], yields {@code 6E2} with [{@code BigInteger},
* [6000, 1], yields {@code 6E2} with [{@code BigInteger},
* {@code scale}] components equals to [6, -2]
* {@code scale}] components equals to [6, -2]. If
* this BigDecimal is numerically equal to zero, then
* {@code BigDecimal.ZERO} is returned.
*
*
* @return a numerically equal {@code BigDecimal} with any
* @return a numerically equal {@code BigDecimal} with any
* trailing zeros removed.
* trailing zeros removed.
* @since 1.5
* @since 1.5
*/
*/
public
BigDecimal
stripTrailingZeros
()
{
public
BigDecimal
stripTrailingZeros
()
{
if
(
intCompact
!=
INFLATED
)
{
if
(
intCompact
==
0
||
(
intVal
!=
null
&&
intVal
.
signum
()
==
0
))
{
return
BigDecimal
.
ZERO
;
}
else
if
(
intCompact
!=
INFLATED
)
{
return
createAndStripZerosToMatchScale
(
intCompact
,
scale
,
Long
.
MIN_VALUE
);
return
createAndStripZerosToMatchScale
(
intCompact
,
scale
,
Long
.
MIN_VALUE
);
}
else
{
}
else
{
return
createAndStripZerosToMatchScale
(
intVal
,
scale
,
Long
.
MIN_VALUE
);
return
createAndStripZerosToMatchScale
(
intVal
,
scale
,
Long
.
MIN_VALUE
);
...
...
src/share/classes/java/net/CookieStore.java
浏览文件 @
4d0e56aa
/*
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005,
2013,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -75,6 +75,8 @@ public interface CookieStore {
...
@@ -75,6 +75,8 @@ public interface CookieStore {
* @return an immutable list of HttpCookie,
* @return an immutable list of HttpCookie,
* return empty list if no cookies match the given URI
* return empty list if no cookies match the given URI
*
*
* @param uri the uri associated with the cookies to be returned
*
* @throws NullPointerException if <tt>uri</tt> is <tt>null</tt>
* @throws NullPointerException if <tt>uri</tt> is <tt>null</tt>
*
*
* @see #add
* @see #add
...
...
src/share/classes/java/net/HttpURLPermission.java
浏览文件 @
4d0e56aa
...
@@ -47,6 +47,7 @@ import java.security.Permission;
...
@@ -47,6 +47,7 @@ import java.security.Permission;
* in {@link java.io.FilePermission}. There are three different ways
* in {@link java.io.FilePermission}. There are three different ways
* as the following examples show:
* as the following examples show:
* <table border>
* <table border>
* <caption>URL Examples</caption>
* <tr><th>Example url</th><th>Description</th></tr>
* <tr><th>Example url</th><th>Description</th></tr>
* <tr><td style="white-space:nowrap;">http://www.oracle.com/a/b/c.html</td>
* <tr><td style="white-space:nowrap;">http://www.oracle.com/a/b/c.html</td>
* <td>A url which identifies a specific (single) resource</td>
* <td>A url which identifies a specific (single) resource</td>
...
@@ -57,7 +58,7 @@ import java.security.Permission;
...
@@ -57,7 +58,7 @@ import java.security.Permission;
* which only differ in the final path component, represented by the '*'.
* which only differ in the final path component, represented by the '*'.
* </td>
* </td>
* </tr>
* </tr>
* <tr><td>http://www.oracle.com/a/b/-</
li
>
* <tr><td>http://www.oracle.com/a/b/-</
td
>
* <td>The '-' character refers to all resources recursively below the
* <td>The '-' character refers to all resources recursively below the
* preceding path (eg. http://www.oracle.com/a/b/c/d/e.html matches this
* preceding path (eg. http://www.oracle.com/a/b/c/d/e.html matches this
* example).
* example).
...
@@ -164,6 +165,8 @@ public final class HttpURLPermission extends Permission {
...
@@ -164,6 +165,8 @@ public final class HttpURLPermission extends Permission {
* methods and request headers by invoking the two argument
* methods and request headers by invoking the two argument
* constructor as follows: HttpURLPermission(url, "*:*")
* constructor as follows: HttpURLPermission(url, "*:*")
*
*
* @param url the url string
*
* @throws IllegalArgumentException if url does not result in a valid {@link URI}
* @throws IllegalArgumentException if url does not result in a valid {@link URI}
*/
*/
public
HttpURLPermission
(
String
url
)
{
public
HttpURLPermission
(
String
url
)
{
...
@@ -204,11 +207,10 @@ public final class HttpURLPermission extends Permission {
...
@@ -204,11 +207,10 @@ public final class HttpURLPermission extends Permission {
* <li>if the path or paths specified by p's url are contained in the
* <li>if the path or paths specified by p's url are contained in the
* set of paths specified by this's url, then return true
* set of paths specified by this's url, then return true
* <li>otherwise, return false</li>
* <li>otherwise, return false</li>
* </ol>
* </ul>
* <p>
* <p>Some examples of how paths are matched are shown below:
* Some examples of how paths are matched are shown below:
* <p><table border>
* <p>
* <caption>Examples of Path Matching</caption>
* <table border>
* <tr><th>this's path</th><th>p's path</th><th>match</th></tr>
* <tr><th>this's path</th><th>p's path</th><th>match</th></tr>
* <tr><td>/a/b</td><td>/a/b</td><td>yes</td></tr>
* <tr><td>/a/b</td><td>/a/b</td><td>yes</td></tr>
* <tr><td>/a/b/*</td><td>/a/b/c</td><td>yes</td></tr>
* <tr><td>/a/b/*</td><td>/a/b/c</td><td>yes</td></tr>
...
...
src/share/classes/java/net/Inet4Address.java
浏览文件 @
4d0e56aa
/*
/*
* Copyright (c) 2000, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -36,7 +36,7 @@ import java.io.ObjectStreamException;
...
@@ -36,7 +36,7 @@ import java.io.ObjectStreamException;
* and <a href="http://www.ietf.org/rfc/rfc2365.txt"><i>RFC 2365:
* and <a href="http://www.ietf.org/rfc/rfc2365.txt"><i>RFC 2365:
* Administratively Scoped IP Multicast</i></a>
* Administratively Scoped IP Multicast</i></a>
*
*
* <h
4> <A NAME="format">Textual representation of IP addresses</a> </h4
>
* <h
3> <A NAME="format">Textual representation of IP addresses</a> </h3
>
*
*
* Textual representation of IPv4 address used as input to methods
* Textual representation of IPv4 address used as input to methods
* takes one of the following forms:
* takes one of the following forms:
...
...
src/share/classes/java/net/Inet6Address.java
浏览文件 @
4d0e56aa
...
@@ -35,7 +35,7 @@ import java.util.Enumeration;
...
@@ -35,7 +35,7 @@ import java.util.Enumeration;
* Defined by <a href="http://www.ietf.org/rfc/rfc2373.txt">
* Defined by <a href="http://www.ietf.org/rfc/rfc2373.txt">
* <i>RFC 2373: IP Version 6 Addressing Architecture</i></a>.
* <i>RFC 2373: IP Version 6 Addressing Architecture</i></a>.
*
*
* <h
4> <A NAME="format">Textual representation of IP addresses</a> </h4
>
* <h
3> <A NAME="format">Textual representation of IP addresses</a> </h3
>
*
*
* Textual representation of IPv6 address used as input to methods
* Textual representation of IPv6 address used as input to methods
* takes one of the following forms:
* takes one of the following forms:
...
@@ -156,7 +156,7 @@ import java.util.Enumeration;
...
@@ -156,7 +156,7 @@ import java.util.Enumeration;
* system. Usually, the numeric values can be determined through administration
* system. Usually, the numeric values can be determined through administration
* tools on the system. Each interface may have multiple values, one for each
* tools on the system. Each interface may have multiple values, one for each
* scope. If the scope is unspecified, then the default value used is zero.</li>
* scope. If the scope is unspecified, then the default value used is zero.</li>
* <
p><
li><i>As a string.</i> This must be the exact string that is returned by
* <li><i>As a string.</i> This must be the exact string that is returned by
* {@link java.net.NetworkInterface#getName()} for the particular interface in
* {@link java.net.NetworkInterface#getName()} for the particular interface in
* question. When an Inet6Address is created in this way, the numeric scope-id
* question. When an Inet6Address is created in this way, the numeric scope-id
* is determined at the time the object is created by querying the relevant
* is determined at the time the object is created by querying the relevant
...
...
src/share/classes/java/net/InetAddress.java
浏览文件 @
4d0e56aa
/*
/*
* Copyright (c) 1995, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -65,7 +65,7 @@ import sun.net.spi.nameservice.*;
...
@@ -65,7 +65,7 @@ import sun.net.spi.nameservice.*;
* with a host name or whether it has already done reverse host name
* with a host name or whether it has already done reverse host name
* resolution).
* resolution).
*
*
* <h
4> Address types </h4
>
* <h
3> Address types </h3
>
*
*
* <blockquote><table cellspacing=2 summary="Description of unicast and multicast address types">
* <blockquote><table cellspacing=2 summary="Description of unicast and multicast address types">
* <tr><th valign=top><i>unicast</i></th>
* <tr><th valign=top><i>unicast</i></th>
...
@@ -165,7 +165,6 @@ import sun.net.spi.nameservice.*;
...
@@ -165,7 +165,6 @@ import sun.net.spi.nameservice.*;
* <p>
* <p>
* A value of -1 indicates "cache forever".
* A value of -1 indicates "cache forever".
* </dd>
* </dd>
* <p>
* <dt><b>networkaddress.cache.negative.ttl</b> (default: 10)</dt>
* <dt><b>networkaddress.cache.negative.ttl</b> (default: 10)</dt>
* <dd>Indicates the caching policy for un-successful name lookups
* <dd>Indicates the caching policy for un-successful name lookups
* from the name service. The value is specified as as integer to
* from the name service. The value is specified as as integer to
...
...
src/share/classes/java/net/ProtocolFamily.java
浏览文件 @
4d0e56aa
/*
/*
* Copyright (c) 2007, 20
08
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 20
13
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -34,6 +34,8 @@ package java.net;
...
@@ -34,6 +34,8 @@ package java.net;
public
interface
ProtocolFamily
{
public
interface
ProtocolFamily
{
/**
/**
* Returns the name of the protocol family.
* Returns the name of the protocol family.
*
* @return the name of the protocol family
*/
*/
String
name
();
String
name
();
}
}
src/share/classes/java/net/SocketOption.java
浏览文件 @
4d0e56aa
/*
/*
* Copyright (c) 2007, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -45,11 +45,15 @@ public interface SocketOption<T> {
...
@@ -45,11 +45,15 @@ public interface SocketOption<T> {
/**
/**
* Returns the name of the socket option.
* Returns the name of the socket option.
*
* @return the name of the socket option
*/
*/
String
name
();
String
name
();
/**
/**
* Returns the type of the socket option value.
* Returns the type of the socket option value.
*
* @return the type of the socket option value
*/
*/
Class
<
T
>
type
();
Class
<
T
>
type
();
}
}
src/share/classes/java/net/URI.java
浏览文件 @
4d0e56aa
/*
/*
* Copyright (c) 2000, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -61,13 +61,13 @@ import java.lang.NullPointerException; // for javadoc
...
@@ -61,13 +61,13 @@ import java.lang.NullPointerException; // for javadoc
* and relativizing URI instances. Instances of this class are immutable.
* and relativizing URI instances. Instances of this class are immutable.
*
*
*
*
* <h
4> URI syntax and components </h4
>
* <h
3> URI syntax and components </h3
>
*
*
* At the highest level a URI reference (hereinafter simply "URI") in string
* At the highest level a URI reference (hereinafter simply "URI") in string
* form has the syntax
* form has the syntax
*
*
* <blockquote>
* <blockquote>
* [<i>scheme</i><tt><b>:</b></tt>
<i></i>
]<i>scheme-specific-part</i>[<tt><b>#</b></tt><i>fragment</i>]
* [<i>scheme</i><tt><b>:</b></tt>]<i>scheme-specific-part</i>[<tt><b>#</b></tt><i>fragment</i>]
* </blockquote>
* </blockquote>
*
*
* where square brackets [...] delineate optional components and the characters
* where square brackets [...] delineate optional components and the characters
...
@@ -334,14 +334,14 @@ import java.lang.NullPointerException; // for javadoc
...
@@ -334,14 +334,14 @@ import java.lang.NullPointerException; // for javadoc
*
*
* <ul>
* <ul>
*
*
* <li><p> The {@link
#URI(java.lang.String) <code>
single-argument
* <li><p> The {@link
plain #URI(java.lang.String)
single-argument
* constructor
</code>
} requires any illegal characters in its argument to be
* constructor} requires any illegal characters in its argument to be
* quoted and preserves any escaped octets and <i>other</i> characters that
* quoted and preserves any escaped octets and <i>other</i> characters that
* are present. </p></li>
* are present. </p></li>
*
*
* <li><p> The {@link
* <li><p> The {@link
plain
* #URI(java.lang.String,java.lang.String,java.lang.String,int,java.lang.String,java.lang.String,java.lang.String)
* #URI(java.lang.String,java.lang.String,java.lang.String,int,java.lang.String,java.lang.String,java.lang.String)
*
<code>multi-argument constructors</code>
} quote illegal characters as
*
multi-argument constructors
} quote illegal characters as
* required by the components in which they appear. The percent character
* required by the components in which they appear. The percent character
* (<tt>'%'</tt>) is always quoted by these constructors. Any <i>other</i>
* (<tt>'%'</tt>) is always quoted by these constructors. Any <i>other</i>
* characters are preserved. </p></li>
* characters are preserved. </p></li>
...
...
src/share/classes/java/util/Collections.java
浏览文件 @
4d0e56aa
...
@@ -34,6 +34,8 @@ import java.util.function.Consumer;
...
@@ -34,6 +34,8 @@ import java.util.function.Consumer;
import
java.util.function.Function
;
import
java.util.function.Function
;
import
java.util.function.Predicate
;
import
java.util.function.Predicate
;
import
java.util.function.UnaryOperator
;
import
java.util.function.UnaryOperator
;
import
java.util.stream.Stream
;
import
java.util.stream.StreamSupport
;
/**
/**
* This class consists exclusively of static methods that operate on or return
* This class consists exclusively of static methods that operate on or return
...
@@ -1510,6 +1512,86 @@ public class Collections {
...
@@ -1510,6 +1512,86 @@ public class Collections {
// Need to cast to raw in order to work around a limitation in the type system
// Need to cast to raw in order to work around a limitation in the type system
super
((
Set
)
s
);
super
((
Set
)
s
);
}
}
static
<
K
,
V
>
Consumer
<
Map
.
Entry
<
K
,
V
>>
entryConsumer
(
Consumer
<?
super
Entry
<
K
,
V
>>
action
)
{
return
e
->
action
.
accept
(
new
UnmodifiableEntry
<>(
e
));
}
public
void
forEach
(
Consumer
<?
super
Entry
<
K
,
V
>>
action
)
{
Objects
.
requireNonNull
(
action
);
c
.
forEach
(
entryConsumer
(
action
));
}
static
final
class
UnmodifiableEntrySetSpliterator
<
K
,
V
>
implements
Spliterator
<
Entry
<
K
,
V
>>
{
final
Spliterator
<
Map
.
Entry
<
K
,
V
>>
s
;
UnmodifiableEntrySetSpliterator
(
Spliterator
<
Entry
<
K
,
V
>>
s
)
{
this
.
s
=
s
;
}
@Override
public
boolean
tryAdvance
(
Consumer
<?
super
Entry
<
K
,
V
>>
action
)
{
Objects
.
requireNonNull
(
action
);
return
s
.
tryAdvance
(
entryConsumer
(
action
));
}
@Override
public
void
forEachRemaining
(
Consumer
<?
super
Entry
<
K
,
V
>>
action
)
{
Objects
.
requireNonNull
(
action
);
s
.
forEachRemaining
(
entryConsumer
(
action
));
}
@Override
public
Spliterator
<
Entry
<
K
,
V
>>
trySplit
()
{
Spliterator
<
Entry
<
K
,
V
>>
split
=
s
.
trySplit
();
return
split
==
null
?
null
:
new
UnmodifiableEntrySetSpliterator
<>(
split
);
}
@Override
public
long
estimateSize
()
{
return
s
.
estimateSize
();
}
@Override
public
long
getExactSizeIfKnown
()
{
return
s
.
getExactSizeIfKnown
();
}
@Override
public
int
characteristics
()
{
return
s
.
characteristics
();
}
@Override
public
boolean
hasCharacteristics
(
int
characteristics
)
{
return
s
.
hasCharacteristics
(
characteristics
);
}
@Override
public
Comparator
<?
super
Entry
<
K
,
V
>>
getComparator
()
{
return
s
.
getComparator
();
}
}
@SuppressWarnings
(
"unchecked"
)
public
Spliterator
<
Entry
<
K
,
V
>>
spliterator
()
{
return
new
UnmodifiableEntrySetSpliterator
<>(
(
Spliterator
<
Map
.
Entry
<
K
,
V
>>)
c
.
spliterator
());
}
@Override
public
Stream
<
Entry
<
K
,
V
>>
stream
()
{
return
StreamSupport
.
stream
(
spliterator
());
}
@Override
public
Stream
<
Entry
<
K
,
V
>>
parallelStream
()
{
return
StreamSupport
.
parallelStream
(
spliterator
());
}
public
Iterator
<
Map
.
Entry
<
K
,
V
>>
iterator
()
{
public
Iterator
<
Map
.
Entry
<
K
,
V
>>
iterator
()
{
return
new
Iterator
<
Map
.
Entry
<
K
,
V
>>()
{
return
new
Iterator
<
Map
.
Entry
<
K
,
V
>>()
{
private
final
Iterator
<?
extends
Map
.
Entry
<?
extends
K
,
?
extends
V
>>
i
=
c
.
iterator
();
private
final
Iterator
<?
extends
Map
.
Entry
<?
extends
K
,
?
extends
V
>>
i
=
c
.
iterator
();
...
...
src/share/classes/java/util/Formatter.java
浏览文件 @
4d0e56aa
...
@@ -190,7 +190,7 @@ import sun.misc.FormattedFloatingDecimal;
...
@@ -190,7 +190,7 @@ import sun.misc.FormattedFloatingDecimal;
* <p> The optional <i>flags</i> is a set of characters that modify the output
* <p> The optional <i>flags</i> is a set of characters that modify the output
* format. The set of valid flags depends on the conversion.
* format. The set of valid flags depends on the conversion.
*
*
* <p> The optional <i>width</i> is a
non-nega
tive decimal integer indicating
* <p> The optional <i>width</i> is a
posi
tive decimal integer indicating
* the minimum number of characters to be written to the output.
* the minimum number of characters to be written to the output.
*
*
* <p> The optional <i>precision</i> is a non-negative decimal integer usually
* <p> The optional <i>precision</i> is a non-negative decimal integer usually
...
...
src/share/classes/java/util/Spliterator.java
浏览文件 @
4d0e56aa
...
@@ -62,10 +62,10 @@ import java.util.function.LongConsumer;
...
@@ -62,10 +62,10 @@ import java.util.function.LongConsumer;
* New characteristics may be defined in the future, so implementors should not
* New characteristics may be defined in the future, so implementors should not
* assign meanings to unlisted values.
* assign meanings to unlisted values.
*
*
* <p><a name="binding"
/
>A Spliterator that does not report {@code IMMUTABLE} or
* <p><a name="binding">A Spliterator that does not report {@code IMMUTABLE} or
* {@code CONCURRENT} is expected to have a documented policy concerning:
* {@code CONCURRENT} is expected to have a documented policy concerning:
* when the spliterator <em>binds</em> to the element source; and detection of
* when the spliterator <em>binds</em> to the element source; and detection of
* structural interference of the element source detected after binding. A
* structural interference of the element source detected after binding.
</a>
A
* <em>late-binding</em> Spliterator binds to the source of elements at the
* <em>late-binding</em> Spliterator binds to the source of elements at the
* point of first traversal, first split, or first query for estimated size,
* point of first traversal, first split, or first query for estimated size,
* rather than at the time the Spliterator is created. A Spliterator that is
* rather than at the time the Spliterator is created. A Spliterator that is
...
@@ -429,6 +429,7 @@ public interface Spliterator<T> {
...
@@ -429,6 +429,7 @@ public interface Spliterator<T> {
* The default implementation returns true if the corresponding bits
* The default implementation returns true if the corresponding bits
* of the given characteristics are set.
* of the given characteristics are set.
*
*
* @param characteristics the characteristics to check for
* @return {@code true} if all the specified characteristics are present,
* @return {@code true} if all the specified characteristics are present,
* else {@code false}
* else {@code false}
*/
*/
...
...
src/share/classes/java/util/concurrent/ConcurrentHashMap.java
浏览文件 @
4d0e56aa
此差异已折叠。
点击以展开。
src/share/classes/java/util/concurrent/ConcurrentMap.java
浏览文件 @
4d0e56aa
...
@@ -39,8 +39,8 @@ import java.util.Objects;
...
@@ -39,8 +39,8 @@ import java.util.Objects;
import
java.util.function.BiFunction
;
import
java.util.function.BiFunction
;
/**
/**
* A {@link java.util.Map} providing
additional atomic
* A {@link java.util.Map} providing
thread safety and atomicity
*
{@code putIfAbsent}, {@code remove}, and {@code replace} method
s.
*
guarantee
s.
*
*
* <p>Memory consistency effects: As with other concurrent
* <p>Memory consistency effects: As with other concurrent
* collections, actions in a thread prior to placing an object into a
* collections, actions in a thread prior to placing an object into a
...
@@ -89,11 +89,11 @@ public interface ConcurrentMap<K, V> extends Map<K, V> {
...
@@ -89,11 +89,11 @@ public interface ConcurrentMap<K, V> extends Map<K, V> {
* @param key key with which the specified value is to be associated
* @param key key with which the specified value is to be associated
* @param value value to be associated with the specified key
* @param value value to be associated with the specified key
* @return the previous value associated with the specified key, or
* @return the previous value associated with the specified key, or
*
<tt>null</tt>
if there was no mapping for the key.
*
{@code null}
if there was no mapping for the key.
* (A
<tt>null</tt>
return can also indicate that the map
* (A
{@code null}
return can also indicate that the map
* previously associated
<tt>null</tt>
with the key,
* previously associated
{@code null}
with the key,
* if the implementation supports null values.)
* if the implementation supports null values.)
* @throws UnsupportedOperationException if the
<tt>put</tt>
operation
* @throws UnsupportedOperationException if the
{@code put}
operation
* is not supported by this map
* is not supported by this map
* @throws ClassCastException if the class of the specified key or value
* @throws ClassCastException if the class of the specified key or value
* prevents it from being stored in this map
* prevents it from being stored in this map
...
...
src/share/classes/java/util/concurrent/ConcurrentNavigableMap.java
浏览文件 @
4d0e56aa
...
@@ -101,7 +101,7 @@ public interface ConcurrentNavigableMap<K,V>
...
@@ -101,7 +101,7 @@ public interface ConcurrentNavigableMap<K,V>
* reflected in the descending map, and vice-versa.
* reflected in the descending map, and vice-versa.
*
*
* <p>The returned map has an ordering equivalent to
* <p>The returned map has an ordering equivalent to
*
<tt>{@link Collections#reverseOrder(Comparator) Collections.reverseOrder}(comparator())</tt>
.
*
{@link Collections#reverseOrder(Comparator) Collections.reverseOrder}{@code (comparator())}
.
* The expression {@code m.descendingMap().descendingMap()} returns a
* The expression {@code m.descendingMap().descendingMap()} returns a
* view of {@code m} essentially equivalent to {@code m}.
* view of {@code m} essentially equivalent to {@code m}.
*
*
...
...
src/share/classes/java/util/stream/AbstractShortCircuitTask.java
浏览文件 @
4d0e56aa
...
@@ -92,22 +92,51 @@ abstract class AbstractShortCircuitTask<P_IN, P_OUT, R,
...
@@ -92,22 +92,51 @@ abstract class AbstractShortCircuitTask<P_IN, P_OUT, R,
*/
*/
protected
abstract
R
getEmptyResult
();
protected
abstract
R
getEmptyResult
();
/**
* Overrides AbstractTask version to include checks for early
* exits while splitting or computing.
*/
@Override
@Override
protected
boolean
canCompute
()
{
public
void
compute
()
{
// Have we already found an answer?
Spliterator
<
P_IN
>
rs
=
spliterator
,
ls
;
if
(
sharedResult
.
get
()
!=
null
)
{
long
sizeEstimate
=
rs
.
estimateSize
();
tryComplete
();
long
sizeThreshold
=
getTargetSize
(
sizeEstimate
);
return
false
;
boolean
forkRight
=
false
;
}
else
if
(
taskCanceled
())
{
@SuppressWarnings
(
"unchecked"
)
K
task
=
(
K
)
this
;
setLocalResult
(
getEmptyResult
());
AtomicReference
<
R
>
sr
=
sharedResult
;
tryComplete
();
R
result
;
return
false
;
while
((
result
=
sr
.
get
())
==
null
)
{
}
if
(
task
.
taskCanceled
())
{
else
{
result
=
task
.
getEmptyResult
();
return
true
;
break
;
}
if
(
sizeEstimate
<=
sizeThreshold
||
(
ls
=
rs
.
trySplit
())
==
null
)
{
result
=
task
.
doLeaf
();
break
;
}
K
leftChild
,
rightChild
,
taskToFork
;
task
.
leftChild
=
leftChild
=
task
.
makeChild
(
ls
);
task
.
rightChild
=
rightChild
=
task
.
makeChild
(
rs
);
task
.
setPendingCount
(
1
);
if
(
forkRight
)
{
forkRight
=
false
;
rs
=
ls
;
task
=
leftChild
;
taskToFork
=
rightChild
;
}
else
{
forkRight
=
true
;
task
=
rightChild
;
taskToFork
=
leftChild
;
}
taskToFork
.
fork
();
sizeEstimate
=
rs
.
estimateSize
();
}
}
task
.
setLocalResult
(
result
);
task
.
tryComplete
();
}
}
/**
/**
* Declares that a globally valid result has been found. If another task has
* Declares that a globally valid result has been found. If another task has
* not already found the answer, the result is installed in
* not already found the answer, the result is installed in
...
...
src/share/classes/java/util/stream/AbstractTask.java
浏览文件 @
4d0e56aa
...
@@ -102,7 +102,7 @@ abstract class AbstractTask<P_IN, P_OUT, R,
...
@@ -102,7 +102,7 @@ abstract class AbstractTask<P_IN, P_OUT, R,
protected
Spliterator
<
P_IN
>
spliterator
;
protected
Spliterator
<
P_IN
>
spliterator
;
/** Target leaf size, common to all tasks in a computation */
/** Target leaf size, common to all tasks in a computation */
protected
final
long
targetSize
;
protected
long
targetSize
;
// may be laziliy initialized
/**
/**
* The left child.
* The left child.
...
@@ -134,7 +134,7 @@ abstract class AbstractTask<P_IN, P_OUT, R,
...
@@ -134,7 +134,7 @@ abstract class AbstractTask<P_IN, P_OUT, R,
super
(
null
);
super
(
null
);
this
.
helper
=
helper
;
this
.
helper
=
helper
;
this
.
spliterator
=
spliterator
;
this
.
spliterator
=
spliterator
;
this
.
targetSize
=
suggestTargetSize
(
spliterator
.
estimateSize
())
;
this
.
targetSize
=
0L
;
}
}
/**
/**
...
@@ -182,27 +182,13 @@ abstract class AbstractTask<P_IN, P_OUT, R,
...
@@ -182,27 +182,13 @@ abstract class AbstractTask<P_IN, P_OUT, R,
}
}
/**
/**
* Returns a suggestion whether it is advisable to split the provided
* Returns the targetSize, initializing it via the supplied
* spliterator based on target size and other considerations, such as pool
* size estimate if not already initialized.
* state.
*
* @return {@code true} if a split is advised otherwise {@code false}
*/
*/
public
static
boolean
suggestSplit
(
Spliterator
spliterator
,
protected
final
long
getTargetSize
(
long
sizeEstimate
)
{
long
targetSize
)
{
long
s
;
long
remaining
=
spliterator
.
estimateSize
();
return
((
s
=
targetSize
)
!=
0
?
s
:
return
(
remaining
>
targetSize
);
(
targetSize
=
suggestTargetSize
(
sizeEstimate
)));
// @@@ May additionally want to fold in pool characteristics such as surplus task count
}
/**
* Returns a suggestion whether it is adviseable to split this task based on
* target size and other considerations.
*
* @return {@code true} if a split is advised otherwise {@code false}
*/
public
boolean
suggestSplit
()
{
return
suggestSplit
(
spliterator
,
targetSize
);
}
}
/**
/**
...
@@ -285,43 +271,46 @@ abstract class AbstractTask<P_IN, P_OUT, R,
...
@@ -285,43 +271,46 @@ abstract class AbstractTask<P_IN, P_OUT, R,
}
}
/**
/**
* Decides whether or not to split a task further or compute it directly. If
* Decides whether or not to split a task further or compute it
* computing directly, call {@code doLeaf} and pass the result to
* directly. If computing directly, calls {@code doLeaf} and pass
* {@code setRawResult}. If splitting, set up the child-related fields,
* the result to {@code setRawResult}. Otherwise splits off
* create the child tasks, fork the leftmost (prefix) child tasks, and
* subtasks, forking one and continuing as the other.
* compute the rightmost (remaining) child tasks.
*
*
* <p>
* <p> The method is structured to conserve resources across a
* Computing will continue for rightmost tasks while a task can be computed
* range of uses. The loop continues with one of the child tasks
* as determined by {@link #canCompute()} and that task should and can be
* when split, to avoid deep recursion. To cope with spliterators
* split into left and right tasks.
* that may be systematically biased toward left-heavy or
*
* right-heavy splits, we alternate which child is forked versus
* <p>
* continued in the loop.
* The rightmost tasks are computed in a loop rather than recursively to
* avoid potential stack overflows when computing with a right-balanced
* tree, such as that produced when splitting with a {@link Spliterator}
* created from an {@link java.util.Iterator}.
*/
*/
@Override
@Override
public
final
void
compute
()
{
public
void
compute
()
{
@SuppressWarnings
(
"unchecked"
)
Spliterator
<
P_IN
>
rs
=
spliterator
,
ls
;
// right, left spliterators
K
task
=
(
K
)
this
;
long
sizeEstimate
=
rs
.
estimateSize
();
while
(
task
.
canCompute
())
{
long
sizeThreshold
=
getTargetSize
(
sizeEstimate
);
Spliterator
<
P_IN
>
split
;
boolean
forkRight
=
false
;
if
(!
task
.
suggestSplit
()
||
(
split
=
task
.
spliterator
.
trySplit
())
==
null
)
{
@SuppressWarnings
(
"unchecked"
)
K
task
=
(
K
)
this
;
task
.
setLocalResult
(
task
.
doLeaf
());
while
(
sizeEstimate
>
sizeThreshold
&&
(
ls
=
rs
.
trySplit
())
!=
null
)
{
task
.
tryComplete
();
K
leftChild
,
rightChild
,
taskToFork
;
return
;
task
.
leftChild
=
leftChild
=
task
.
makeChild
(
ls
);
task
.
rightChild
=
rightChild
=
task
.
makeChild
(
rs
);
task
.
setPendingCount
(
1
);
if
(
forkRight
)
{
forkRight
=
false
;
rs
=
ls
;
task
=
leftChild
;
taskToFork
=
rightChild
;
}
}
else
{
else
{
K
l
=
task
.
leftChild
=
task
.
makeChild
(
split
);
forkRight
=
true
;
K
r
=
task
.
rightChild
=
task
.
makeChild
(
task
.
spliterator
);
task
=
rightChild
;
task
.
spliterator
=
null
;
taskToFork
=
leftChild
;
task
.
setPendingCount
(
1
);
l
.
fork
();
task
=
r
;
}
}
taskToFork
.
fork
();
sizeEstimate
=
rs
.
estimateSize
();
}
}
task
.
setLocalResult
(
task
.
doLeaf
());
task
.
tryComplete
();
}
}
/**
/**
...
@@ -338,21 +327,6 @@ abstract class AbstractTask<P_IN, P_OUT, R,
...
@@ -338,21 +327,6 @@ abstract class AbstractTask<P_IN, P_OUT, R,
leftChild
=
rightChild
=
null
;
leftChild
=
rightChild
=
null
;
}
}
/**
* Determines if the task can be computed.
*
* @implSpec The default always returns true
*
* @return {@code true} if this task can be computed to either calculate the
* leaf via {@link #doLeaf()} or split, otherwise false if this task
* cannot be computed, for example if this task has been canceled
* and/or a result for the computation has been found by another
* task.
*/
protected
boolean
canCompute
()
{
return
true
;
}
/**
/**
* Returns whether this node is a "leftmost" node -- whether the path from
* Returns whether this node is a "leftmost" node -- whether the path from
* the root to this node involves only traversing leftmost child links. For
* the root to this node involves only traversing leftmost child links. For
...
...
src/share/classes/java/util/stream/ForEachOps.java
浏览文件 @
4d0e56aa
...
@@ -28,6 +28,7 @@ import java.util.Objects;
...
@@ -28,6 +28,7 @@ import java.util.Objects;
import
java.util.Spliterator
;
import
java.util.Spliterator
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.CountedCompleter
;
import
java.util.concurrent.CountedCompleter
;
import
java.util.concurrent.ForkJoinTask
;
import
java.util.function.Consumer
;
import
java.util.function.Consumer
;
import
java.util.function.DoubleConsumer
;
import
java.util.function.DoubleConsumer
;
import
java.util.function.IntConsumer
;
import
java.util.function.IntConsumer
;
...
@@ -128,7 +129,7 @@ final class ForEachOps {
...
@@ -128,7 +129,7 @@ final class ForEachOps {
*
*
* @param <T> the output type of the stream pipeline
* @param <T> the output type of the stream pipeline
*/
*/
private
static
abstract
class
ForEachOp
<
T
>
static
abstract
class
ForEachOp
<
T
>
implements
TerminalOp
<
T
,
Void
>,
TerminalSink
<
T
,
Void
>
{
implements
TerminalOp
<
T
,
Void
>,
TerminalSink
<
T
,
Void
>
{
private
final
boolean
ordered
;
private
final
boolean
ordered
;
...
@@ -169,7 +170,7 @@ final class ForEachOps {
...
@@ -169,7 +170,7 @@ final class ForEachOps {
// Implementations
// Implementations
/** Implementation class for reference streams */
/** Implementation class for reference streams */
private
static
class
OfRef
<
T
>
extends
ForEachOp
<
T
>
{
static
final
class
OfRef
<
T
>
extends
ForEachOp
<
T
>
{
final
Consumer
<?
super
T
>
consumer
;
final
Consumer
<?
super
T
>
consumer
;
OfRef
(
Consumer
<?
super
T
>
consumer
,
boolean
ordered
)
{
OfRef
(
Consumer
<?
super
T
>
consumer
,
boolean
ordered
)
{
...
@@ -184,7 +185,7 @@ final class ForEachOps {
...
@@ -184,7 +185,7 @@ final class ForEachOps {
}
}
/** Implementation class for {@code IntStream} */
/** Implementation class for {@code IntStream} */
private
static
class
OfInt
extends
ForEachOp
<
Integer
>
static
final
class
OfInt
extends
ForEachOp
<
Integer
>
implements
Sink
.
OfInt
{
implements
Sink
.
OfInt
{
final
IntConsumer
consumer
;
final
IntConsumer
consumer
;
...
@@ -205,7 +206,7 @@ final class ForEachOps {
...
@@ -205,7 +206,7 @@ final class ForEachOps {
}
}
/** Implementation class for {@code LongStream} */
/** Implementation class for {@code LongStream} */
private
static
class
OfLong
extends
ForEachOp
<
Long
>
static
final
class
OfLong
extends
ForEachOp
<
Long
>
implements
Sink
.
OfLong
{
implements
Sink
.
OfLong
{
final
LongConsumer
consumer
;
final
LongConsumer
consumer
;
...
@@ -226,7 +227,7 @@ final class ForEachOps {
...
@@ -226,7 +227,7 @@ final class ForEachOps {
}
}
/** Implementation class for {@code DoubleStream} */
/** Implementation class for {@code DoubleStream} */
private
static
class
OfDouble
extends
ForEachOp
<
Double
>
static
final
class
OfDouble
extends
ForEachOp
<
Double
>
implements
Sink
.
OfDouble
{
implements
Sink
.
OfDouble
{
final
DoubleConsumer
consumer
;
final
DoubleConsumer
consumer
;
...
@@ -248,20 +249,20 @@ final class ForEachOps {
...
@@ -248,20 +249,20 @@ final class ForEachOps {
}
}
/** A {@code ForkJoinTask} for performing a parallel for-each operation */
/** A {@code ForkJoinTask} for performing a parallel for-each operation */
private
static
class
ForEachTask
<
S
,
T
>
extends
CountedCompleter
<
Void
>
{
static
final
class
ForEachTask
<
S
,
T
>
extends
CountedCompleter
<
Void
>
{
private
Spliterator
<
S
>
spliterator
;
private
Spliterator
<
S
>
spliterator
;
private
final
Sink
<
S
>
sink
;
private
final
Sink
<
S
>
sink
;
private
final
PipelineHelper
<
T
>
helper
;
private
final
PipelineHelper
<
T
>
helper
;
private
final
long
targetSize
;
private
long
targetSize
;
ForEachTask
(
PipelineHelper
<
T
>
helper
,
ForEachTask
(
PipelineHelper
<
T
>
helper
,
Spliterator
<
S
>
spliterator
,
Spliterator
<
S
>
spliterator
,
Sink
<
S
>
sink
)
{
Sink
<
S
>
sink
)
{
super
(
null
);
super
(
null
);
this
.
spliterator
=
spliterator
;
this
.
sink
=
sink
;
this
.
sink
=
sink
;
this
.
targetSize
=
AbstractTask
.
suggestTargetSize
(
spliterator
.
estimateSize
());
this
.
helper
=
helper
;
this
.
helper
=
helper
;
this
.
spliterator
=
spliterator
;
this
.
targetSize
=
0L
;
}
}
ForEachTask
(
ForEachTask
<
S
,
T
>
parent
,
Spliterator
<
S
>
spliterator
)
{
ForEachTask
(
ForEachTask
<
S
,
T
>
parent
,
Spliterator
<
S
>
spliterator
)
{
...
@@ -272,28 +273,40 @@ final class ForEachOps {
...
@@ -272,28 +273,40 @@ final class ForEachOps {
this
.
helper
=
parent
.
helper
;
this
.
helper
=
parent
.
helper
;
}
}
// Similar to AbstractTask but doesn't need to track child tasks
public
void
compute
()
{
public
void
compute
()
{
Spliterator
<
S
>
rightSplit
=
spliterator
,
leftSplit
;
long
sizeEstimate
=
rightSplit
.
estimateSize
(),
sizeThreshold
;
if
((
sizeThreshold
=
targetSize
)
==
0L
)
targetSize
=
sizeThreshold
=
AbstractTask
.
suggestTargetSize
(
sizeEstimate
);
boolean
isShortCircuit
=
StreamOpFlag
.
SHORT_CIRCUIT
.
isKnown
(
helper
.
getStreamAndOpFlags
());
boolean
isShortCircuit
=
StreamOpFlag
.
SHORT_CIRCUIT
.
isKnown
(
helper
.
getStreamAndOpFlags
());
while
(
true
)
{
boolean
forkRight
=
false
;
if
(
isShortCircuit
&&
sink
.
cancellationRequested
())
{
Sink
<
S
>
taskSink
=
sink
;
propagateCompletion
();
ForEachTask
<
S
,
T
>
task
=
this
;
spliterator
=
null
;
while
(!
isShortCircuit
||
!
taskSink
.
cancellationRequested
())
{
return
;
if
(
sizeEstimate
<=
sizeThreshold
||
(
leftSplit
=
rightSplit
.
trySplit
())
==
null
)
{
task
.
helper
.
copyInto
(
taskSink
,
rightSplit
);
break
;
}
}
ForEachTask
<
S
,
T
>
leftTask
=
new
ForEachTask
<>(
task
,
leftSplit
);
Spliterator
<
S
>
split
;
task
.
addToPendingCount
(
1
)
;
if
(!
AbstractTask
.
suggestSplit
(
spliterator
,
targetSize
)
ForEachTask
<
S
,
T
>
taskToFork
;
||
(
split
=
spliterator
.
trySplit
())
==
null
)
{
if
(
forkRight
)
{
helper
.
copyInto
(
sink
,
spliterator
)
;
forkRight
=
false
;
propagateCompletion
()
;
rightSplit
=
leftSplit
;
spliterator
=
null
;
taskToFork
=
task
;
return
;
task
=
leftTask
;
}
}
else
{
else
{
addToPendingCount
(
1
)
;
forkRight
=
true
;
new
ForEachTask
<>(
this
,
split
).
fork
()
;
taskToFork
=
leftTask
;
}
}
taskToFork
.
fork
();
sizeEstimate
=
rightSplit
.
estimateSize
();
}
}
task
.
spliterator
=
null
;
task
.
propagateCompletion
();
}
}
}
}
...
@@ -301,7 +314,7 @@ final class ForEachOps {
...
@@ -301,7 +314,7 @@ final class ForEachOps {
* A {@code ForkJoinTask} for performing a parallel for-each operation
* A {@code ForkJoinTask} for performing a parallel for-each operation
* which visits the elements in encounter order
* which visits the elements in encounter order
*/
*/
private
static
class
ForEachOrderedTask
<
S
,
T
>
extends
CountedCompleter
<
Void
>
{
static
final
class
ForEachOrderedTask
<
S
,
T
>
extends
CountedCompleter
<
Void
>
{
private
final
PipelineHelper
<
T
>
helper
;
private
final
PipelineHelper
<
T
>
helper
;
private
Spliterator
<
S
>
spliterator
;
private
Spliterator
<
S
>
spliterator
;
private
final
long
targetSize
;
private
final
long
targetSize
;
...
@@ -343,39 +356,49 @@ final class ForEachOps {
...
@@ -343,39 +356,49 @@ final class ForEachOps {
}
}
private
static
<
S
,
T
>
void
doCompute
(
ForEachOrderedTask
<
S
,
T
>
task
)
{
private
static
<
S
,
T
>
void
doCompute
(
ForEachOrderedTask
<
S
,
T
>
task
)
{
while
(
true
)
{
Spliterator
<
S
>
rightSplit
=
task
.
spliterator
,
leftSplit
;
Spliterator
<
S
>
split
;
long
sizeThreshold
=
task
.
targetSize
;
if
(!
AbstractTask
.
suggestSplit
(
task
.
spliterator
,
task
.
targetSize
)
boolean
forkRight
=
false
;
||
(
split
=
task
.
spliterator
.
trySplit
())
==
null
)
{
while
(
rightSplit
.
estimateSize
()
>
sizeThreshold
&&
if
(
task
.
getPendingCount
()
==
0
)
{
(
leftSplit
=
rightSplit
.
trySplit
())
!=
null
)
{
task
.
helper
.
wrapAndCopyInto
(
task
.
action
,
task
.
spliterator
);
ForEachOrderedTask
<
S
,
T
>
leftChild
=
}
new
ForEachOrderedTask
<>(
task
,
leftSplit
,
task
.
leftPredecessor
);
else
{
ForEachOrderedTask
<
S
,
T
>
rightChild
=
Node
.
Builder
<
T
>
nb
=
task
.
helper
.
makeNodeBuilder
(
new
ForEachOrderedTask
<>(
task
,
rightSplit
,
leftChild
);
task
.
helper
.
exactOutputSizeIfKnown
(
task
.
spliterator
),
task
.
completionMap
.
put
(
leftChild
,
rightChild
);
size
->
(
T
[])
new
Object
[
size
]);
task
.
addToPendingCount
(
1
);
// forking
task
.
node
=
task
.
helper
.
wrapAndCopyInto
(
nb
,
task
.
spliterator
).
build
();
rightChild
.
addToPendingCount
(
1
);
// right pending on left child
}
if
(
task
.
leftPredecessor
!=
null
)
{
task
.
tryComplete
();
leftChild
.
addToPendingCount
(
1
);
// left pending on previous subtree, except left spine
return
;
if
(
task
.
completionMap
.
replace
(
task
.
leftPredecessor
,
task
,
leftChild
))
task
.
addToPendingCount
(-
1
);
// transfer my "right child" count to my left child
else
leftChild
.
addToPendingCount
(-
1
);
// left child is ready to go when ready
}
ForEachOrderedTask
<
S
,
T
>
taskToFork
;
if
(
forkRight
)
{
forkRight
=
false
;
rightSplit
=
leftSplit
;
task
=
leftChild
;
taskToFork
=
rightChild
;
}
}
else
{
else
{
ForEachOrderedTask
<
S
,
T
>
leftChild
=
new
ForEachOrderedTask
<>(
task
,
split
,
task
.
leftPredecessor
);
forkRight
=
true
;
ForEachOrderedTask
<
S
,
T
>
rightChild
=
new
ForEachOrderedTask
<>(
task
,
task
.
spliterator
,
leftChild
);
task
.
completionMap
.
put
(
leftChild
,
rightChild
);
task
.
addToPendingCount
(
1
);
// forking
rightChild
.
addToPendingCount
(
1
);
// right pending on left child
if
(
task
.
leftPredecessor
!=
null
)
{
leftChild
.
addToPendingCount
(
1
);
// left pending on previous subtree, except left spine
if
(
task
.
completionMap
.
replace
(
task
.
leftPredecessor
,
task
,
leftChild
))
task
.
addToPendingCount
(-
1
);
// transfer my "right child" count to my left child
else
leftChild
.
addToPendingCount
(-
1
);
// left child is ready to go when ready
}
leftChild
.
fork
();
task
=
rightChild
;
task
=
rightChild
;
taskToFork
=
leftChild
;
}
}
taskToFork
.
fork
();
}
if
(
task
.
getPendingCount
()
==
0
)
{
task
.
helper
.
wrapAndCopyInto
(
task
.
action
,
rightSplit
);
}
else
{
Node
.
Builder
<
T
>
nb
=
task
.
helper
.
makeNodeBuilder
(
task
.
helper
.
exactOutputSizeIfKnown
(
rightSplit
),
size
->
(
T
[])
new
Object
[
size
]);
task
.
node
=
task
.
helper
.
wrapAndCopyInto
(
nb
,
rightSplit
).
build
();
}
}
task
.
tryComplete
();
}
}
@Override
@Override
...
...
src/share/classes/java/util/stream/Nodes.java
浏览文件 @
4d0e56aa
...
@@ -1829,25 +1829,20 @@ final class Nodes {
...
@@ -1829,25 +1829,20 @@ final class Nodes {
@Override
@Override
public
void
compute
()
{
public
void
compute
()
{
SizedCollectorTask
<
P_IN
,
P_OUT
,
T_SINK
,
K
>
task
=
this
;
SizedCollectorTask
<
P_IN
,
P_OUT
,
T_SINK
,
K
>
task
=
this
;
while
(
true
)
{
Spliterator
<
P_IN
>
rightSplit
=
spliterator
,
leftSplit
;
Spliterator
<
P_IN
>
leftSplit
;
while
(
rightSplit
.
estimateSize
()
>
task
.
targetSize
&&
if
(!
AbstractTask
.
suggestSplit
(
task
.
spliterator
,
task
.
targetSize
)
(
leftSplit
=
rightSplit
.
trySplit
())
!=
null
)
{
||
((
leftSplit
=
task
.
spliterator
.
trySplit
())
==
null
))
{
task
.
setPendingCount
(
1
);
if
(
task
.
offset
+
task
.
length
>=
MAX_ARRAY_SIZE
)
long
leftSplitSize
=
leftSplit
.
estimateSize
();
throw
new
IllegalArgumentException
(
"Stream size exceeds max array size"
);
task
.
makeChild
(
leftSplit
,
task
.
offset
,
leftSplitSize
).
fork
();
T_SINK
sink
=
(
T_SINK
)
task
;
task
=
task
.
makeChild
(
rightSplit
,
task
.
offset
+
leftSplitSize
,
task
.
helper
.
wrapAndCopyInto
(
sink
,
task
.
spliterator
);
task
.
length
-
leftSplitSize
);
task
.
propagateCompletion
();
}
return
;
if
(
task
.
offset
+
task
.
length
>=
MAX_ARRAY_SIZE
)
}
throw
new
IllegalArgumentException
(
"Stream size exceeds max array size"
);
else
{
T_SINK
sink
=
(
T_SINK
)
task
;
task
.
setPendingCount
(
1
);
task
.
helper
.
wrapAndCopyInto
(
sink
,
rightSplit
);
long
leftSplitSize
=
leftSplit
.
estimateSize
();
task
.
propagateCompletion
();
task
.
makeChild
(
leftSplit
,
task
.
offset
,
leftSplitSize
).
fork
();
task
=
task
.
makeChild
(
task
.
spliterator
,
task
.
offset
+
leftSplitSize
,
task
.
length
-
leftSplitSize
);
}
}
}
}
abstract
K
makeChild
(
Spliterator
<
P_IN
>
spliterator
,
long
offset
,
long
size
);
abstract
K
makeChild
(
Spliterator
<
P_IN
>
spliterator
,
long
offset
,
long
size
);
...
...
src/share/classes/javax/management/JMX.java
浏览文件 @
4d0e56aa
...
@@ -160,6 +160,10 @@ public class JMX {
...
@@ -160,6 +160,10 @@ public class JMX {
* example, then the return type is {@code MyMBean}.
* example, then the return type is {@code MyMBean}.
*
*
* @return the new proxy instance.
* @return the new proxy instance.
*
* @throws IllegalArgumentException if {@code interfaceClass} is not
* a <a href="package-summary.html#mgIface">compliant MBean
* interface</a>
*/
*/
public
static
<
T
>
T
newMBeanProxy
(
MBeanServerConnection
connection
,
public
static
<
T
>
T
newMBeanProxy
(
MBeanServerConnection
connection
,
ObjectName
objectName
,
ObjectName
objectName
,
...
@@ -200,6 +204,10 @@ public class JMX {
...
@@ -200,6 +204,10 @@ public class JMX {
* example, then the return type is {@code MyMBean}.
* example, then the return type is {@code MyMBean}.
*
*
* @return the new proxy instance.
* @return the new proxy instance.
*
* @throws IllegalArgumentException if {@code interfaceClass} is not
* a <a href="package-summary.html#mgIface">compliant MBean
* interface</a>
*/
*/
public
static
<
T
>
T
newMBeanProxy
(
MBeanServerConnection
connection
,
public
static
<
T
>
T
newMBeanProxy
(
MBeanServerConnection
connection
,
ObjectName
objectName
,
ObjectName
objectName
,
...
@@ -298,6 +306,9 @@ public class JMX {
...
@@ -298,6 +306,9 @@ public class JMX {
* example, then the return type is {@code MyMXBean}.
* example, then the return type is {@code MyMXBean}.
*
*
* @return the new proxy instance.
* @return the new proxy instance.
*
* @throws IllegalArgumentException if {@code interfaceClass} is not
* a {@link javax.management.MXBean compliant MXBean interface}
*/
*/
public
static
<
T
>
T
newMXBeanProxy
(
MBeanServerConnection
connection
,
public
static
<
T
>
T
newMXBeanProxy
(
MBeanServerConnection
connection
,
ObjectName
objectName
,
ObjectName
objectName
,
...
@@ -338,6 +349,9 @@ public class JMX {
...
@@ -338,6 +349,9 @@ public class JMX {
* example, then the return type is {@code MyMXBean}.
* example, then the return type is {@code MyMXBean}.
*
*
* @return the new proxy instance.
* @return the new proxy instance.
*
* @throws IllegalArgumentException if {@code interfaceClass} is not
* a {@link javax.management.MXBean compliant MXBean interface}
*/
*/
public
static
<
T
>
T
newMXBeanProxy
(
MBeanServerConnection
connection
,
public
static
<
T
>
T
newMXBeanProxy
(
MBeanServerConnection
connection
,
ObjectName
objectName
,
ObjectName
objectName
,
...
@@ -348,21 +362,25 @@ public class JMX {
...
@@ -348,21 +362,25 @@ public class JMX {
/**
/**
* <p>Test whether an interface is an MXBean interface.
* <p>Test whether an interface is an MXBean interface.
* An interface is an MXBean interface if it is
annotated
* An interface is an MXBean interface if it is
public,
* {@link MXBean @MXBean} or {@code @MXBean(true)}
*
annotated
{@link MXBean @MXBean} or {@code @MXBean(true)}
* or if it does not have an {@code @MXBean} annotation
* or if it does not have an {@code @MXBean} annotation
* and its name ends with "{@code MXBean}".</p>
* and its name ends with "{@code MXBean}".</p>
*
*
* @param interfaceClass The candidate interface.
* @param interfaceClass The candidate interface.
*
*
* @return true if {@code interfaceClass} is a
n interface and
* @return true if {@code interfaceClass} is a
*
meets the conditions described.
*
{@link javax.management.MXBean compliant MXBean interface}
*
*
* @throws NullPointerException if {@code interfaceClass} is null.
* @throws NullPointerException if {@code interfaceClass} is null.
*/
*/
public
static
boolean
isMXBeanInterface
(
Class
<?>
interfaceClass
)
{
public
static
boolean
isMXBeanInterface
(
Class
<?>
interfaceClass
)
{
if
(!
interfaceClass
.
isInterface
())
if
(!
interfaceClass
.
isInterface
())
return
false
;
return
false
;
if
(!
Modifier
.
isPublic
(
interfaceClass
.
getModifiers
())
&&
!
Introspector
.
ALLOW_NONPUBLIC_MBEAN
)
{
return
false
;
}
MXBean
a
=
interfaceClass
.
getAnnotation
(
MXBean
.
class
);
MXBean
a
=
interfaceClass
.
getAnnotation
(
MXBean
.
class
);
if
(
a
!=
null
)
if
(
a
!=
null
)
return
a
.
value
();
return
a
.
value
();
...
@@ -389,9 +407,6 @@ public class JMX {
...
@@ -389,9 +407,6 @@ public class JMX {
boolean
notificationEmitter
,
boolean
notificationEmitter
,
boolean
isMXBean
)
{
boolean
isMXBean
)
{
if
(
System
.
getSecurityManager
()
!=
null
)
{
checkProxyInterface
(
interfaceClass
);
}
try
{
try
{
if
(
isMXBean
)
{
if
(
isMXBean
)
{
// Check interface for MXBean compliance
// Check interface for MXBean compliance
...
@@ -419,17 +434,4 @@ public class JMX {
...
@@ -419,17 +434,4 @@ public class JMX {
handler
);
handler
);
return
interfaceClass
.
cast
(
proxy
);
return
interfaceClass
.
cast
(
proxy
);
}
}
/**
* Checks for the M(X)Bean proxy interface being public and not restricted
* @param interfaceClass MBean proxy interface
* @throws SecurityException when the proxy interface comes from a restricted
* package or is not public
*/
private
static
void
checkProxyInterface
(
Class
<?>
interfaceClass
)
{
if
(!
Modifier
.
isPublic
(
interfaceClass
.
getModifiers
()))
{
throw
new
SecurityException
(
"mbean proxy interface non-public"
);
}
ReflectUtil
.
checkPackageAccess
(
interfaceClass
);
}
}
}
src/share/classes/javax/management/MBeanServerInvocationHandler.java
浏览文件 @
4d0e56aa
...
@@ -225,7 +225,7 @@ public class MBeanServerInvocationHandler implements InvocationHandler {
...
@@ -225,7 +225,7 @@ public class MBeanServerInvocationHandler implements InvocationHandler {
*
*
* @return the new proxy instance.
* @return the new proxy instance.
*
*
* @see JMX#newMBeanProxy(MBeanServerConnection, ObjectName, Class)
* @see JMX#newMBeanProxy(MBeanServerConnection, ObjectName, Class
, boolean
)
*/
*/
public
static
<
T
>
T
newProxyInstance
(
MBeanServerConnection
connection
,
public
static
<
T
>
T
newProxyInstance
(
MBeanServerConnection
connection
,
ObjectName
objectName
,
ObjectName
objectName
,
...
...
src/share/classes/javax/management/MXBean.java
浏览文件 @
4d0e56aa
...
@@ -54,9 +54,9 @@ import javax.management.openmbean.TabularType;
...
@@ -54,9 +54,9 @@ import javax.management.openmbean.TabularType;
/**
/**
<p>Annotation to mark an interface explicitly as being an MXBean
<p>Annotation to mark an interface explicitly as being an MXBean
interface, or as not being an MXBean interface. By default, an
interface, or as not being an MXBean interface. By default, an
interface is an MXBean interface if it
s name ends with {@code
interface is an MXBean interface if it
is public and its name ends
MXBean}, as in {@code SomethingMXBean}. The following interfaces
with {@code MXBean}, as in {@code SomethingMXBean}. The following
are MXBean interfaces:</p>
interfaces
are MXBean interfaces:</p>
<pre>
<pre>
public interface WhatsitMXBean {}
public interface WhatsitMXBean {}
...
@@ -71,6 +71,8 @@ import javax.management.openmbean.TabularType;
...
@@ -71,6 +71,8 @@ import javax.management.openmbean.TabularType;
<p>The following interfaces are not MXBean interfaces:</p>
<p>The following interfaces are not MXBean interfaces:</p>
<pre>
<pre>
interface NonPublicInterfaceNotMXBean{}
public interface Whatsit3Interface{}
public interface Whatsit3Interface{}
@MXBean(false)
@MXBean(false)
...
...
src/share/classes/javax/management/package.html
浏览文件 @
4d0e56aa
...
@@ -53,8 +53,8 @@ questions.
...
@@ -53,8 +53,8 @@ questions.
<p>
The fundamental notion of the JMX API is the
<em>
MBean
</em>
.
<p>
The fundamental notion of the JMX API is the
<em>
MBean
</em>
.
An MBean is a named
<em>
managed object
</em>
representing a
An MBean is a named
<em>
managed object
</em>
representing a
resource. It has a
<em
>
management interface
</em>
consisting
resource. It has a
<em
id=
"mgIface"
>
management interface
</em>
of:
</p>
which must be
<em>
public
</em>
and consist
of:
</p>
<ul>
<ul>
<li>
named and typed attributes that can be read and/or
<li>
named and typed attributes that can be read and/or
...
...
src/share/classes/javax/script/ScriptEngineFactory.java
浏览文件 @
4d0e56aa
...
@@ -196,18 +196,17 @@ public interface ScriptEngineFactory {
...
@@ -196,18 +196,17 @@ public interface ScriptEngineFactory {
/**
/**
* Returns
A
valid scripting language executable progam with given statements.
* Returns
a
valid scripting language executable progam with given statements.
* For instance an implementation for a PHP engine might be:
* For instance an implementation for a PHP engine might be:
* <p>
* <p>
* <pre>{@code
* <pre>{@code
* public String getProgram(String... statements) {
* public String getProgram(String... statements) {
*
$
retval = "<?\n";
*
String
retval = "<?\n";
* int len = statements.length;
* int len = statements.length;
* for (int i = 0; i < len; i++) {
* for (int i = 0; i < len; i++) {
*
$
retval += statements[i] + ";\n";
* retval += statements[i] + ";\n";
* }
* }
* $retval += "?>";
* return retval += "?>";
*
* }
* }
* }</pre>
* }</pre>
*
*
...
...
src/share/classes/sun/management/ManagementFactoryHelper.java
浏览文件 @
4d0e56aa
...
@@ -147,18 +147,20 @@ public class ManagementFactoryHelper {
...
@@ -147,18 +147,20 @@ public class ManagementFactoryHelper {
}
}
}
}
// The logging MXBean object is an instance of
/**
// PlatformLoggingMXBean and java.util.logging.LoggingMXBean
* The logging MXBean object is an instance of
// but it can't directly implement two MXBean interfaces
* PlatformLoggingMXBean and java.util.logging.LoggingMXBean
// as a compliant MXBean implements exactly one MXBean interface,
* but it can't directly implement two MXBean interfaces
// or if it implements one interface that is a subinterface of
* as a compliant MXBean implements exactly one MXBean interface,
// all the others; otherwise, it is a non-compliant MXBean
* or if it implements one interface that is a subinterface of
// and MBeanServer will throw NotCompliantMBeanException.
* all the others; otherwise, it is a non-compliant MXBean
// See the Definition of an MXBean section in javax.management.MXBean spec.
* and MBeanServer will throw NotCompliantMBeanException.
//
* See the Definition of an MXBean section in javax.management.MXBean spec.
// To create a compliant logging MXBean, define a LoggingMXBean interface
*
// that extend PlatformLoggingMXBean and j.u.l.LoggingMXBean
* To create a compliant logging MXBean, define a LoggingMXBean interface
interface
LoggingMXBean
* that extend PlatformLoggingMXBean and j.u.l.LoggingMXBean
*/
public
interface
LoggingMXBean
extends
PlatformLoggingMXBean
,
java
.
util
.
logging
.
LoggingMXBean
{
extends
PlatformLoggingMXBean
,
java
.
util
.
logging
.
LoggingMXBean
{
}
}
...
...
test/com/sun/management/HotSpotDiagnosticMXBean/SetVMOption.java
浏览文件 @
4d0e56aa
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
* @summary Basic Test for HotSpotDiagnosticMXBean.setVMOption()
* @summary Basic Test for HotSpotDiagnosticMXBean.setVMOption()
* and getDiagnosticOptions().
* and getDiagnosticOptions().
* @author Mandy Chung
* @author Mandy Chung
* @author Jaroslav Bachorik
*
*
* @run main/othervm -XX:+PrintGCDetails SetVMOption
* @run main/othervm -XX:+PrintGCDetails SetVMOption
*/
*/
...
@@ -36,7 +37,6 @@ import java.util.*;
...
@@ -36,7 +37,6 @@ import java.util.*;
import
com.sun.management.HotSpotDiagnosticMXBean
;
import
com.sun.management.HotSpotDiagnosticMXBean
;
import
com.sun.management.VMOption
;
import
com.sun.management.VMOption
;
import
com.sun.management.VMOption.Origin
;
import
com.sun.management.VMOption.Origin
;
import
sun.misc.Version
;
public
class
SetVMOption
{
public
class
SetVMOption
{
private
static
String
PRINT_GC_DETAILS
=
"PrintGCDetails"
;
private
static
String
PRINT_GC_DETAILS
=
"PrintGCDetails"
;
...
@@ -47,17 +47,8 @@ public class SetVMOption {
...
@@ -47,17 +47,8 @@ public class SetVMOption {
private
static
HotSpotDiagnosticMXBean
mbean
;
private
static
HotSpotDiagnosticMXBean
mbean
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
List
<
HotSpotDiagnosticMXBean
>
list
=
mbean
=
ManagementFactory
.
getPlatformMXBeans
(
HotSpotDiagnosticMXBean
.
class
);
ManagementFactory
.
getPlatformMXBean
(
HotSpotDiagnosticMXBean
.
class
);
// The following test is transitional only and should be removed
// once build 52 is promoted.
int
build
=
Version
.
jvmBuildNumber
();
if
(
build
>
0
&&
build
<
52
)
{
// JVM support is integrated in build 52
// this test is skipped if running with VM earlier than 52
return
;
}
VMOption
option
=
findPrintGCDetailsOption
();
VMOption
option
=
findPrintGCDetailsOption
();
if
(!
option
.
getValue
().
equalsIgnoreCase
(
EXPECTED_VALUE
))
{
if
(!
option
.
getValue
().
equalsIgnoreCase
(
EXPECTED_VALUE
))
{
...
...
test/java/io/File/CheckPermission.java
0 → 100644
浏览文件 @
4d0e56aa
/*
* Copyright (c) 2013, 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.
*/
/* @test
* @bug 8017212
* @summary Examine methods in File.java that access the file system do the
* right permission check when a security manager exists.
* @author Dan Xu
*/
import
java.io.File
;
import
java.io.FilenameFilter
;
import
java.io.FileFilter
;
import
java.io.IOException
;
import
java.security.Permission
;
import
java.util.ArrayList
;
import
java.util.EnumMap
;
import
java.util.EnumSet
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
public
class
CheckPermission
{
private
static
final
String
CHECK_PERMISSION_TEST
=
"CheckPermissionTest"
;
public
enum
FileOperation
{
READ
,
WRITE
,
DELETE
,
EXEC
}
static
class
Checks
{
private
List
<
Permission
>
permissionsChecked
=
new
ArrayList
<>();
private
Set
<
String
>
propertiesChecked
=
new
HashSet
<>();
private
Map
<
FileOperation
,
List
<
String
>>
fileOperationChecked
=
new
EnumMap
<>(
FileOperation
.
class
);
List
<
Permission
>
permissionsChecked
()
{
return
permissionsChecked
;
}
Set
<
String
>
propertiesChecked
()
{
return
propertiesChecked
;
}
List
<
String
>
fileOperationChecked
(
FileOperation
op
)
{
return
fileOperationChecked
.
get
(
op
);
}
void
addFileOperation
(
FileOperation
op
,
String
file
)
{
List
<
String
>
opList
=
fileOperationChecked
.
get
(
op
);
if
(
opList
==
null
)
{
opList
=
new
ArrayList
<>();
fileOperationChecked
.
put
(
op
,
opList
);
}
opList
.
add
(
file
);
}
}
static
ThreadLocal
<
Checks
>
myChecks
=
new
ThreadLocal
<>();
static
void
prepare
()
{
myChecks
.
set
(
new
Checks
());
}
static
class
LoggingSecurityManager
extends
SecurityManager
{
static
void
install
()
{
System
.
setSecurityManager
(
new
LoggingSecurityManager
());
}
private
void
checkFileOperation
(
FileOperation
op
,
String
file
)
{
Checks
checks
=
myChecks
.
get
();
if
(
checks
!=
null
)
checks
.
addFileOperation
(
op
,
file
);
}
@Override
public
void
checkRead
(
String
file
)
{
checkFileOperation
(
FileOperation
.
READ
,
file
);
}
@Override
public
void
checkWrite
(
String
file
)
{
checkFileOperation
(
FileOperation
.
WRITE
,
file
);
}
@Override
public
void
checkDelete
(
String
file
)
{
checkFileOperation
(
FileOperation
.
DELETE
,
file
);
}
@Override
public
void
checkExec
(
String
file
)
{
checkFileOperation
(
FileOperation
.
EXEC
,
file
);
}
@Override
public
void
checkPermission
(
Permission
perm
)
{
Checks
checks
=
myChecks
.
get
();
if
(
checks
!=
null
)
checks
.
permissionsChecked
().
add
(
perm
);
}
@Override
public
void
checkPropertyAccess
(
String
key
)
{
Checks
checks
=
myChecks
.
get
();
if
(
checks
!=
null
)
checks
.
propertiesChecked
().
add
(
key
);
}
}
static
void
assertCheckPermission
(
Class
<?
extends
Permission
>
type
,
String
name
)
{
for
(
Permission
perm
:
myChecks
.
get
().
permissionsChecked
())
{
if
(
type
.
isInstance
(
perm
)
&&
perm
.
getName
().
equals
(
name
))
return
;
}
throw
new
RuntimeException
(
type
.
getName
()
+
"(\""
+
name
+
"\") not checked"
);
}
static
void
assertCheckPropertyAccess
(
String
key
)
{
if
(!
myChecks
.
get
().
propertiesChecked
().
contains
(
key
))
throw
new
RuntimeException
(
"Property "
+
key
+
" not checked"
);
}
static
void
assertChecked
(
File
file
,
List
<
String
>
list
)
{
if
(
list
!=
null
&&
!
list
.
isEmpty
())
{
for
(
String
path
:
list
)
{
if
(
path
.
equals
(
file
.
getPath
()))
return
;
}
}
throw
new
RuntimeException
(
"Access not checked"
);
}
static
void
assertNotChecked
(
File
file
,
List
<
String
>
list
)
{
if
(
list
!=
null
&&
!
list
.
isEmpty
())
{
for
(
String
path
:
list
)
{
if
(
path
.
equals
(
file
.
getPath
()))
throw
new
RuntimeException
(
"Access checked"
);
}
}
}
static
void
assertCheckOperation
(
File
file
,
Set
<
FileOperation
>
ops
)
{
for
(
FileOperation
op
:
ops
)
assertChecked
(
file
,
myChecks
.
get
().
fileOperationChecked
(
op
));
}
static
void
assertNotCheckOperation
(
File
file
,
Set
<
FileOperation
>
ops
)
{
for
(
FileOperation
op
:
ops
)
assertNotChecked
(
file
,
myChecks
.
get
().
fileOperationChecked
(
op
));
}
static
void
assertOnlyCheckOperation
(
File
file
,
EnumSet
<
FileOperation
>
ops
)
{
assertCheckOperation
(
file
,
ops
);
assertNotCheckOperation
(
file
,
EnumSet
.
complementOf
(
ops
));
}
static
File
testFile
,
another
;
static
void
setup
()
{
testFile
=
new
File
(
CHECK_PERMISSION_TEST
+
System
.
currentTimeMillis
());
if
(
testFile
.
exists
())
{
testFile
.
delete
();
}
another
=
new
File
(
CHECK_PERMISSION_TEST
+
"Another"
+
System
.
currentTimeMillis
());
if
(
another
.
exists
())
{
another
.
delete
();
}
LoggingSecurityManager
.
install
();
}
public
static
void
main
(
String
[]
args
)
throws
IOException
{
setup
();
prepare
();
testFile
.
canRead
();
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
READ
));
prepare
();
testFile
.
canWrite
();
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
WRITE
));
prepare
();
testFile
.
exists
();
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
READ
));
prepare
();
testFile
.
isDirectory
();
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
READ
));
prepare
();
testFile
.
isFile
();
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
READ
));
prepare
();
testFile
.
isHidden
();
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
READ
));
prepare
();
testFile
.
lastModified
();
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
READ
));
prepare
();
testFile
.
length
();
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
READ
));
prepare
();
testFile
.
createNewFile
();
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
WRITE
));
prepare
();
testFile
.
list
();
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
READ
));
prepare
();
testFile
.
list
(
new
FilenameFilter
()
{
@Override
public
boolean
accept
(
File
dir
,
String
name
)
{
return
false
;
}
});
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
READ
));
prepare
();
testFile
.
listFiles
();
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
READ
));
prepare
();
testFile
.
listFiles
(
new
FilenameFilter
()
{
@Override
public
boolean
accept
(
File
dir
,
String
name
)
{
return
false
;
}
});
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
READ
));
prepare
();
testFile
.
listFiles
(
new
FileFilter
()
{
@Override
public
boolean
accept
(
File
file
)
{
return
false
;
}
});
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
READ
));
prepare
();
testFile
.
mkdir
();
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
WRITE
));
if
(
testFile
.
exists
())
{
prepare
();
testFile
.
mkdirs
();
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
READ
));
}
if
(!
another
.
exists
())
{
prepare
();
another
.
mkdirs
();
assertOnlyCheckOperation
(
another
,
EnumSet
.
of
(
FileOperation
.
READ
,
FileOperation
.
WRITE
));
}
prepare
();
another
.
delete
();
assertOnlyCheckOperation
(
another
,
EnumSet
.
of
(
FileOperation
.
DELETE
));
prepare
();
boolean
renRst
=
testFile
.
renameTo
(
another
);
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
WRITE
));
assertOnlyCheckOperation
(
another
,
EnumSet
.
of
(
FileOperation
.
WRITE
));
if
(
renRst
)
{
if
(
testFile
.
exists
())
throw
new
RuntimeException
(
testFile
+
" is already renamed to "
+
another
);
testFile
=
another
;
}
prepare
();
testFile
.
setLastModified
(
0
);
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
WRITE
));
prepare
();
testFile
.
setReadOnly
();
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
WRITE
));
prepare
();
testFile
.
setWritable
(
true
,
true
);
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
WRITE
));
prepare
();
testFile
.
setWritable
(
true
);
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
WRITE
));
prepare
();
testFile
.
setReadable
(
true
,
true
);
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
WRITE
));
prepare
();
testFile
.
setReadable
(
true
);
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
WRITE
));
prepare
();
testFile
.
setExecutable
(
true
,
true
);
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
WRITE
));
prepare
();
testFile
.
setExecutable
(
true
);
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
WRITE
));
prepare
();
testFile
.
canExecute
();
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
EXEC
));
prepare
();
testFile
.
getTotalSpace
();
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
READ
));
assertCheckPermission
(
RuntimePermission
.
class
,
"getFileSystemAttributes"
);
prepare
();
testFile
.
getFreeSpace
();
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
READ
));
assertCheckPermission
(
RuntimePermission
.
class
,
"getFileSystemAttributes"
);
prepare
();
testFile
.
getUsableSpace
();
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
READ
));
assertCheckPermission
(
RuntimePermission
.
class
,
"getFileSystemAttributes"
);
prepare
();
File
tmpFile
=
File
.
createTempFile
(
CHECK_PERMISSION_TEST
,
null
);
assertOnlyCheckOperation
(
tmpFile
,
EnumSet
.
of
(
FileOperation
.
WRITE
));
tmpFile
.
delete
();
assertCheckOperation
(
tmpFile
,
EnumSet
.
of
(
FileOperation
.
DELETE
));
prepare
();
tmpFile
=
File
.
createTempFile
(
CHECK_PERMISSION_TEST
,
null
,
null
);
assertOnlyCheckOperation
(
tmpFile
,
EnumSet
.
of
(
FileOperation
.
WRITE
));
tmpFile
.
delete
();
assertCheckOperation
(
tmpFile
,
EnumSet
.
of
(
FileOperation
.
DELETE
));
prepare
();
testFile
.
deleteOnExit
();
assertOnlyCheckOperation
(
testFile
,
EnumSet
.
of
(
FileOperation
.
DELETE
));
}
}
test/java/io/File/NulFile.java
浏览文件 @
4d0e56aa
...
@@ -612,8 +612,13 @@ public class NulFile {
...
@@ -612,8 +612,13 @@ public class NulFile {
try
{
try
{
File
.
createTempFile
(
prefix
,
suffix
,
directory
);
File
.
createTempFile
(
prefix
,
suffix
,
directory
);
}
catch
(
IOException
ex
)
{
}
catch
(
IOException
ex
)
{
if
(
ExceptionMsg
.
equals
(
ex
.
getMessage
()))
String
err
=
"Unable to create temporary file"
;
if
(
err
.
equals
(
ex
.
getMessage
()))
exceptionThrown
=
true
;
exceptionThrown
=
true
;
else
{
throw
new
RuntimeException
(
"Get IOException with message, "
+
ex
.
getMessage
()
+
", expect message, "
+
err
);
}
}
}
}
}
if
(!
exceptionThrown
)
{
if
(!
exceptionThrown
)
{
...
...
test/java/io/File/createTempFile/SpecialTempFile.java
浏览文件 @
4d0e56aa
...
@@ -23,9 +23,8 @@
...
@@ -23,9 +23,8 @@
/*
/*
* @test
* @test
* @bug 8013827 8011950
* @bug 8013827 8011950
8017212
* @summary Check whether File.createTempFile can handle special parameters
* @summary Check whether File.createTempFile can handle special parameters
* on Windows platforms
* @author Dan Xu
* @author Dan Xu
*/
*/
...
@@ -64,6 +63,17 @@ public class SpecialTempFile {
...
@@ -64,6 +63,17 @@ public class SpecialTempFile {
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
// Common test
final
String
name
=
"SpecialTempFile"
;
File
f
=
new
File
(
System
.
getProperty
(
"java.io.tmpdir"
),
name
);
if
(!
f
.
exists
())
{
f
.
createNewFile
();
}
String
[]
nulPre
=
{
name
+
"\u0000"
};
String
[]
nulSuf
=
{
".test"
};
test
(
"NulName"
,
nulPre
,
nulSuf
);
// Windows tests
if
(!
System
.
getProperty
(
"os.name"
).
startsWith
(
"Windows"
))
if
(!
System
.
getProperty
(
"os.name"
).
startsWith
(
"Windows"
))
return
;
return
;
...
...
test/java/lang/ref/OOMEInReferenceHandler.java
浏览文件 @
4d0e56aa
...
@@ -23,9 +23,9 @@
...
@@ -23,9 +23,9 @@
/**
/**
* @test
* @test
* @bug 7038914
* @bug 7038914
8016341
* @summary Verify that the reference handler does not die after an OOME allocating the InterruptedException object
* @summary Verify that the reference handler does not die after an OOME allocating the InterruptedException object
* @run main/othervm -Xmx
16
M -XX:-UseTLAB OOMEInReferenceHandler
* @run main/othervm -Xmx
24
M -XX:-UseTLAB OOMEInReferenceHandler
* @author peter.levart@gmail.com
* @author peter.levart@gmail.com
*/
*/
...
@@ -107,6 +107,6 @@ public class OOMEInReferenceHandler {
...
@@ -107,6 +107,6 @@ public class OOMEInReferenceHandler {
}
}
// no sure answer after 10 seconds
// no sure answer after 10 seconds
throw
new
IllegalStateException
(
"Reference Handler thread stuck.
"
);
throw
new
IllegalStateException
(
"Reference Handler thread stuck.
weakRef.get(): "
+
weakRef
.
get
()
);
}
}
}
}
test/java/math/BigDecimal/StrippingZerosTest.java
浏览文件 @
4d0e56aa
...
@@ -45,8 +45,17 @@ public class StrippingZerosTest {
...
@@ -45,8 +45,17 @@ public class StrippingZerosTest {
{
new
BigDecimal
(
"1234.56780"
),
new
BigDecimal
(
"1234.5678"
)},
{
new
BigDecimal
(
"1234.56780"
),
new
BigDecimal
(
"1234.5678"
)},
{
new
BigDecimal
(
"1234.567800000"
),
new
BigDecimal
(
"1234.5678"
)},
{
new
BigDecimal
(
"1234.567800000"
),
new
BigDecimal
(
"1234.5678"
)},
{
new
BigDecimal
(
"0"
),
new
BigDecimal
(
"0"
)},
{
new
BigDecimal
(
"0"
),
new
BigDecimal
(
"0"
)},
{
new
BigDecimal
(
"0e100"
),
new
BigDecimal
(
"0e100"
)},
{
new
BigDecimal
(
"0e2"
),
BigDecimal
.
ZERO
},
{
new
BigDecimal
(
"0e-100"
),
new
BigDecimal
(
"0e-100"
)},
{
new
BigDecimal
(
"0e-2"
),
BigDecimal
.
ZERO
},
{
new
BigDecimal
(
"0e42"
),
BigDecimal
.
ZERO
},
{
new
BigDecimal
(
"+0e42"
),
BigDecimal
.
ZERO
},
{
new
BigDecimal
(
"-0e42"
),
BigDecimal
.
ZERO
},
{
new
BigDecimal
(
"0e-42"
),
BigDecimal
.
ZERO
},
{
new
BigDecimal
(
"+0e-42"
),
BigDecimal
.
ZERO
},
{
new
BigDecimal
(
"-0e-42"
),
BigDecimal
.
ZERO
},
{
new
BigDecimal
(
"0e-2"
),
BigDecimal
.
ZERO
},
{
new
BigDecimal
(
"0e100"
),
BigDecimal
.
ZERO
},
{
new
BigDecimal
(
"0e-100"
),
BigDecimal
.
ZERO
},
{
new
BigDecimal
(
"10"
),
new
BigDecimal
(
"1e1"
)},
{
new
BigDecimal
(
"10"
),
new
BigDecimal
(
"1e1"
)},
{
new
BigDecimal
(
"20"
),
new
BigDecimal
(
"2e1"
)},
{
new
BigDecimal
(
"20"
),
new
BigDecimal
(
"2e1"
)},
{
new
BigDecimal
(
"100"
),
new
BigDecimal
(
"1e2"
)},
{
new
BigDecimal
(
"100"
),
new
BigDecimal
(
"1e2"
)},
...
...
test/java/util/Collections/UnmodifiableMapEntrySet.java
0 → 100644
浏览文件 @
4d0e56aa
/*
* Copyright (c) 2013, 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.
*/
/**
* @test
* @run testng UnmodifiableMapEntrySet
* @summary Unit tests for wrapping classes should delegate to default methods
*/
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Spliterator
;
import
java.util.TreeMap
;
import
java.util.function.Consumer
;
import
java.util.function.Function
;
import
java.util.function.Supplier
;
import
org.testng.annotations.Test
;
import
org.testng.annotations.DataProvider
;
import
static
org
.
testng
.
Assert
.
assertEquals
;
@Test
(
groups
=
"unit"
)
public
class
UnmodifiableMapEntrySet
{
static
Object
[][]
collections
;
static
<
M
extends
Map
<
Integer
,
Integer
>>
M
fillMap
(
int
size
,
M
m
)
{
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
m
.
put
(
i
,
i
);
}
return
m
;
}
@DataProvider
(
name
=
"maps"
)
static
Object
[][]
mapCases
()
{
if
(
collections
!=
null
)
{
return
collections
;
}
List
<
Object
[]>
cases
=
new
ArrayList
<>();
for
(
int
size
:
new
int
[]
{
1
,
2
,
16
})
{
cases
.
add
(
new
Object
[]
{
String
.
format
(
"new HashMap(%d)"
,
size
),
(
Supplier
<
Map
<
Integer
,
Integer
>>)
()
->
Collections
.
unmodifiableMap
(
fillMap
(
size
,
new
HashMap
<>()))
});
cases
.
add
(
new
Object
[]
{
String
.
format
(
"new TreeMap(%d)"
,
size
),
(
Supplier
<
Map
<
Integer
,
Integer
>>)
()
->
Collections
.
unmodifiableSortedMap
(
fillMap
(
size
,
new
TreeMap
<>()))
});
}
return
cases
.
toArray
(
new
Object
[
0
][]);
}
static
class
EntryConsumer
implements
Consumer
<
Map
.
Entry
<
Integer
,
Integer
>>
{
int
updates
;
@Override
public
void
accept
(
Map
.
Entry
<
Integer
,
Integer
>
me
)
{
try
{
me
.
setValue
(
Integer
.
MAX_VALUE
);
updates
++;
}
catch
(
UnsupportedOperationException
e
)
{
}
}
void
assertNoUpdates
()
{
assertEquals
(
updates
,
0
,
"Updates to entries"
);
}
}
void
testWithEntryConsumer
(
Consumer
<
EntryConsumer
>
c
)
{
EntryConsumer
ec
=
new
EntryConsumer
();
c
.
accept
(
ec
);
ec
.
assertNoUpdates
();
}
@Test
(
dataProvider
=
"maps"
)
public
void
testForEach
(
String
d
,
Supplier
<
Map
<
Integer
,
Integer
>>
ms
)
{
testWithEntryConsumer
(
ec
->
ms
.
get
().
entrySet
().
forEach
(
ec
));
}
@Test
(
dataProvider
=
"maps"
)
public
void
testIteratorForEachRemaining
(
String
d
,
Supplier
<
Map
<
Integer
,
Integer
>>
ms
)
{
testWithEntryConsumer
(
ec
->
ms
.
get
().
entrySet
().
iterator
().
forEachRemaining
(
ec
));
}
@Test
(
dataProvider
=
"maps"
)
public
void
testIteratorNext
(
String
d
,
Supplier
<
Map
<
Integer
,
Integer
>>
ms
)
{
testWithEntryConsumer
(
ec
->
{
for
(
Map
.
Entry
<
Integer
,
Integer
>
me
:
ms
.
get
().
entrySet
())
{
ec
.
accept
(
me
);
}
});
}
@Test
(
dataProvider
=
"maps"
)
public
void
testSpliteratorForEachRemaining
(
String
d
,
Supplier
<
Map
<
Integer
,
Integer
>>
ms
)
{
testSpliterator
(
ms
.
get
().
entrySet
()::
spliterator
,
// Higher order function returning a consumer that
// traverses all spliterator elements using an EntryConsumer
s
->
ec
->
s
.
forEachRemaining
(
ec
));
}
@Test
(
dataProvider
=
"maps"
)
public
void
testSpliteratorTryAdvance
(
String
d
,
Supplier
<
Map
<
Integer
,
Integer
>>
ms
)
{
testSpliterator
(
ms
.
get
().
entrySet
()::
spliterator
,
// Higher order function returning a consumer that
// traverses all spliterator elements using an EntryConsumer
s
->
ec
->
{
while
(
s
.
tryAdvance
(
ec
));
});
}
void
testSpliterator
(
Supplier
<
Spliterator
<
Map
.
Entry
<
Integer
,
Integer
>>>
ss
,
// Higher order function that given a spliterator returns a
// consumer for that spliterator which traverses elements
// using an EntryConsumer
Function
<
Spliterator
<
Map
.
Entry
<
Integer
,
Integer
>>,
Consumer
<
EntryConsumer
>>
sc
)
{
testWithEntryConsumer
(
sc
.
apply
(
ss
.
get
()));
Spliterator
<
Map
.
Entry
<
Integer
,
Integer
>>
s
=
ss
.
get
();
Spliterator
<
Map
.
Entry
<
Integer
,
Integer
>>
split
=
s
.
trySplit
();
if
(
split
!=
null
)
{
testWithEntryConsumer
(
sc
.
apply
(
split
));
testWithEntryConsumer
(
sc
.
apply
(
s
));
}
}
@Test
(
dataProvider
=
"maps"
)
public
void
testStreamForEach
(
String
d
,
Supplier
<
Map
<
Integer
,
Integer
>>
ms
)
{
testWithEntryConsumer
(
ec
->
ms
.
get
().
entrySet
().
stream
().
forEach
(
ec
));
}
@Test
(
dataProvider
=
"maps"
)
public
void
testParallelStreamForEach
(
String
d
,
Supplier
<
Map
<
Integer
,
Integer
>>
ms
)
{
testWithEntryConsumer
(
ec
->
ms
.
get
().
entrySet
().
parallelStream
().
forEach
(
ec
));
}
}
test/javax/management/MBeanServer/MBeanFallbackTest.java
0 → 100644
浏览文件 @
4d0e56aa
/*
* Copyright (c) 2013, 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
javax.management.MBeanServer
;
import
javax.management.MBeanServerFactory
;
import
javax.management.NotCompliantMBeanException
;
import
javax.management.ObjectName
;
/*
* @test
* @bug 8010285
* @summary Test fallback for private MBean interfaces.
* It needs to be a separate class because the "jdk.jmx.mbeans.allowNonPublic"
* system property must be set before c.s.j.m.MBeanAnalyzer has been loaded.
* @author Jaroslav Bachorik
* @run clean MBeanFallbackTest
* @run build MBeanFallbackTest
* @run main MBeanFallbackTest
*/
public
class
MBeanFallbackTest
{
private
static
interface
PrivateMBean
{
public
int
[]
getInts
();
}
public
static
class
Private
implements
PrivateMBean
{
public
int
[]
getInts
()
{
return
new
int
[]{
1
,
2
,
3
};
}
}
private
static
int
failures
=
0
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
System
.
setProperty
(
"jdk.jmx.mbeans.allowNonPublic"
,
"true"
);
testPrivate
(
PrivateMBean
.
class
,
new
Private
());
if
(
failures
==
0
)
System
.
out
.
println
(
"Test passed"
);
else
throw
new
Exception
(
"TEST FAILURES: "
+
failures
);
}
private
static
void
fail
(
String
msg
)
{
failures
++;
System
.
out
.
println
(
"FAIL: "
+
msg
);
}
private
static
void
success
(
String
msg
)
{
System
.
out
.
println
(
"OK: "
+
msg
);
}
private
static
void
testPrivate
(
Class
<?>
iface
,
Object
bean
)
throws
Exception
{
try
{
System
.
out
.
println
(
"Registering a private MBean "
+
iface
.
getName
()
+
" ..."
);
MBeanServer
mbs
=
MBeanServerFactory
.
newMBeanServer
();
ObjectName
on
=
new
ObjectName
(
"test:type=Compliant"
);
mbs
.
registerMBean
(
bean
,
on
);
success
(
"Registered a private MBean - "
+
iface
.
getName
());
}
catch
(
Exception
e
)
{
Throwable
t
=
e
;
while
(
t
!=
null
&&
!(
t
instanceof
NotCompliantMBeanException
))
{
t
=
t
.
getCause
();
}
if
(
t
!=
null
)
{
fail
(
"MBean not registered"
);
}
else
{
throw
e
;
}
}
}
}
test/javax/management/MBeanServer/MBeanTest.java
0 → 100644
浏览文件 @
4d0e56aa
/*
* Copyright (c) 2013, 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
javax.management.MBeanServer
;
import
javax.management.MBeanServerFactory
;
import
javax.management.NotCompliantMBeanException
;
import
javax.management.ObjectName
;
/*
* @test
* @bug 8010285
* @summary General MBean test.
* @author Jaroslav Bachorik
* @run clean MBeanTest
* @run build MBeanTest
* @run main MBeanTest
*/
public
class
MBeanTest
{
private
static
interface
PrivateMBean
{
public
int
[]
getInts
();
}
public
static
class
Private
implements
PrivateMBean
{
public
int
[]
getInts
()
{
return
new
int
[]{
1
,
2
,
3
};
}
}
public
static
interface
NonCompliantMBean
{
public
boolean
getInt
();
public
boolean
isInt
();
public
void
setInt
(
int
a
);
public
void
setInt
(
long
b
);
}
public
static
class
NonCompliant
implements
NonCompliantMBean
{
public
boolean
getInt
()
{
return
false
;
}
public
boolean
isInt
()
{
return
true
;
}
public
void
setInt
(
int
a
)
{
}
public
void
setInt
(
long
b
)
{
}
}
public
static
interface
CompliantMBean
{
public
boolean
isFlag
();
public
int
getInt
();
public
void
setInt
(
int
value
);
}
public
static
class
Compliant
implements
CompliantMBean
{
public
boolean
isFlag
()
{
return
false
;
}
public
int
getInt
()
{
return
1
;
}
public
void
setInt
(
int
value
)
{
}
}
private
static
int
failures
=
0
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
testCompliant
(
CompliantMBean
.
class
,
new
Compliant
());
testNonCompliant
(
PrivateMBean
.
class
,
new
Private
());
testNonCompliant
(
NonCompliantMBean
.
class
,
new
NonCompliant
());
if
(
failures
==
0
)
System
.
out
.
println
(
"Test passed"
);
else
throw
new
Exception
(
"TEST FAILURES: "
+
failures
);
}
private
static
void
fail
(
String
msg
)
{
failures
++;
System
.
out
.
println
(
"FAIL: "
+
msg
);
}
private
static
void
success
(
String
msg
)
{
System
.
out
.
println
(
"OK: "
+
msg
);
}
private
static
void
testNonCompliant
(
Class
<?>
iface
,
Object
bean
)
throws
Exception
{
try
{
System
.
out
.
println
(
"Registering a non-compliant MBean "
+
iface
.
getName
()
+
" ..."
);
MBeanServer
mbs
=
MBeanServerFactory
.
newMBeanServer
();
ObjectName
on
=
new
ObjectName
(
"test:type=NonCompliant"
);
mbs
.
registerMBean
(
bean
,
on
);
fail
(
"Registered a non-compliant MBean - "
+
iface
.
getName
());
}
catch
(
Exception
e
)
{
Throwable
t
=
e
;
while
(
t
!=
null
&&
!(
t
instanceof
NotCompliantMBeanException
))
{
t
=
t
.
getCause
();
}
if
(
t
!=
null
)
{
success
(
"MBean not registered"
);
}
else
{
throw
e
;
}
}
}
private
static
void
testCompliant
(
Class
<?>
iface
,
Object
bean
)
throws
Exception
{
try
{
System
.
out
.
println
(
"Registering a compliant MBean "
+
iface
.
getName
()
+
" ..."
);
MBeanServer
mbs
=
MBeanServerFactory
.
newMBeanServer
();
ObjectName
on
=
new
ObjectName
(
"test:type=Compliant"
);
mbs
.
registerMBean
(
bean
,
on
);
success
(
"Registered a compliant MBean - "
+
iface
.
getName
());
}
catch
(
Exception
e
)
{
Throwable
t
=
e
;
while
(
t
!=
null
&&
!(
t
instanceof
NotCompliantMBeanException
))
{
t
=
t
.
getCause
();
}
if
(
t
!=
null
)
{
fail
(
"MBean not registered"
);
}
else
{
throw
e
;
}
}
}
}
test/javax/management/mxbean/MXBeanFallbackTest.java
0 → 100644
浏览文件 @
4d0e56aa
/*
* Copyright (c) 2005, 2013, 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.
*/
/*
* @test
* @bug 8010285
* @summary Test for the private MXBean interface fallback.
* It needs to be a separate class because the "jdk.jmx.mbeans.allowNonPublic"
* system property must be set before c.s.j.m.MBeanAnalyzer has been loaded.
* @author Jaroslav Bachorik
* @run clean MXBeanFallbackTest
* @run build MXBeanFallbackTest
* @run main MXBeanFallbackTest
*/
import
javax.management.MBeanServer
;
import
javax.management.MBeanServerFactory
;
import
javax.management.NotCompliantMBeanException
;
import
javax.management.ObjectName
;
public
class
MXBeanFallbackTest
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
System
.
setProperty
(
"jdk.jmx.mbeans.allowNonPublic"
,
"true"
);
testPrivateMXBean
(
"Private"
,
new
Private
());
if
(
failures
==
0
)
System
.
out
.
println
(
"Test passed"
);
else
throw
new
Exception
(
"TEST FAILURES: "
+
failures
);
}
private
static
int
failures
=
0
;
private
static
interface
PrivateMXBean
{
public
int
[]
getInts
();
}
public
static
class
Private
implements
PrivateMXBean
{
public
int
[]
getInts
()
{
return
new
int
[]{
1
,
2
,
3
};
}
}
private
static
void
testPrivateMXBean
(
String
type
,
Object
bean
)
throws
Exception
{
System
.
out
.
println
(
type
+
" MXBean test..."
);
MBeanServer
mbs
=
MBeanServerFactory
.
newMBeanServer
();
ObjectName
on
=
new
ObjectName
(
"test:type="
+
type
);
try
{
mbs
.
registerMBean
(
bean
,
on
);
success
(
"Private MXBean registered"
);
}
catch
(
NotCompliantMBeanException
e
)
{
failure
(
"Failed to register the private MXBean - "
+
bean
.
getClass
().
getInterfaces
()[
0
].
getName
());
}
}
private
static
void
success
(
String
what
)
{
System
.
out
.
println
(
"OK: "
+
what
);
}
private
static
void
failure
(
String
what
)
{
System
.
out
.
println
(
"FAILED: "
+
what
);
failures
++;
}
}
test/javax/management/mxbean/MXBeanTest.java
浏览文件 @
4d0e56aa
/*
/*
* Copyright (c) 2005, 20
08
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 20
13
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -23,9 +23,10 @@
...
@@ -23,9 +23,10 @@
/*
/*
* @test
* @test
* @bug 6175517 6278707 6318827 6305746 6392303 6600709
* @bug 6175517 6278707 6318827 6305746 6392303 6600709
8010285
* @summary General MXBean test.
* @summary General MXBean test.
* @author Eamonn McManus
* @author Eamonn McManus
* @author Jaroslav Bachorik
* @run clean MXBeanTest MerlinMXBean TigerMXBean
* @run clean MXBeanTest MerlinMXBean TigerMXBean
* @run build MXBeanTest MerlinMXBean TigerMXBean
* @run build MXBeanTest MerlinMXBean TigerMXBean
* @run main MXBeanTest
* @run main MXBeanTest
...
@@ -51,6 +52,7 @@ import javax.management.MBeanServer;
...
@@ -51,6 +52,7 @@ import javax.management.MBeanServer;
import
javax.management.MBeanServerConnection
;
import
javax.management.MBeanServerConnection
;
import
javax.management.MBeanServerFactory
;
import
javax.management.MBeanServerFactory
;
import
javax.management.MBeanServerInvocationHandler
;
import
javax.management.MBeanServerInvocationHandler
;
import
javax.management.NotCompliantMBeanException
;
import
javax.management.ObjectName
;
import
javax.management.ObjectName
;
import
javax.management.StandardMBean
;
import
javax.management.StandardMBean
;
import
javax.management.openmbean.ArrayType
;
import
javax.management.openmbean.ArrayType
;
...
@@ -75,6 +77,8 @@ public class MXBeanTest {
...
@@ -75,6 +77,8 @@ public class MXBeanTest {
testExplicitMXBean
();
testExplicitMXBean
();
testSubclassMXBean
();
testSubclassMXBean
();
testIndirectMXBean
();
testIndirectMXBean
();
testNonCompliantMXBean
(
"Private"
,
new
Private
());
testNonCompliantMXBean
(
"NonCompliant"
,
new
NonCompliant
());
if
(
failures
==
0
)
if
(
failures
==
0
)
System
.
out
.
println
(
"Test passed"
);
System
.
out
.
println
(
"Test passed"
);
...
@@ -84,6 +88,39 @@ public class MXBeanTest {
...
@@ -84,6 +88,39 @@ public class MXBeanTest {
private
static
int
failures
=
0
;
private
static
int
failures
=
0
;
private
static
interface
PrivateMXBean
{
public
int
[]
getInts
();
}
public
static
class
Private
implements
PrivateMXBean
{
public
int
[]
getInts
()
{
return
new
int
[]{
1
,
2
,
3
};
}
}
public
static
interface
NonCompliantMXBean
{
public
boolean
getInt
();
public
boolean
isInt
();
public
void
setInt
(
int
a
);
public
void
setInt
(
long
b
);
}
public
static
class
NonCompliant
implements
NonCompliantMXBean
{
public
boolean
getInt
()
{
return
false
;
}
public
boolean
isInt
()
{
return
true
;
}
public
void
setInt
(
int
a
)
{
}
public
void
setInt
(
long
b
)
{
}
}
public
static
interface
ExplicitMXBean
{
public
static
interface
ExplicitMXBean
{
public
int
[]
getInts
();
public
int
[]
getInts
();
}
}
...
@@ -110,6 +147,19 @@ public class MXBeanTest {
...
@@ -110,6 +147,19 @@ public class MXBeanTest {
}
}
}
}
private
static
void
testNonCompliantMXBean
(
String
type
,
Object
bean
)
throws
Exception
{
System
.
out
.
println
(
type
+
" MXBean test..."
);
MBeanServer
mbs
=
MBeanServerFactory
.
newMBeanServer
();
ObjectName
on
=
new
ObjectName
(
"test:type="
+
type
);
try
{
mbs
.
registerMBean
(
bean
,
on
);
failure
(
bean
.
getClass
().
getInterfaces
()[
0
].
getName
()
+
" is not a compliant "
+
"MXBean interface"
);
}
catch
(
NotCompliantMBeanException
e
)
{
success
(
"Non-compliant MXBean not registered"
);
}
}
private
static
void
testExplicitMXBean
()
throws
Exception
{
private
static
void
testExplicitMXBean
()
throws
Exception
{
System
.
out
.
println
(
"Explicit MXBean test..."
);
System
.
out
.
println
(
"Explicit MXBean test..."
);
MBeanServer
mbs
=
MBeanServerFactory
.
newMBeanServer
();
MBeanServer
mbs
=
MBeanServerFactory
.
newMBeanServer
();
...
...
test/javax/management/proxy/JMXProxyFallbackTest.java
0 → 100644
浏览文件 @
4d0e56aa
/*
* Copyright (c) 2013, 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
javax.management.JMX
;
import
javax.management.MBeanServer
;
import
javax.management.MBeanServerFactory
;
import
javax.management.NotCompliantMBeanException
;
import
javax.management.ObjectName
;
/*
* @test
* @bug 8010285
* @summary Tests the fallback for creating JMX proxies for private interfaces
* It needs to be a separate class because the "jdk.jmx.mbeans.allowNonPublic"
* system property must be set before c.s.j.m.MBeanAnalyzer has been loaded.
* @author Jaroslav Bachorik
* @run clean JMXProxyFallbackTest
* @run build JMXProxyFallbackTest
* @run main JMXProxyFallbackTest
*/
public
class
JMXProxyFallbackTest
{
private
static
interface
PrivateMBean
{
public
int
[]
getInts
();
}
private
static
interface
PrivateMXBean
{
public
int
[]
getInts
();
}
public
static
class
Private
implements
PrivateMXBean
,
PrivateMBean
{
public
int
[]
getInts
()
{
return
new
int
[]{
1
,
2
,
3
};
}
}
private
static
int
failures
=
0
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
System
.
setProperty
(
"jdk.jmx.mbeans.allowNonPublic"
,
"true"
);
testPrivate
(
PrivateMBean
.
class
);
testPrivate
(
PrivateMXBean
.
class
);
if
(
failures
==
0
)
System
.
out
.
println
(
"Test passed"
);
else
throw
new
Exception
(
"TEST FAILURES: "
+
failures
);
}
private
static
void
fail
(
String
msg
)
{
failures
++;
System
.
out
.
println
(
"FAIL: "
+
msg
);
}
private
static
void
success
(
String
msg
)
{
System
.
out
.
println
(
"OK: "
+
msg
);
}
private
static
void
testPrivate
(
Class
<?>
iface
)
throws
Exception
{
try
{
System
.
out
.
println
(
"Creating a proxy for private M(X)Bean "
+
iface
.
getName
()
+
" ..."
);
MBeanServer
mbs
=
MBeanServerFactory
.
newMBeanServer
();
ObjectName
on
=
new
ObjectName
(
"test:type=Proxy"
);
JMX
.
newMBeanProxy
(
mbs
,
on
,
iface
);
success
(
"Created a proxy for private M(X)Bean - "
+
iface
.
getName
());
}
catch
(
Exception
e
)
{
Throwable
t
=
e
;
while
(
t
!=
null
&&
!(
t
instanceof
NotCompliantMBeanException
))
{
t
=
t
.
getCause
();
}
if
(
t
!=
null
)
{
fail
(
"Proxy not created"
);
}
else
{
throw
e
;
}
}
}
}
test/javax/management/proxy/JMXProxyTest.java
0 → 100644
浏览文件 @
4d0e56aa
/*
* Copyright (c) 2013, 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
javax.management.JMX
;
import
javax.management.MBeanServer
;
import
javax.management.MBeanServerFactory
;
import
javax.management.NotCompliantMBeanException
;
import
javax.management.ObjectName
;
/*
* @test
* @bug 8010285
* @summary Tests that javax.management.JMX creates proxies only for the
* compliant MBeans/MXBeans
* @author Jaroslav Bachorik
* @run clean JMXProxyTest
* @run build JMXProxyTest
* @run main JMXProxyTest
*/
public
class
JMXProxyTest
{
private
static
interface
PrivateMBean
{
public
int
[]
getInts
();
}
private
static
interface
PrivateMXBean
{
public
int
[]
getInts
();
}
public
static
class
Private
implements
PrivateMXBean
,
PrivateMBean
{
public
int
[]
getInts
()
{
return
new
int
[]{
1
,
2
,
3
};
}
}
public
static
interface
NonCompliantMBean
{
public
boolean
getInt
();
public
boolean
isInt
();
public
void
setInt
(
int
a
);
public
void
setInt
(
long
b
);
}
public
static
interface
NonCompliantMXBean
{
public
boolean
getInt
();
public
boolean
isInt
();
public
void
setInt
(
int
a
);
public
void
setInt
(
long
b
);
}
public
static
class
NonCompliant
implements
NonCompliantMXBean
,
NonCompliantMBean
{
public
boolean
getInt
()
{
return
false
;
}
public
boolean
isInt
()
{
return
true
;
}
public
void
setInt
(
int
a
)
{
}
public
void
setInt
(
long
b
)
{
}
}
public
static
interface
CompliantMBean
{
public
boolean
isFlag
();
public
int
getInt
();
public
void
setInt
(
int
value
);
}
public
static
interface
CompliantMXBean
{
public
boolean
isFlag
();
public
int
getInt
();
public
void
setInt
(
int
value
);
}
public
static
class
Compliant
implements
CompliantMXBean
,
CompliantMBean
{
public
boolean
isFlag
()
{
return
false
;
}
public
int
getInt
()
{
return
1
;
}
public
void
setInt
(
int
value
)
{
}
}
private
static
int
failures
=
0
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
testCompliant
(
CompliantMBean
.
class
,
false
);
testCompliant
(
CompliantMXBean
.
class
,
true
);
testNonCompliant
(
PrivateMBean
.
class
,
false
);
testNonCompliant
(
PrivateMXBean
.
class
,
true
);
testNonCompliant
(
NonCompliantMBean
.
class
,
false
);
testNonCompliant
(
NonCompliantMXBean
.
class
,
true
);
if
(
failures
==
0
)
System
.
out
.
println
(
"Test passed"
);
else
throw
new
Exception
(
"TEST FAILURES: "
+
failures
);
}
private
static
void
fail
(
String
msg
)
{
failures
++;
System
.
out
.
println
(
"FAIL: "
+
msg
);
}
private
static
void
success
(
String
msg
)
{
System
.
out
.
println
(
"OK: "
+
msg
);
}
private
static
void
testNonCompliant
(
Class
<?>
iface
,
boolean
isMx
)
throws
Exception
{
try
{
System
.
out
.
println
(
"Creating a proxy for non-compliant "
+
(
isMx
?
"MXBean"
:
"MBean"
)
+
" "
+
iface
.
getName
()
+
" ..."
);
MBeanServer
mbs
=
MBeanServerFactory
.
newMBeanServer
();
ObjectName
on
=
new
ObjectName
(
"test:type=Proxy"
);
if
(
isMx
)
{
JMX
.
newMXBeanProxy
(
mbs
,
on
,
iface
);
}
else
{
JMX
.
newMBeanProxy
(
mbs
,
on
,
iface
);
}
fail
(
"Created a proxy for non-compliant "
+
(
isMx
?
"MXBean"
:
"MBean"
)
+
" - "
+
iface
.
getName
());
}
catch
(
Exception
e
)
{
Throwable
t
=
e
;
while
(
t
!=
null
&&
!(
t
instanceof
NotCompliantMBeanException
))
{
t
=
t
.
getCause
();
}
if
(
t
!=
null
)
{
success
(
"Proxy not created"
);
}
else
{
throw
e
;
}
}
}
private
static
void
testCompliant
(
Class
<?>
iface
,
boolean
isMx
)
throws
Exception
{
try
{
System
.
out
.
println
(
"Creating a proxy for compliant "
+
(
isMx
?
"MXBean"
:
"MBean"
)
+
" "
+
iface
.
getName
()
+
" ..."
);
MBeanServer
mbs
=
MBeanServerFactory
.
newMBeanServer
();
ObjectName
on
=
new
ObjectName
(
"test:type=Proxy"
);
if
(
isMx
)
{
JMX
.
newMXBeanProxy
(
mbs
,
on
,
iface
);
}
else
{
JMX
.
newMBeanProxy
(
mbs
,
on
,
iface
);
}
success
(
"Created a proxy for compliant "
+
(
isMx
?
"MXBean"
:
"MBean"
)
+
" - "
+
iface
.
getName
());
}
catch
(
Exception
e
)
{
Throwable
t
=
e
;
while
(
t
!=
null
&&
!(
t
instanceof
NotCompliantMBeanException
))
{
t
=
t
.
getCause
();
}
if
(
t
!=
null
)
{
fail
(
"Proxy not created"
);
}
else
{
throw
e
;
}
}
}
}
test/sun/security/krb5/auto/SaslGSS.java
浏览文件 @
4d0e56aa
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
/*
/*
* @test
* @test
* @bug 8012082
* @bug 8012082
8019267
* @summary SASL: auth-conf negotiated, but unencrypted data is accepted,
* @summary SASL: auth-conf negotiated, but unencrypted data is accepted,
* reset to unencrypt
* reset to unencrypt
* @compile -XDignore.symbol.file SaslGSS.java
* @compile -XDignore.symbol.file SaslGSS.java
...
@@ -37,9 +37,16 @@ import javax.security.sasl.AuthorizeCallback;
...
@@ -37,9 +37,16 @@ import javax.security.sasl.AuthorizeCallback;
import
javax.security.sasl.RealmCallback
;
import
javax.security.sasl.RealmCallback
;
import
javax.security.sasl.Sasl
;
import
javax.security.sasl.Sasl
;
import
javax.security.sasl.SaslServer
;
import
javax.security.sasl.SaslServer
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.PrintStream
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Locale
;
import
java.util.Locale
;
import
java.util.logging.ConsoleHandler
;
import
java.util.logging.Handler
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
org.ietf.jgss.*
;
import
org.ietf.jgss.*
;
import
sun.security.jgss.GSSUtil
;
import
sun.security.jgss.GSSUtil
;
...
@@ -79,14 +86,28 @@ public class SaslGSS {
...
@@ -79,14 +86,28 @@ public class SaslGSS {
}
}
});
});
// Handshake
ByteArrayOutputStream
bout
=
new
ByteArrayOutputStream
();
PrintStream
oldErr
=
System
.
err
;
System
.
setErr
(
new
PrintStream
(
bout
));
Logger
.
getLogger
(
"javax.security.sasl"
).
setLevel
(
Level
.
ALL
);
Handler
h
=
new
ConsoleHandler
();
h
.
setLevel
(
Level
.
ALL
);
Logger
.
getLogger
(
"javax.security.sasl"
).
addHandler
(
h
);
byte
[]
token
=
new
byte
[
0
];
byte
[]
token
=
new
byte
[
0
];
token
=
sc
.
initSecContext
(
token
,
0
,
token
.
length
);
token
=
ss
.
evaluateResponse
(
token
);
try
{
token
=
sc
.
unwrap
(
token
,
0
,
token
.
length
,
new
MessageProp
(
0
,
false
));
// Handshake
token
[
0
]
=
(
byte
)(((
token
[
0
]
&
4
)
!=
0
)
?
4
:
2
);
token
=
sc
.
initSecContext
(
token
,
0
,
token
.
length
);
token
=
sc
.
wrap
(
token
,
0
,
token
.
length
,
new
MessageProp
(
0
,
false
));
token
=
ss
.
evaluateResponse
(
token
);
ss
.
evaluateResponse
(
token
);
token
=
sc
.
unwrap
(
token
,
0
,
token
.
length
,
new
MessageProp
(
0
,
false
));
token
[
0
]
=
(
byte
)(((
token
[
0
]
&
4
)
!=
0
)
?
4
:
2
);
token
=
sc
.
wrap
(
token
,
0
,
token
.
length
,
new
MessageProp
(
0
,
false
));
ss
.
evaluateResponse
(
token
);
}
finally
{
System
.
setErr
(
oldErr
);
}
// Talk
// Talk
// 1. Client sends a auth-int message
// 1. Client sends a auth-int message
...
@@ -102,5 +123,15 @@ public class SaslGSS {
...
@@ -102,5 +123,15 @@ public class SaslGSS {
if
(!
qop
.
getPrivacy
())
{
if
(!
qop
.
getPrivacy
())
{
throw
new
Exception
();
throw
new
Exception
();
}
}
for
(
String
s:
bout
.
toString
().
split
(
"\\n"
))
{
if
(
s
.
contains
(
"KRB5SRV04"
)
&&
s
.
contains
(
"NULL"
))
{
return
;
}
}
System
.
out
.
println
(
"======================="
);
System
.
out
.
println
(
bout
.
toString
());
System
.
out
.
println
(
"======================="
);
throw
new
Exception
(
"Haven't seen KRB5SRV04 with NULL"
);
}
}
}
}
test/sun/security/pkcs11/Signature/TestRSAKeyLength.java
浏览文件 @
4d0e56aa
/*
/*
* Copyright (c) 2010, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -36,7 +36,7 @@ public class TestRSAKeyLength extends PKCS11Test {
...
@@ -36,7 +36,7 @@ public class TestRSAKeyLength extends PKCS11Test {
main
(
new
TestRSAKeyLength
());
main
(
new
TestRSAKeyLength
());
}
}
public
void
main
(
Provider
p
)
throws
Exception
{
public
void
main
(
Provider
p
)
throws
Exception
{
boolean
isValidKeyLength
[]
=
{
true
,
true
,
false
,
false
};
boolean
isValidKeyLength
[]
=
{
true
,
true
,
true
,
false
,
false
};
String
algos
[]
=
{
"SHA1withRSA"
,
"SHA224withRSA"
,
"SHA256withRSA"
,
String
algos
[]
=
{
"SHA1withRSA"
,
"SHA224withRSA"
,
"SHA256withRSA"
,
"SHA384withRSA"
,
"SHA512withRSA"
};
"SHA384withRSA"
,
"SHA512withRSA"
};
KeyPairGenerator
kpg
=
KeyPairGenerator
.
getInstance
(
"RSA"
,
p
);
KeyPairGenerator
kpg
=
KeyPairGenerator
.
getInstance
(
"RSA"
,
p
);
...
@@ -45,6 +45,10 @@ public class TestRSAKeyLength extends PKCS11Test {
...
@@ -45,6 +45,10 @@ public class TestRSAKeyLength extends PKCS11Test {
PrivateKey
privKey
=
kp
.
getPrivate
();
PrivateKey
privKey
=
kp
.
getPrivate
();
PublicKey
pubKey
=
kp
.
getPublic
();
PublicKey
pubKey
=
kp
.
getPublic
();
if
(
algos
.
length
!=
isValidKeyLength
.
length
)
{
throw
new
Exception
(
"Internal Error: number of test algos"
+
" and results length mismatch!"
);
}
for
(
int
i
=
0
;
i
<
algos
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
algos
.
length
;
i
++)
{
Signature
sig
=
Signature
.
getInstance
(
algos
[
i
],
p
);
Signature
sig
=
Signature
.
getInstance
(
algos
[
i
],
p
);
System
.
out
.
println
(
"Testing RSA signature "
+
algos
[
i
]);
System
.
out
.
println
(
"Testing RSA signature "
+
algos
[
i
]);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录