Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
2629adac
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
5
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看板
提交
2629adac
编写于
8月 29, 2011
作者:
M
mullan
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
4dcf283e
68301733
变更
77
隐藏空白更改
内联
并排
Showing
77 changed file
with
1532 addition
and
596 deletion
+1532
-596
src/share/classes/com/sun/jndi/ldap/ClientId.java
src/share/classes/com/sun/jndi/ldap/ClientId.java
+8
-5
src/share/classes/com/sun/jndi/ldap/LdapClient.java
src/share/classes/com/sun/jndi/ldap/LdapClient.java
+6
-4
src/share/classes/com/sun/jndi/ldap/LdapCtx.java
src/share/classes/com/sun/jndi/ldap/LdapCtx.java
+2
-1
src/share/classes/com/sun/jndi/ldap/LdapName.java
src/share/classes/com/sun/jndi/ldap/LdapName.java
+7
-5
src/share/classes/com/sun/jndi/ldap/LdapPoolManager.java
src/share/classes/com/sun/jndi/ldap/LdapPoolManager.java
+2
-1
src/share/classes/com/sun/jndi/toolkit/dir/HierMemDirCtx.java
...share/classes/com/sun/jndi/toolkit/dir/HierMemDirCtx.java
+1
-1
src/share/classes/com/sun/jndi/toolkit/dir/SearchFilter.java
src/share/classes/com/sun/jndi/toolkit/dir/SearchFilter.java
+9
-6
src/share/classes/com/sun/security/ntlm/Client.java
src/share/classes/com/sun/security/ntlm/Client.java
+9
-7
src/share/classes/com/sun/security/ntlm/NTLM.java
src/share/classes/com/sun/security/ntlm/NTLM.java
+3
-1
src/share/classes/com/sun/security/ntlm/NTLMException.java
src/share/classes/com/sun/security/ntlm/NTLMException.java
+5
-0
src/share/classes/com/sun/security/ntlm/Server.java
src/share/classes/com/sun/security/ntlm/Server.java
+12
-9
src/share/classes/com/sun/security/sasl/ntlm/FactoryImpl.java
...share/classes/com/sun/security/sasl/ntlm/FactoryImpl.java
+9
-3
src/share/classes/com/sun/security/sasl/ntlm/NTLMClient.java
src/share/classes/com/sun/security/sasl/ntlm/NTLMClient.java
+7
-4
src/share/classes/com/sun/security/sasl/ntlm/NTLMServer.java
src/share/classes/com/sun/security/sasl/ntlm/NTLMServer.java
+13
-7
src/share/classes/com/sun/servicetag/SunConnection.java
src/share/classes/com/sun/servicetag/SunConnection.java
+6
-14
src/share/classes/java/io/BufferedReader.java
src/share/classes/java/io/BufferedReader.java
+6
-3
src/share/classes/java/io/BufferedWriter.java
src/share/classes/java/io/BufferedWriter.java
+2
-2
src/share/classes/java/io/Closeable.java
src/share/classes/java/io/Closeable.java
+6
-0
src/share/classes/java/io/FilterOutputStream.java
src/share/classes/java/io/FilterOutputStream.java
+3
-4
src/share/classes/java/lang/AutoCloseable.java
src/share/classes/java/lang/AutoCloseable.java
+9
-0
src/share/classes/java/lang/InternalError.java
src/share/classes/java/lang/InternalError.java
+41
-6
src/share/classes/java/lang/System.java
src/share/classes/java/lang/System.java
+1
-0
src/share/classes/java/lang/VirtualMachineError.java
src/share/classes/java/lang/VirtualMachineError.java
+42
-7
src/share/classes/java/net/HttpCookie.java
src/share/classes/java/net/HttpCookie.java
+6
-2
src/share/classes/java/security/KeyRep.java
src/share/classes/java/security/KeyRep.java
+2
-1
src/share/classes/java/security/Security.java
src/share/classes/java/security/Security.java
+6
-3
src/share/classes/java/util/Observable.java
src/share/classes/java/util/Observable.java
+2
-2
src/share/classes/java/util/prefs/Preferences.java
src/share/classes/java/util/prefs/Preferences.java
+4
-8
src/share/classes/javax/naming/NameImpl.java
src/share/classes/javax/naming/NameImpl.java
+10
-5
src/share/classes/javax/naming/directory/BasicAttributes.java
...share/classes/javax/naming/directory/BasicAttributes.java
+4
-3
src/share/classes/javax/naming/ldap/Rdn.java
src/share/classes/javax/naming/ldap/Rdn.java
+4
-5
src/share/classes/javax/net/ssl/HttpsURLConnection.java
src/share/classes/javax/net/ssl/HttpsURLConnection.java
+2
-4
src/share/classes/sun/font/FontManagerFactory.java
src/share/classes/sun/font/FontManagerFactory.java
+4
-13
src/share/classes/sun/management/ManagementFactoryHelper.java
...share/classes/sun/management/ManagementFactoryHelper.java
+4
-2
src/share/classes/sun/misc/URLClassPath.java
src/share/classes/sun/misc/URLClassPath.java
+3
-3
src/share/classes/sun/reflect/MethodAccessorGenerator.java
src/share/classes/sun/reflect/MethodAccessorGenerator.java
+2
-4
src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java
...s/sun/reflect/annotation/AnnotationInvocationHandler.java
+2
-1
src/share/classes/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java
...lect/annotation/AnnotationTypeMismatchExceptionProxy.java
+2
-1
src/share/classes/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java
...lect/annotation/EnumConstantNotPresentExceptionProxy.java
+2
-1
src/share/classes/sun/reflect/annotation/TypeNotPresentExceptionProxy.java
.../sun/reflect/annotation/TypeNotPresentExceptionProxy.java
+2
-1
src/share/classes/sun/reflect/generics/parser/SignatureParser.java
.../classes/sun/reflect/generics/parser/SignatureParser.java
+215
-95
src/share/classes/sun/security/jgss/krb5/Krb5NameElement.java
...share/classes/sun/security/jgss/krb5/Krb5NameElement.java
+2
-1
src/share/classes/sun/security/krb5/PrincipalName.java
src/share/classes/sun/security/krb5/PrincipalName.java
+4
-3
src/share/classes/sun/security/pkcs11/Session.java
src/share/classes/sun/security/pkcs11/Session.java
+5
-3
src/share/classes/sun/security/pkcs11/Token.java
src/share/classes/sun/security/pkcs11/Token.java
+3
-3
src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java
src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java
+15
-14
src/share/classes/sun/security/provider/JavaKeyStore.java
src/share/classes/sun/security/provider/JavaKeyStore.java
+1
-1
src/share/classes/sun/security/provider/certpath/X509CertPath.java
.../classes/sun/security/provider/certpath/X509CertPath.java
+7
-1
src/share/classes/sun/security/provider/certpath/ldap/LDAPCertStore.java
...es/sun/security/provider/certpath/ldap/LDAPCertStore.java
+2
-1
src/share/classes/sun/security/ssl/SSLSessionContextImpl.java
...share/classes/sun/security/ssl/SSLSessionContextImpl.java
+3
-1
src/share/classes/sun/security/tools/KeyStoreUtil.java
src/share/classes/sun/security/tools/KeyStoreUtil.java
+3
-1
src/share/classes/sun/security/util/HostnameChecker.java
src/share/classes/sun/security/util/HostnameChecker.java
+4
-4
src/share/classes/sun/security/x509/DNSName.java
src/share/classes/sun/security/x509/DNSName.java
+1
-1
src/share/classes/sun/security/x509/RFC822Name.java
src/share/classes/sun/security/x509/RFC822Name.java
+1
-1
src/share/classes/sun/security/x509/X500Name.java
src/share/classes/sun/security/x509/X500Name.java
+1
-2
src/share/classes/sun/tools/jconsole/ProxyClient.java
src/share/classes/sun/tools/jconsole/ProxyClient.java
+5
-13
src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystem.java
...e/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystem.java
+69
-69
src/solaris/classes/sun/nio/ch/InheritedChannel.java
src/solaris/classes/sun/nio/ch/InheritedChannel.java
+2
-2
src/solaris/classes/sun/nio/fs/LinuxWatchService.java
src/solaris/classes/sun/nio/fs/LinuxWatchService.java
+4
-1
src/solaris/lib/content-types.properties
src/solaris/lib/content-types.properties
+4
-0
src/solaris/native/sun/nio/fs/genUnixConstants.c
src/solaris/native/sun/nio/fs/genUnixConstants.c
+1
-0
src/windows/classes/sun/nio/ch/WindowsAsynchronousFileChannelImpl.java
...lasses/sun/nio/ch/WindowsAsynchronousFileChannelImpl.java
+1
-3
src/windows/lib/content-types.properties
src/windows/lib/content-types.properties
+4
-0
test/ProblemList.txt
test/ProblemList.txt
+27
-0
test/com/sun/security/sasl/ntlm/Conformance.java
test/com/sun/security/sasl/ntlm/Conformance.java
+104
-0
test/java/io/IOException/LastErrorString.java
test/java/io/IOException/LastErrorString.java
+1
-0
test/java/io/etc/FailingFlushAndClose.java
test/java/io/etc/FailingFlushAndClose.java
+268
-0
test/java/lang/ProcessBuilder/Basic.java
test/java/lang/ProcessBuilder/Basic.java
+1
-1
test/java/lang/management/ManagementFactory/GetObjectName.java
...java/lang/management/ManagementFactory/GetObjectName.java
+75
-0
test/java/lang/reflect/Generics/Probe.java
test/java/lang/reflect/Generics/Probe.java
+11
-11
test/java/lang/reflect/Generics/SignatureTest.java
test/java/lang/reflect/Generics/SignatureTest.java
+50
-0
test/java/lang/reflect/Generics/TestBadSignatures.java
test/java/lang/reflect/Generics/TestBadSignatures.java
+54
-0
test/java/net/CookieHandler/TestHttpCookie.java
test/java/net/CookieHandler/TestHttpCookie.java
+7
-6
test/java/nio/channels/DatagramChannel/NetworkConfiguration.java
...va/nio/channels/DatagramChannel/NetworkConfiguration.java
+12
-1
test/java/nio/channels/DatagramChannel/SelectWhenRefused.java
.../java/nio/channels/DatagramChannel/SelectWhenRefused.java
+12
-5
test/java/util/zip/LargeZip.java
test/java/util/zip/LargeZip.java
+234
-165
test/javax/naming/ldap/LdapName/CompareToEqualsTests.java
test/javax/naming/ldap/LdapName/CompareToEqualsTests.java
+49
-38
未找到文件。
src/share/classes/com/sun/jndi/ldap/ClientId.java
浏览文件 @
2629adac
...
...
@@ -25,6 +25,7 @@
package
com.sun.jndi.ldap
;
import
java.util.Locale
;
import
java.util.Arrays
;
// JDK 1.2
import
java.io.OutputStream
;
import
javax.naming.ldap.Control
;
...
...
@@ -71,7 +72,7 @@ class ClientId {
ClientId
(
int
version
,
String
hostname
,
int
port
,
String
protocol
,
Control
[]
bindCtls
,
OutputStream
trace
,
String
socketFactory
)
{
this
.
version
=
version
;
this
.
hostname
=
hostname
.
toLowerCase
();
// ignore case
this
.
hostname
=
hostname
.
toLowerCase
(
Locale
.
ENGLISH
);
// ignore case
this
.
port
=
port
;
this
.
protocol
=
protocol
;
this
.
bindCtls
=
(
bindCtls
!=
null
?
bindCtls
.
clone
()
:
null
);
...
...
@@ -83,13 +84,15 @@ class ClientId {
if
((
socketFactory
!=
null
)
&&
!
socketFactory
.
equals
(
LdapCtx
.
DEFAULT_SSL_FACTORY
))
{
try
{
Class
<?>
socketFactoryClass
=
Obj
.
helper
.
loadClass
(
socketFactory
);
Class
<?>
socketFactoryClass
=
Obj
.
helper
.
loadClass
(
socketFactory
);
Class
<?>
objClass
=
Class
.
forName
(
"java.lang.Object"
);
this
.
sockComparator
=
socketFactoryClass
.
getMethod
(
"compare"
,
new
Class
<?>[]{
objClass
,
objClass
});
Method
getDefault
=
socketFactoryClass
.
getMethod
(
"getDefault"
,
new
Class
<?>[]{});
this
.
factory
=
(
SocketFactory
)
getDefault
.
invoke
(
null
,
new
Object
[]{});
Method
getDefault
=
socketFactoryClass
.
getMethod
(
"getDefault"
,
new
Class
<?>[]{});
this
.
factory
=
(
SocketFactory
)
getDefault
.
invoke
(
null
,
new
Object
[]{});
}
catch
(
Exception
e
)
{
// Ignore it here, the same exceptions are/will be handled by
// LdapPoolManager and Connection classes.
...
...
src/share/classes/com/sun/jndi/ldap/LdapClient.java
浏览文件 @
2629adac
...
...
@@ -26,6 +26,7 @@
package
com.sun.jndi.ldap
;
import
java.io.*
;
import
java.util.Locale
;
import
java.util.Vector
;
import
java.util.Hashtable
;
...
...
@@ -738,14 +739,15 @@ public final class LdapClient implements PooledConnection {
if
(
hasBinaryValues
)
{
la
.
add
(
ber
.
parseOctetString
(
ber
.
peekByte
(),
len
));
}
else
{
la
.
add
(
ber
.
parseStringWithTag
(
Ber
.
ASN_SIMPLE_STRING
,
isLdapv3
,
len
));
la
.
add
(
ber
.
parseStringWithTag
(
Ber
.
ASN_SIMPLE_STRING
,
isLdapv3
,
len
));
}
return
len
[
0
];
}
private
boolean
isBinaryValued
(
String
attrid
,
Hashtable
<
String
,
Boolean
>
binaryAttrs
)
{
String
id
=
attrid
.
toLowerCase
();
String
id
=
attrid
.
toLowerCase
(
Locale
.
ENGLISH
);
return
((
id
.
indexOf
(
";binary"
)
!=
-
1
)
||
defaultBinaryAttrs
.
containsKey
(
id
)
||
...
...
@@ -753,8 +755,8 @@ public final class LdapClient implements PooledConnection {
}
// package entry point; used by Connection
static
void
parseResult
(
BerDecoder
replyBer
,
LdapResult
res
,
boolean
isLdapv3
)
throws
IOException
{
static
void
parseResult
(
BerDecoder
replyBer
,
LdapResult
res
,
boolean
isLdapv3
)
throws
IOException
{
res
.
status
=
replyBer
.
parseEnumeration
();
res
.
matchedDN
=
replyBer
.
parseString
(
isLdapv3
);
...
...
src/share/classes/com/sun/jndi/ldap/LdapCtx.java
浏览文件 @
2629adac
...
...
@@ -33,6 +33,7 @@ import javax.naming.ldap.*;
import
javax.naming.ldap.LdapName
;
import
javax.naming.ldap.Rdn
;
import
java.util.Locale
;
import
java.util.Vector
;
import
java.util.Hashtable
;
import
java.util.List
;
...
...
@@ -2597,7 +2598,7 @@ final public class LdapCtx extends ComponentDirContext
}
else
{
binaryAttrs
=
new
Hashtable
<>(
11
,
0.75f
);
StringTokenizer
tokens
=
new
StringTokenizer
(
attrIds
.
toLowerCase
(),
" "
);
new
StringTokenizer
(
attrIds
.
toLowerCase
(
Locale
.
ENGLISH
),
" "
);
while
(
tokens
.
hasMoreTokens
())
{
binaryAttrs
.
put
(
tokens
.
nextToken
(),
Boolean
.
TRUE
);
...
...
src/share/classes/com/sun/jndi/ldap/LdapName.java
浏览文件 @
2629adac
...
...
@@ -28,6 +28,7 @@ package com.sun.jndi.ldap;
import
java.util.Enumeration
;
import
java.util.Vector
;
import
java.util.Locale
;
import
javax.naming.*
;
import
javax.naming.directory.Attributes
;
...
...
@@ -707,7 +708,7 @@ public final class LdapName implements Name {
TypeAndValue
that
=
(
TypeAndValue
)
obj
;
int
diff
=
type
.
toUpperCase
().
compareTo
(
that
.
type
.
toUpperCase
()
);
int
diff
=
type
.
compareToIgnoreCase
(
that
.
type
);
if
(
diff
!=
0
)
{
return
diff
;
}
...
...
@@ -730,7 +731,7 @@ public final class LdapName implements Name {
public
int
hashCode
()
{
// If two objects are equal, their hash codes must match.
return
(
type
.
toUpperCase
().
hashCode
()
+
return
(
type
.
toUpperCase
(
Locale
.
ENGLISH
).
hashCode
()
+
getValueComparable
().
hashCode
());
}
...
...
@@ -764,11 +765,12 @@ public final class LdapName implements Name {
// cache result
if
(
binary
)
{
comparable
=
value
.
toUpperCase
();
comparable
=
value
.
toUpperCase
(
Locale
.
ENGLISH
);
}
else
{
comparable
=
(
String
)
unescapeValue
(
value
);
if
(!
valueCaseSensitive
)
{
comparable
=
comparable
.
toUpperCase
();
// ignore case
// ignore case
comparable
=
comparable
.
toUpperCase
(
Locale
.
ENGLISH
);
}
}
return
comparable
;
...
...
@@ -836,7 +838,7 @@ public final class LdapName implements Name {
buf
.
append
(
Character
.
forDigit
(
0xF
&
b
,
16
));
}
return
(
new
String
(
buf
)).
toUpperCase
();
return
(
new
String
(
buf
)).
toUpperCase
(
Locale
.
ENGLISH
);
}
/*
...
...
src/share/classes/com/sun/jndi/ldap/LdapPoolManager.java
浏览文件 @
2629adac
...
...
@@ -28,6 +28,7 @@ package com.sun.jndi.ldap;
import
java.io.PrintStream
;
import
java.io.OutputStream
;
import
java.util.Hashtable
;
import
java.util.Locale
;
import
java.util.StringTokenizer
;
import
javax.naming.ldap.Control
;
...
...
@@ -133,7 +134,7 @@ public final class LdapPoolManager {
String
mech
;
int
p
;
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
mech
=
parser
.
nextToken
().
toLowerCase
();
mech
=
parser
.
nextToken
().
toLowerCase
(
Locale
.
ENGLISH
);
if
(
mech
.
equals
(
"anonymous"
))
{
mech
=
"none"
;
}
...
...
src/share/classes/com/sun/jndi/toolkit/dir/HierMemDirCtx.java
浏览文件 @
2629adac
...
...
@@ -910,7 +910,7 @@ final class HierarchicalName extends CompoundName {
public
int
hashCode
()
{
if
(
hashValue
==
-
1
)
{
String
name
=
toString
().
toUpperCase
();
String
name
=
toString
().
toUpperCase
(
Locale
.
ENGLISH
);
int
len
=
name
.
length
();
int
off
=
0
;
char
val
[]
=
new
char
[
len
];
...
...
src/share/classes/com/sun/jndi/toolkit/dir/SearchFilter.java
浏览文件 @
2629adac
...
...
@@ -29,6 +29,7 @@ import javax.naming.directory.*;
import
java.util.Enumeration
;
import
java.util.StringTokenizer
;
import
java.util.Vector
;
import
java.util.Locale
;
/**
* A class for parsing LDAP search filters (defined in RFC 1960, 2254)
...
...
@@ -395,19 +396,21 @@ public class SearchFilter implements AttrFilter {
// do we need to begin with the first token?
if
(
proto
.
charAt
(
0
)
!=
WILDCARD_TOKEN
&&
!
value
.
toString
().
toLowerCase
().
startsWith
(
subStrs
.
nextToken
().
toLowerCase
()))
{
if
(
debug
)
{
System
.
out
.
println
(
"faild initial test"
);}
!
value
.
toString
().
toLowerCase
(
Locale
.
ENGLISH
).
startsWith
(
subStrs
.
nextToken
().
toLowerCase
(
Locale
.
ENGLISH
)))
{
if
(
debug
)
{
System
.
out
.
println
(
"faild initial test"
);
}
return
false
;
}
while
(
subStrs
.
hasMoreTokens
())
{
String
currentStr
=
subStrs
.
nextToken
();
if
(
debug
)
{
System
.
out
.
println
(
"looking for \""
+
currentStr
+
"\""
);}
currentPos
=
value
.
toLowerCase
().
indexOf
(
currentStr
.
toLowerCase
(),
currentPos
);
currentPos
=
value
.
toLowerCase
(
Locale
.
ENGLISH
).
indexOf
(
currentStr
.
toLowerCase
(
Locale
.
ENGLISH
),
currentPos
);
if
(
currentPos
==
-
1
)
{
return
false
;
}
...
...
src/share/classes/com/sun/security/ntlm/Client.java
浏览文件 @
2629adac
...
...
@@ -69,14 +69,16 @@ public final class Client extends NTLM {
* This method does not make any modification to this parameter, it neither
* needs to access the content of this parameter after this method call,
* so you are free to modify or nullify this parameter after this call.
* @throws NullPointerException if {@code username} or {@code password} is null.
* @throws NTLMException if {@code version} is illegal
* @throws NTLMException if {@code username} or {@code password} is null,
* or {@code version} is illegal.
*
*/
public
Client
(
String
version
,
String
hostname
,
String
username
,
String
domain
,
char
[]
password
)
throws
NTLMException
{
super
(
version
);
if
((
username
==
null
||
password
==
null
))
{
throw
new
NullPointerException
(
"username/password cannot be null"
);
throw
new
NTLMException
(
NTLMException
.
PROTOCOL
,
"username/password cannot be null"
);
}
this
.
hostname
=
hostname
;
this
.
username
=
username
;
...
...
@@ -117,13 +119,13 @@ public final class Client extends NTLM {
* @param nonce random 8-byte array to be used in message generation,
* must not be null except for original NTLM v1
* @return the message generated
* @throws NullPointerException if {@code type2} or {@code nonce} is null
* for NTLM v1.
* @throws NTLMException if the incoming message is invalid
* @throws NTLMException if the incoming message is invalid, or
* {@code nonce} is null for NTLM v1.
*/
public
byte
[]
type3
(
byte
[]
type2
,
byte
[]
nonce
)
throws
NTLMException
{
if
(
type2
==
null
||
(
v
!=
Version
.
NTLM
&&
nonce
==
null
))
{
throw
new
NullPointerException
(
"type2 and nonce cannot be null"
);
throw
new
NTLMException
(
NTLMException
.
PROTOCOL
,
"type2 and nonce cannot be null"
);
}
debug
(
"NTLM Client: Type 2 received\n"
);
debug
(
type2
);
...
...
src/share/classes/com/sun/security/ntlm/NTLM.java
浏览文件 @
2629adac
...
...
@@ -33,6 +33,7 @@ import java.security.MessageDigest;
import
java.security.NoSuchAlgorithmException
;
import
java.security.spec.InvalidKeySpecException
;
import
java.util.Arrays
;
import
java.util.Locale
;
import
javax.crypto.BadPaddingException
;
import
javax.crypto.Cipher
;
import
javax.crypto.IllegalBlockSizeException
;
...
...
@@ -410,7 +411,8 @@ class NTLM {
static
byte
[]
getP1
(
char
[]
password
)
{
try
{
return
new
String
(
password
).
toUpperCase
().
getBytes
(
"ISO8859_1"
);
return
new
String
(
password
).
toUpperCase
(
Locale
.
ENGLISH
).
getBytes
(
"ISO8859_1"
);
}
catch
(
UnsupportedEncodingException
ex
)
{
return
null
;
}
...
...
src/share/classes/com/sun/security/ntlm/NTLMException.java
浏览文件 @
2629adac
...
...
@@ -65,6 +65,11 @@ public final class NTLMException extends GeneralSecurityException {
*/
public
final
static
int
BAD_VERSION
=
5
;
/**
* Protocol errors.
*/
public
final
static
int
PROTOCOL
=
6
;
private
int
errorCode
;
/**
...
...
src/share/classes/com/sun/security/ntlm/Server.java
浏览文件 @
2629adac
...
...
@@ -62,12 +62,13 @@ public abstract class Server extends NTLM {
* is selected, authentication succeeds if one of LM (or LMv2) or
* NTLM (or NTLMv2) is verified.
* @param domain the domain, must not be null
* @throws N
ullPointer
Exception if {@code domain} is null.
* @throws N
TLM
Exception if {@code domain} is null.
*/
public
Server
(
String
version
,
String
domain
)
throws
NTLMException
{
super
(
version
);
if
(
domain
==
null
)
{
throw
new
NullPointerException
(
"domain cannot be null"
);
throw
new
NTLMException
(
NTLMException
.
PROTOCOL
,
"domain cannot be null"
);
}
this
.
allVersion
=
(
version
==
null
);
this
.
domain
=
domain
;
...
...
@@ -80,12 +81,13 @@ public abstract class Server extends NTLM {
* @param nonce the random 8-byte array to be used in message generation,
* must not be null
* @return the message generated
* @throws N
ullPointerException if type1 or nonce is null
*
@throws NTLMException if the incoming message is invalid
* @throws N
TLMException if the incoming message is invalid, or
*
{@code nonce} is null.
*/
public
byte
[]
type2
(
byte
[]
type1
,
byte
[]
nonce
)
{
public
byte
[]
type2
(
byte
[]
type1
,
byte
[]
nonce
)
throws
NTLMException
{
if
(
nonce
==
null
)
{
throw
new
NullPointerException
(
"nonce cannot be null"
);
throw
new
NTLMException
(
NTLMException
.
PROTOCOL
,
"nonce cannot be null"
);
}
debug
(
"NTLM Server: Type 1 received\n"
);
if
(
type1
!=
null
)
debug
(
type1
);
...
...
@@ -105,13 +107,14 @@ public abstract class Server extends NTLM {
* @param type3 the incoming Type3 message from client, must not be null
* @param nonce the same nonce provided in {@link #type2}, must not be null
* @return username and hostname of the client in a byte array
* @throws N
ullPointerException if {@code type3} or {@code nonce} is null
*
@throws NTLMException if the incoming message is invalid
* @throws N
TLMException if the incoming message is invalid, or
*
{@code nonce} is null.
*/
public
String
[]
verify
(
byte
[]
type3
,
byte
[]
nonce
)
throws
NTLMException
{
if
(
type3
==
null
||
nonce
==
null
)
{
throw
new
NullPointerException
(
"type1 or nonce cannot be null"
);
throw
new
NTLMException
(
NTLMException
.
PROTOCOL
,
"type1 or nonce cannot be null"
);
}
debug
(
"NTLM Server: Type 3 received\n"
);
if
(
type3
!=
null
)
debug
(
type3
);
...
...
src/share/classes/com/sun/security/sasl/ntlm/FactoryImpl.java
浏览文件 @
2629adac
...
...
@@ -70,6 +70,12 @@ SaslServerFactory{
if
(
mechs
[
i
].
equals
(
"NTLM"
)
&&
PolicyUtils
.
checkPolicy
(
mechPolicies
[
0
],
props
))
{
if
(
cbh
==
null
)
{
throw
new
SaslException
(
"Callback handler with support for "
+
"RealmCallback, NameCallback, and PasswordCallback "
+
"required"
);
}
return
new
NTLMClient
(
mechs
[
i
],
authorizationId
,
protocol
,
serverName
,
props
,
cbh
);
}
...
...
@@ -98,9 +104,9 @@ SaslServerFactory{
}
if
(
cbh
==
null
)
{
throw
new
SaslException
(
"Callback handler with support for AuthorizeCallback, "
+
"RealmCallback, NameCallback, and PasswordCallback "
+
"required"
);
"Callback handler with support for "
+
"RealmCallback, NameCallback, and PasswordCallback "
+
"required"
);
}
return
new
NTLMServer
(
mech
,
protocol
,
serverName
,
props
,
cbh
);
}
...
...
src/share/classes/com/sun/security/sasl/ntlm/NTLMClient.java
浏览文件 @
2629adac
...
...
@@ -107,7 +107,7 @@ final class NTLMClient implements SaslClient {
* @param protocol non-null for Sasl, useless for NTLM
* @param serverName non-null for Sasl, but can be null for NTLM
* @param props can be null
* @param cbh can be null for Sasl,
but will throw NPE for NTLM
* @param cbh can be null for Sasl,
already null-checked in factory
* @throws SaslException
*/
NTLMClient
(
String
mech
,
String
authzid
,
String
protocol
,
String
serverName
,
...
...
@@ -166,7 +166,7 @@ final class NTLMClient implements SaslClient {
pcb
.
getPassword
());
}
catch
(
NTLMException
ne
)
{
throw
new
SaslException
(
"NTLM:
Invalid version string: "
+
version
,
ne
);
"NTLM:
client creation failure"
,
ne
);
}
}
...
...
@@ -183,17 +183,20 @@ final class NTLMClient implements SaslClient {
@Override
public
byte
[]
unwrap
(
byte
[]
incoming
,
int
offset
,
int
len
)
throws
SaslException
{
throw
new
UnsupportedOperation
Exception
(
"Not supported."
);
throw
new
IllegalState
Exception
(
"Not supported."
);
}
@Override
public
byte
[]
wrap
(
byte
[]
outgoing
,
int
offset
,
int
len
)
throws
SaslException
{
throw
new
UnsupportedOperation
Exception
(
"Not supported."
);
throw
new
IllegalState
Exception
(
"Not supported."
);
}
@Override
public
Object
getNegotiatedProperty
(
String
propName
)
{
if
(!
isComplete
())
{
throw
new
IllegalStateException
(
"authentication not complete"
);
}
switch
(
propName
)
{
case
Sasl
.
QOP
:
return
"auth"
;
...
...
src/share/classes/com/sun/security/sasl/ntlm/NTLMServer.java
浏览文件 @
2629adac
...
...
@@ -106,7 +106,7 @@ final class NTLMServer implements SaslServer {
* @param serverName not null for Sasl, can be null in NTLM. If non-null,
* might be used as domain if not provided in props
* @param props can be null
* @param cbh can be null for Sasl,
but will throw NPE in auth for NTLM
* @param cbh can be null for Sasl,
already null-checked in factory
* @throws SaslException
*/
NTLMServer
(
String
mech
,
String
protocol
,
String
serverName
,
...
...
@@ -132,7 +132,7 @@ final class NTLMServer implements SaslServer {
domain
=
serverName
;
}
if
(
domain
==
null
)
{
throw
new
NullPointer
Exception
(
"Domain must be provided as"
throw
new
Sasl
Exception
(
"Domain must be provided as"
+
" the serverName argument or in props"
);
}
...
...
@@ -159,7 +159,7 @@ final class NTLMServer implements SaslServer {
};
}
catch
(
NTLMException
ne
)
{
throw
new
SaslException
(
"NTLM:
Invalid version string: "
+
version
,
ne
);
"NTLM:
server creation failure"
,
ne
);
}
nonce
=
new
byte
[
8
];
}
...
...
@@ -182,8 +182,8 @@ final class NTLMServer implements SaslServer {
hostname
=
out
[
1
];
return
null
;
}
}
catch
(
GeneralSecurity
Exception
ex
)
{
throw
new
SaslException
(
""
,
ex
);
}
catch
(
NTLM
Exception
ex
)
{
throw
new
SaslException
(
"
NTLM: generate response failure
"
,
ex
);
}
}
...
...
@@ -194,23 +194,29 @@ final class NTLMServer implements SaslServer {
@Override
public
String
getAuthorizationID
()
{
if
(!
isComplete
())
{
throw
new
IllegalStateException
(
"authentication not complete"
);
}
return
authzId
;
}
@Override
public
byte
[]
unwrap
(
byte
[]
incoming
,
int
offset
,
int
len
)
throws
SaslException
{
throw
new
UnsupportedOperation
Exception
(
"Not supported yet."
);
throw
new
IllegalState
Exception
(
"Not supported yet."
);
}
@Override
public
byte
[]
wrap
(
byte
[]
outgoing
,
int
offset
,
int
len
)
throws
SaslException
{
throw
new
UnsupportedOperation
Exception
(
"Not supported yet."
);
throw
new
IllegalState
Exception
(
"Not supported yet."
);
}
@Override
public
Object
getNegotiatedProperty
(
String
propName
)
{
if
(!
isComplete
())
{
throw
new
IllegalStateException
(
"authentication not complete"
);
}
switch
(
propName
)
{
case
Sasl
.
QOP
:
return
"auth"
;
...
...
src/share/classes/com/sun/servicetag/SunConnection.java
浏览文件 @
2629adac
...
...
@@ -101,10 +101,7 @@ class SunConnection {
return
new
URL
(
registerURL
);
}
catch
(
MalformedURLException
ex
)
{
// should never reach here
InternalError
x
=
new
InternalError
(
ex
.
getMessage
());
x
.
initCause
(
ex
);
throw
x
;
throw
new
InternalError
(
ex
.
getMessage
(),
ex
);
}
}
...
...
@@ -171,9 +168,7 @@ class SunConnection {
try
{
BrowserSupport
.
browse
(
url
.
toURI
());
}
catch
(
URISyntaxException
ex
)
{
InternalError
x
=
new
InternalError
(
"Error in registering: "
+
ex
.
getMessage
());
x
.
initCause
(
ex
);
throw
x
;
throw
new
InternalError
(
"Error in registering: "
+
ex
.
getMessage
(),
ex
);
}
catch
(
IllegalArgumentException
ex
)
{
if
(
Util
.
isVerbose
())
{
ex
.
printStackTrace
();
...
...
@@ -232,9 +227,7 @@ class SunConnection {
return
(
returnCode
==
HttpURLConnection
.
HTTP_OK
);
}
catch
(
MalformedURLException
me
)
{
// should never reach here
InternalError
x
=
new
InternalError
(
"Error in registering: "
+
me
.
getMessage
());
x
.
initCause
(
me
);
throw
x
;
throw
new
InternalError
(
"Error in registering: "
+
me
.
getMessage
(),
me
);
}
catch
(
Exception
ioe
)
{
// SocketTimeoutException, IOException or UnknownHostException
if
(
Util
.
isVerbose
())
{
...
...
@@ -262,10 +255,9 @@ class SunConnection {
BrowserSupport
.
browse
(
registerPage
.
toURI
());
}
catch
(
FileNotFoundException
ex
)
{
// should never reach here
InternalError
x
=
new
InternalError
(
"Error in launching "
+
registerPage
+
": "
+
ex
.
getMessage
());
x
.
initCause
(
ex
);
throw
x
;
throw
new
InternalError
(
"Error in launching "
+
registerPage
+
": "
+
ex
.
getMessage
()
,
ex
);
}
catch
(
IllegalArgumentException
ex
)
{
if
(
Util
.
isVerbose
())
{
ex
.
printStackTrace
();
...
...
src/share/classes/java/io/BufferedReader.java
浏览文件 @
2629adac
...
...
@@ -514,9 +514,12 @@ public class BufferedReader extends Reader {
synchronized
(
lock
)
{
if
(
in
==
null
)
return
;
in
.
close
();
in
=
null
;
cb
=
null
;
try
{
in
.
close
();
}
finally
{
in
=
null
;
cb
=
null
;
}
}
}
}
src/share/classes/java/io/BufferedWriter.java
浏览文件 @
2629adac
...
...
@@ -255,15 +255,15 @@ public class BufferedWriter extends Writer {
}
}
@SuppressWarnings
(
"try"
)
public
void
close
()
throws
IOException
{
synchronized
(
lock
)
{
if
(
out
==
null
)
{
return
;
}
try
{
try
(
Writer
w
=
out
)
{
flushBuffer
();
}
finally
{
out
.
close
();
out
=
null
;
cb
=
null
;
}
...
...
src/share/classes/java/io/Closeable.java
浏览文件 @
2629adac
...
...
@@ -42,6 +42,12 @@ public interface Closeable extends AutoCloseable {
* with it. If the stream is already closed then invoking this
* method has no effect.
*
* <p> As noted in {@link AutoCloseable#close()}, cases where the
* close may fail require careful attention. It is strongly advised
* to relinquish the underlying resources and to internally
* <em>mark</em> the {@code Closeable} as closed, prior to throwing
* the {@code IOException}.
*
* @throws IOException if an I/O error occurs
*/
public
void
close
()
throws
IOException
;
...
...
src/share/classes/java/io/FilterOutputStream.java
浏览文件 @
2629adac
...
...
@@ -152,11 +152,10 @@ class FilterOutputStream extends OutputStream {
* @see java.io.FilterOutputStream#flush()
* @see java.io.FilterOutputStream#out
*/
@SuppressWarnings
(
"try"
)
public
void
close
()
throws
IOException
{
try
{
flush
();
}
catch
(
IOException
ignored
)
{
try
(
OutputStream
ostream
=
out
)
{
flush
();
}
out
.
close
();
}
}
src/share/classes/java/lang/AutoCloseable.java
浏览文件 @
2629adac
...
...
@@ -43,6 +43,15 @@ public interface AutoCloseable {
* throw more specific exceptions, or to throw no exception at all
* if the close operation cannot fail.
*
* <p> Cases where the close operation may fail require careful
* attention by implementers. It is strongly advised to relinquish
* the underlying resources and to internally <em>mark</em> the
* resource as closed, prior to throwing the exception. The {@code
* close} method is unlikely to be invoked more than once and so
* this ensures that the resources are released in a timely manner.
* Furthermore it reduces problems that could arise when the resource
* wraps, or is wrapped, by another resource.
*
* <p><em>Implementers of this interface are also strongly advised
* to not have the {@code close} method throw {@link
* InterruptedException}.</em>
...
...
src/share/classes/java/lang/InternalError.java
浏览文件 @
2629adac
/*
* Copyright (c) 1994, 20
08
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 20
11
, 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
...
...
@@ -32,8 +32,7 @@ package java.lang;
* @author unascribed
* @since JDK1.0
*/
public
class
InternalError
extends
VirtualMachineError
{
public
class
InternalError
extends
VirtualMachineError
{
private
static
final
long
serialVersionUID
=
-
9062593416125562365L
;
/**
...
...
@@ -47,9 +46,45 @@ class InternalError extends VirtualMachineError {
* Constructs an <code>InternalError</code> with the specified
* detail message.
*
* @param
s
the detail message.
* @param
message
the detail message.
*/
public
InternalError
(
String
s
)
{
super
(
s
);
public
InternalError
(
String
message
)
{
super
(
message
);
}
/**
* Constructs an {@code InternalError} with the specified detail
* message and cause. <p>Note that the detail message associated
* with {@code cause} is <i>not</i> automatically incorporated in
* this error's detail message.
*
* @param message the detail message (which is saved for later retrieval
* by the {@link #getMessage()} method).
* @param cause the cause (which is saved for later retrieval by the
* {@link #getCause()} method). (A {@code null} value is
* permitted, and indicates that the cause is nonexistent or
* unknown.)
* @since 1.8
*/
public
InternalError
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
/**
* Constructs an {@code InternalError} with the specified cause
* and a detail message of {@code (cause==null ? null :
* cause.toString())} (which typically contains the class and
* detail message of {@code cause}).
*
* @param cause the cause (which is saved for later retrieval by the
* {@link #getCause()} method). (A {@code null} value is
* permitted, and indicates that the cause is nonexistent or
* unknown.)
* @since 1.8
*/
public
InternalError
(
Throwable
cause
)
{
super
(
cause
);
}
}
src/share/classes/java/lang/System.java
浏览文件 @
2629adac
...
...
@@ -632,6 +632,7 @@ public final class System {
*
* <p>On UNIX systems, it returns {@code "\n"}; on Microsoft
* Windows systems it returns {@code "\r\n"}.
* @since 1.7
*/
public
static
String
lineSeparator
()
{
return
lineSeparator
;
...
...
src/share/classes/java/lang/VirtualMachineError.java
浏览文件 @
2629adac
/*
* Copyright (c) 1995,
1997
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995,
2011
, 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
* under the terms of the GNU General Public License version 2 only, as
P
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
...
...
@@ -33,8 +33,9 @@ package java.lang;
* @author Frank Yellin
* @since JDK1.0
*/
abstract
public
class
VirtualMachineError
extends
Error
{
abstract
public
class
VirtualMachineError
extends
Error
{
private
static
final
long
serialVersionUID
=
4161983926571568670L
;
/**
* Constructs a <code>VirtualMachineError</code> with no detail message.
*/
...
...
@@ -46,9 +47,43 @@ class VirtualMachineError extends Error {
* Constructs a <code>VirtualMachineError</code> with the specified
* detail message.
*
* @param s the detail message.
* @param message the detail message.
*/
public
VirtualMachineError
(
String
message
)
{
super
(
message
);
}
/**
* Constructs a {@code VirtualMachineError} with the specified
* detail message and cause. <p>Note that the detail message
* associated with {@code cause} is <i>not</i> automatically
* incorporated in this error's detail message.
*
* @param message the detail message (which is saved for later retrieval
* by the {@link #getMessage()} method).
* @param cause the cause (which is saved for later retrieval by the
* {@link #getCause()} method). (A {@code null} value is
* permitted, and indicates that the cause is nonexistent or
* unknown.)
* @since 1.8
*/
public
VirtualMachineError
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
/**
* Constructs an a {@code VirtualMachineError} with the specified
* cause and a detail message of {@code (cause==null ? null :
* cause.toString())} (which typically contains the class and
* detail message of {@code cause}).
*
* @param cause the cause (which is saved for later retrieval by the
* {@link #getCause()} method). (A {@code null} value is
* permitted, and indicates that the cause is nonexistent or
* unknown.)
* @since 1.8
*/
public
VirtualMachineError
(
String
s
)
{
super
(
s
);
public
VirtualMachineError
(
Throwable
cause
)
{
super
(
cause
);
}
}
src/share/classes/java/net/HttpCookie.java
浏览文件 @
2629adac
...
...
@@ -748,10 +748,14 @@ public final class HttpCookie implements Cloneable {
&&
(
embeddedDotInDomain
==
-
1
||
embeddedDotInDomain
==
domain
.
length
()
-
1
))
return
false
;
// if the host name contains no dot and the domain name is .local
// if the host name contains no dot and the domain name
// is .local or host.local
int
firstDotInHost
=
host
.
indexOf
(
'.'
);
if
(
firstDotInHost
==
-
1
&&
isLocalDomain
)
if
(
firstDotInHost
==
-
1
&&
(
isLocalDomain
||
domain
.
equalsIgnoreCase
(
host
+
".local"
)))
{
return
true
;
}
int
domainLength
=
domain
.
length
();
int
lengthDiff
=
host
.
length
()
-
domainLength
;
...
...
src/share/classes/java/security/KeyRep.java
浏览文件 @
2629adac
...
...
@@ -26,6 +26,7 @@
package
java.security
;
import
java.io.*
;
import
java.util.Locale
;
import
java.security.spec.PKCS8EncodedKeySpec
;
import
java.security.spec.X509EncodedKeySpec
;
...
...
@@ -137,7 +138,7 @@ public class KeyRep implements Serializable {
this
.
type
=
type
;
this
.
algorithm
=
algorithm
;
this
.
format
=
format
.
toUpperCase
();
this
.
format
=
format
.
toUpperCase
(
Locale
.
ENGLISH
);
this
.
encoded
=
encoded
.
clone
();
}
...
...
src/share/classes/java/security/Security.java
浏览文件 @
2629adac
...
...
@@ -1087,8 +1087,10 @@ public final class Security {
// Check the keys for each provider.
for
(
Enumeration
<
Object
>
e
=
providers
[
i
].
keys
();
e
.
hasMoreElements
();
)
{
String
currentKey
=
((
String
)
e
.
nextElement
()).
toUpperCase
();
if
(
currentKey
.
startsWith
(
serviceName
.
toUpperCase
()))
{
String
currentKey
=
((
String
)
e
.
nextElement
()).
toUpperCase
(
Locale
.
ENGLISH
);
if
(
currentKey
.
startsWith
(
serviceName
.
toUpperCase
(
Locale
.
ENGLISH
)))
{
// We should skip the currentKey if it contains a
// whitespace. The reason is: such an entry in the
// provider property contains attributes for the
...
...
@@ -1096,7 +1098,8 @@ public final class Security {
// in entries which lead to the implementation
// classes.
if
(
currentKey
.
indexOf
(
" "
)
<
0
)
{
result
.
add
(
currentKey
.
substring
(
serviceName
.
length
()
+
1
));
result
.
add
(
currentKey
.
substring
(
serviceName
.
length
()
+
1
));
}
}
}
...
...
src/share/classes/java/util/Observable.java
浏览文件 @
2629adac
/*
* Copyright (c) 1994, 20
04
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 20
11
, 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
...
...
@@ -44,7 +44,7 @@ package java.util;
* notifications on separate threads, or may guarantee that their
* subclass follows this order, as they choose.
* <p>
* Note that this notification mechanism
is
has nothing to do with threads
* Note that this notification mechanism has nothing to do with threads
* and is completely separate from the <tt>wait</tt> and <tt>notify</tt>
* mechanism of class <tt>Object</tt>.
* <p>
...
...
src/share/classes/java/util/prefs/Preferences.java
浏览文件 @
2629adac
...
...
@@ -256,11 +256,9 @@ public abstract class Preferences {
.
getContextClassLoader
())
.
newInstance
();
}
catch
(
Exception
e
)
{
InternalError
error
=
new
InternalError
(
throw
new
InternalError
(
"Can't instantiate Preferences factory "
+
factoryName
);
error
.
initCause
(
e
);
throw
error
;
+
factoryName
,
e
);
}
}
}
...
...
@@ -299,11 +297,9 @@ public abstract class Preferences {
return
(
PreferencesFactory
)
Class
.
forName
(
platformFactory
,
false
,
null
).
newInstance
();
}
catch
(
Exception
e
)
{
InternalError
error
=
new
InternalError
(
throw
new
InternalError
(
"Can't instantiate platform default Preferences factory "
+
platformFactory
);
error
.
initCause
(
e
);
throw
error
;
+
platformFactory
,
e
);
}
}
...
...
src/share/classes/javax/naming/NameImpl.java
浏览文件 @
2629adac
...
...
@@ -25,6 +25,7 @@
package
javax.naming
;
import
java.util.Locale
;
import
java.util.Vector
;
import
java.util.Enumeration
;
import
java.util.Properties
;
...
...
@@ -216,7 +217,8 @@ class NameImpl {
}
private
static
boolean
toBoolean
(
String
name
)
{
return
((
name
!=
null
)
&&
name
.
toLowerCase
().
equals
(
"true"
));
return
((
name
!=
null
)
&&
name
.
toLowerCase
(
Locale
.
ENGLISH
).
equals
(
"true"
));
}
private
final
void
recordNamingConvention
(
Properties
p
)
{
...
...
@@ -526,11 +528,14 @@ class NameImpl {
comp1
=
comp1
.
trim
();
comp2
=
comp2
.
trim
();
}
int
local
;
if
(
syntaxCaseInsensitive
)
{
comp1
=
comp1
.
toLowerCase
();
comp2
=
comp2
.
toLowerCase
();
local
=
comp1
.
compareToIgnoreCase
(
comp2
);
}
else
{
local
=
comp1
.
compareTo
(
comp2
);
}
int
local
=
comp1
.
compareTo
(
comp2
);
if
(
local
!=
0
)
{
return
local
;
}
...
...
@@ -696,7 +701,7 @@ class NameImpl {
comp
=
comp
.
trim
();
}
if
(
syntaxCaseInsensitive
)
{
comp
=
comp
.
toLowerCase
();
comp
=
comp
.
toLowerCase
(
Locale
.
ENGLISH
);
}
hash
+=
comp
.
hashCode
();
...
...
src/share/classes/javax/naming/directory/BasicAttributes.java
浏览文件 @
2629adac
...
...
@@ -28,6 +28,7 @@ package javax.naming.directory;
import
java.util.Hashtable
;
import
java.util.Enumeration
;
import
java.util.Locale
;
import
javax.naming.NamingException
;
import
javax.naming.NamingEnumeration
;
...
...
@@ -160,7 +161,7 @@ public class BasicAttributes implements Attributes {
public
Attribute
get
(
String
attrID
)
{
Attribute
attr
=
attrs
.
get
(
ignoreCase
?
attrID
.
toLowerCase
()
:
attrID
);
ignoreCase
?
attrID
.
toLowerCase
(
Locale
.
ENGLISH
)
:
attrID
);
return
(
attr
);
}
...
...
@@ -179,13 +180,13 @@ public class BasicAttributes implements Attributes {
public
Attribute
put
(
Attribute
attr
)
{
String
id
=
attr
.
getID
();
if
(
ignoreCase
)
{
id
=
id
.
toLowerCase
();
id
=
id
.
toLowerCase
(
Locale
.
ENGLISH
);
}
return
attrs
.
put
(
id
,
attr
);
}
public
Attribute
remove
(
String
attrID
)
{
String
id
=
(
ignoreCase
?
attrID
.
toLowerCase
()
:
attrID
);
String
id
=
(
ignoreCase
?
attrID
.
toLowerCase
(
Locale
.
ENGLISH
)
:
attrID
);
return
attrs
.
remove
(
id
);
}
...
...
src/share/classes/javax/naming/ldap/Rdn.java
浏览文件 @
2629adac
...
...
@@ -28,6 +28,7 @@ package javax.naming.ldap;
import
java.util.Iterator
;
import
java.util.NoSuchElementException
;
import
java.util.ArrayList
;
import
java.util.Locale
;
import
java.util.Collections
;
import
javax.naming.InvalidNameException
;
...
...
@@ -434,8 +435,7 @@ public class Rdn implements Serializable, Comparable<Object> {
}
public
int
compareTo
(
RdnEntry
that
)
{
int
diff
=
type
.
toUpperCase
().
compareTo
(
that
.
type
.
toUpperCase
());
int
diff
=
type
.
compareToIgnoreCase
(
that
.
type
);
if
(
diff
!=
0
)
{
return
diff
;
}
...
...
@@ -462,7 +462,7 @@ public class Rdn implements Serializable, Comparable<Object> {
}
public
int
hashCode
()
{
return
(
type
.
toUpperCase
().
hashCode
()
+
return
(
type
.
toUpperCase
(
Locale
.
ENGLISH
).
hashCode
()
+
getValueComparable
().
hashCode
());
}
...
...
@@ -479,7 +479,7 @@ public class Rdn implements Serializable, Comparable<Object> {
if
(
value
instanceof
byte
[])
{
comparable
=
escapeBinaryValue
((
byte
[])
value
);
}
else
{
comparable
=
((
String
)
value
).
toUpperCase
();
comparable
=
((
String
)
value
).
toUpperCase
(
Locale
.
ENGLISH
);
}
return
comparable
;
}
...
...
@@ -569,7 +569,6 @@ public class Rdn implements Serializable, Comparable<Object> {
builder
.
append
(
Character
.
forDigit
(
0xF
&
b
,
16
));
}
return
builder
.
toString
();
// return builder.toString().toUpperCase();
}
/**
...
...
src/share/classes/javax/net/ssl/HttpsURLConnection.java
浏览文件 @
2629adac
...
...
@@ -144,8 +144,7 @@ class HttpsURLConnection extends HttpURLConnection
throws
SSLPeerUnverifiedException
{
java
.
security
.
cert
.
Certificate
[]
certs
=
getServerCertificates
();
return
((
X500Principal
)
((
X509Certificate
)
certs
[
0
]).
getSubjectX500Principal
());
return
((
X509Certificate
)
certs
[
0
]).
getSubjectX500Principal
();
}
/**
...
...
@@ -173,8 +172,7 @@ class HttpsURLConnection extends HttpURLConnection
java
.
security
.
cert
.
Certificate
[]
certs
=
getLocalCertificates
();
if
(
certs
!=
null
)
{
return
((
X500Principal
)
((
X509Certificate
)
certs
[
0
]).
getSubjectX500Principal
());
return
((
X509Certificate
)
certs
[
0
]).
getSubjectX500Principal
();
}
else
{
return
null
;
}
...
...
src/share/classes/sun/font/FontManagerFactory.java
浏览文件 @
2629adac
...
...
@@ -78,20 +78,11 @@ public final class FontManagerFactory {
ClassLoader
cl
=
ClassLoader
.
getSystemClassLoader
();
Class
fmClass
=
Class
.
forName
(
fmClassName
,
true
,
cl
);
instance
=
(
FontManager
)
fmClass
.
newInstance
();
}
catch
(
ClassNotFoundException
ex
)
{
InternalError
err
=
new
InternalError
();
err
.
initCause
(
ex
);
throw
err
;
}
catch
(
ClassNotFoundException
|
InstantiationException
|
IllegalAccessException
ex
)
{
throw
new
InternalError
(
ex
)
;
}
catch
(
InstantiationException
ex
)
{
InternalError
err
=
new
InternalError
();
err
.
initCause
(
ex
);
throw
err
;
}
catch
(
IllegalAccessException
ex
)
{
InternalError
err
=
new
InternalError
();
err
.
initCause
(
ex
);
throw
err
;
}
return
null
;
}
...
...
src/share/classes/sun/management/ManagementFactoryHelper.java
浏览文件 @
2629adac
...
...
@@ -171,7 +171,8 @@ public class ManagementFactoryHelper {
ObjectName
result
=
objname
;
if
(
result
==
null
)
{
synchronized
(
this
)
{
if
(
objname
==
null
)
{
result
=
objname
;
if
(
result
==
null
)
{
result
=
Util
.
newObjectName
(
LOGGING_MXBEAN_NAME
);
objname
=
result
;
}
...
...
@@ -228,7 +229,8 @@ public class ManagementFactoryHelper {
ObjectName
result
=
objname
;
if
(
result
==
null
)
{
synchronized
(
this
)
{
if
(
objname
==
null
)
{
result
=
objname
;
if
(
result
==
null
)
{
result
=
Util
.
newObjectName
(
BUFFER_POOL_MXBEAN_NAME
+
",name="
+
pool
.
getName
());
objname
=
result
;
...
...
src/share/classes/sun/misc/URLClassPath.java
浏览文件 @
2629adac
...
...
@@ -717,7 +717,7 @@ public class URLClassPath {
try
{
ensureOpen
();
}
catch
(
IOException
e
)
{
throw
(
InternalError
)
new
InternalError
().
initCause
(
e
);
throw
new
InternalError
(
e
);
}
return
index
;
}
...
...
@@ -812,7 +812,7 @@ public class URLClassPath {
try
{
ensureOpen
();
}
catch
(
IOException
e
)
{
throw
(
InternalError
)
new
InternalError
().
initCause
(
e
);
throw
new
InternalError
(
e
);
}
final
JarEntry
entry
=
jar
.
getJarEntry
(
name
);
if
(
entry
!=
null
)
...
...
@@ -900,7 +900,7 @@ public class URLClassPath {
try
{
newLoader
.
ensureOpen
();
}
catch
(
IOException
e
)
{
throw
(
InternalError
)
new
InternalError
().
initCause
(
e
);
throw
new
InternalError
(
e
);
}
final
JarEntry
entry
=
newLoader
.
jar
.
getJarEntry
(
name
);
if
(
entry
!=
null
)
{
...
...
src/share/classes/sun/reflect/MethodAccessorGenerator.java
浏览文件 @
2629adac
...
...
@@ -401,10 +401,8 @@ class MethodAccessorGenerator extends AccessorGenerator {
0
,
bytes
.
length
,
declaringClass
.
getClassLoader
()).
newInstance
();
}
catch
(
InstantiationException
|
IllegalAccessException
e
)
{
throw
(
InternalError
)
new
InternalError
().
initCause
(
e
);
}
catch
(
InstantiationException
|
IllegalAccessException
e
)
{
throw
new
InternalError
(
e
);
}
}
});
...
...
src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java
浏览文件 @
2629adac
/*
* Copyright (c) 2003, 20
08
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 20
11
, 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
...
...
@@ -40,6 +40,7 @@ import java.security.PrivilegedAction;
* @since 1.5
*/
class
AnnotationInvocationHandler
implements
InvocationHandler
,
Serializable
{
private
static
final
long
serialVersionUID
=
6182022883658399397L
;
private
final
Class
<?
extends
Annotation
>
type
;
private
final
Map
<
String
,
Object
>
memberValues
;
...
...
src/share/classes/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java
浏览文件 @
2629adac
/*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004,
2011,
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
...
...
@@ -34,6 +34,7 @@ import java.lang.reflect.Method;
* @since 1.5
*/
class
AnnotationTypeMismatchExceptionProxy
extends
ExceptionProxy
{
private
static
final
long
serialVersionUID
=
7844069490309503934L
;
private
Method
member
;
private
String
foundType
;
...
...
src/share/classes/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java
浏览文件 @
2629adac
/*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004,
2011,
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
...
...
@@ -32,6 +32,7 @@ package sun.reflect.annotation;
* @since 1.5
*/
public
class
EnumConstantNotPresentExceptionProxy
extends
ExceptionProxy
{
private
static
final
long
serialVersionUID
=
-
604662101303187330L
;
Class
<?
extends
Enum
<?>>
enumType
;
String
constName
;
...
...
src/share/classes/sun/reflect/annotation/TypeNotPresentExceptionProxy.java
浏览文件 @
2629adac
/*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004,
2011,
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
...
...
@@ -33,6 +33,7 @@ import java.lang.annotation.*;
* @since 1.5
*/
public
class
TypeNotPresentExceptionProxy
extends
ExceptionProxy
{
private
static
final
long
serialVersionUID
=
5565925172427947573L
;
String
typeName
;
Throwable
cause
;
...
...
src/share/classes/sun/reflect/generics/parser/SignatureParser.java
浏览文件 @
2629adac
/*
* Copyright (c) 2003, 20
05
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 20
11
, 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
...
...
@@ -25,17 +25,15 @@
package
sun.reflect.generics.parser
;
import
java.lang.reflect.GenericSignatureFormatError
;
import
java.util.*
;
import
sun.reflect.generics.tree.*
;
/**
* Parser for type signatures, as defined in the Java Virtual
//
Machine Specification (JVMS) chapter 4.
*
Machine Specification (JVMS) chapter 4.
* Converts the signatures into an abstract syntax tree (AST) representation.
//
See the package sun.reflect.generics.tree for details of the AST.
*
See the package sun.reflect.generics.tree for details of the AST.
*/
public
class
SignatureParser
{
// The input is conceptually a character stream (though currently it's
...
...
@@ -58,8 +56,8 @@ public class SignatureParser {
// if (current != x {error("expected an x");
//
// where x is some character constant.
// The assertion in
id
cates, that, as currently written,
// the code should nver reach this point unless the input is an
// The assertion in
di
cates, that, as currently written,
// the code should n
e
ver reach this point unless the input is an
// x. On the other hand, the test is there to check the legality
// of the input wrt to a given production. It may be that at a later
// time the code might be called directly, and if the input is
...
...
@@ -68,7 +66,7 @@ public class SignatureParser {
private
char
[]
input
;
// the input signature
private
int
index
=
0
;
// index into the input
// used to mark end of input
// used to mark end of input
private
static
final
char
EOI
=
':'
;
private
static
final
boolean
DEBUG
=
false
;
...
...
@@ -104,6 +102,11 @@ public class SignatureParser {
index
++;
}
// For debugging, prints current character to the end of the input.
private
String
remainder
()
{
return
new
String
(
input
,
index
,
input
.
length
-
index
);
}
// Match c against a "set" of characters
private
boolean
matches
(
char
c
,
char
...
set
)
{
for
(
char
e
:
set
)
{
...
...
@@ -117,8 +120,17 @@ public class SignatureParser {
// Currently throws a GenericSignatureFormatError.
private
Error
error
(
String
errorMsg
)
{
if
(
DEBUG
)
System
.
out
.
println
(
"Parse error:"
+
errorMsg
);
return
new
GenericSignatureFormatError
();
return
new
GenericSignatureFormatError
(
"Signature Parse error: "
+
errorMsg
+
"\n\tRemaining input: "
+
remainder
());
}
/**
* Verify the parse has made forward progress; throw an exception
* if no progress.
*/
private
void
progress
(
int
startingPosition
)
{
if
(
index
<=
startingPosition
)
throw
error
(
"Failure to make progress!"
);
}
/**
...
...
@@ -163,6 +175,7 @@ public class SignatureParser {
/**
* Parses a type signature
* and produces an abstract syntax tree representing it.
*
* @param s a string representing the input type signature
* @return An abstract syntax tree for a type signature
* corresponding to the input string
...
...
@@ -183,38 +196,58 @@ public class SignatureParser {
// and when it completes parsing, it leaves the input at the first
// character after the input parses.
// parse a class signature based on the implicit input.
/*
* Note on grammar conventions: a trailing "*" matches zero or
* more occurrences, a trailing "+" matches one or more occurrences,
* "_opt" indicates an optional component.
*/
/**
* ClassSignature:
* FormalTypeParameters_opt SuperclassSignature SuperinterfaceSignature*
*/
private
ClassSignature
parseClassSignature
()
{
// parse a class signature based on the implicit input.
assert
(
index
==
0
);
return
ClassSignature
.
make
(
parseZeroOrMoreFormalTypeParameters
(),
parseClassTypeSignature
(),
parseClassTypeSignature
(),
// Only rule for SuperclassSignature
parseSuperInterfaces
());
}
private
FormalTypeParameter
[]
parseZeroOrMoreFormalTypeParameters
(){
if
(
current
()
==
'<'
)
{
return
parseFormalTypeParameters
();}
else
{
return
new
FormalTypeParameter
[
0
];}
if
(
current
()
==
'<'
)
{
return
parseFormalTypeParameters
();
}
else
{
return
new
FormalTypeParameter
[
0
];
}
}
/**
* FormalTypeParameters:
* "<" FormalTypeParameter+ ">"
*/
private
FormalTypeParameter
[]
parseFormalTypeParameters
(){
Collection
<
FormalTypeParameter
>
ftps
=
new
ArrayList
<
FormalTypeParameter
>(
3
);
List
<
FormalTypeParameter
>
ftps
=
new
ArrayList
<>(
3
);
assert
(
current
()
==
'<'
);
// should not have been called at all
if
(
current
()
!=
'<'
)
{
throw
error
(
"expected
<
"
);}
if
(
current
()
!=
'<'
)
{
throw
error
(
"expected
'<'
"
);}
advance
();
ftps
.
add
(
parseFormalTypeParameter
());
while
(
current
()
!=
'>'
)
{
int
startingPosition
=
index
;
ftps
.
add
(
parseFormalTypeParameter
());
progress
(
startingPosition
);
}
advance
();
FormalTypeParameter
[]
ftpa
=
new
FormalTypeParameter
[
ftps
.
size
()];
return
ftps
.
toArray
(
ftpa
);
return
ftps
.
toArray
(
new
FormalTypeParameter
[
ftps
.
size
()]);
}
/**
* FormalTypeParameter:
* Identifier ClassBound InterfaceBound*
*/
private
FormalTypeParameter
parseFormalTypeParameter
(){
String
id
=
parseIdentifier
();
FieldTypeSignature
[]
bs
=
parse
ZeroOrMore
Bounds
();
FieldTypeSignature
[]
bs
=
parseBounds
();
return
FormalTypeParameter
.
make
(
id
,
bs
);
}
...
...
@@ -229,7 +262,8 @@ public class SignatureParser {
case
'['
:
case
':'
:
case
'>'
:
case
'<'
:
return
result
.
toString
();
case
'<'
:
return
result
.
toString
();
default
:{
result
.
append
(
c
);
advance
();
...
...
@@ -239,26 +273,42 @@ public class SignatureParser {
}
return
result
.
toString
();
}
/**
* FieldTypeSignature:
* ClassTypeSignature
* ArrayTypeSignature
* TypeVariableSignature
*/
private
FieldTypeSignature
parseFieldTypeSignature
()
{
return
parseFieldTypeSignature
(
true
);
}
private
FieldTypeSignature
parseFieldTypeSignature
(
boolean
allowArrays
)
{
switch
(
current
())
{
case
'L'
:
return
parseClassTypeSignature
();
case
'T'
:
return
parseTypeVariableSignature
();
case
'['
:
return
parseArrayTypeSignature
();
if
(
allowArrays
)
return
parseArrayTypeSignature
();
else
throw
error
(
"Array signature not allowed here."
);
default
:
throw
error
(
"Expected Field Type Signature"
);
}
}
/**
* ClassTypeSignature:
* "L" PackageSpecifier_opt SimpleClassTypeSignature ClassTypeSignatureSuffix* ";"
*/
private
ClassTypeSignature
parseClassTypeSignature
(){
assert
(
current
()
==
'L'
);
if
(
current
()
!=
'L'
)
{
throw
error
(
"expected a class type"
);}
advance
();
List
<
SimpleClassTypeSignature
>
scts
=
new
ArrayList
<
SimpleClassTypeSignature
>(
5
);
scts
.
add
(
parseSimpleClassTypeSignature
(
false
));
List
<
SimpleClassTypeSignature
>
scts
=
new
ArrayList
<>(
5
);
scts
.
add
(
parsePackageNameAndSimpleClassTypeSignature
()
);
parseClassTypeSignatureSuffix
(
scts
);
if
(
current
()
!=
';'
)
throw
error
(
"expected ';' got '"
+
current
()
+
"'"
);
...
...
@@ -267,25 +317,65 @@ public class SignatureParser {
return
ClassTypeSignature
.
make
(
scts
);
}
private
SimpleClassTypeSignature
parseSimpleClassTypeSignature
(
boolean
dollar
){
String
id
=
parseIdentifier
();
char
c
=
current
();
switch
(
c
)
{
case
';'
:
case
'/'
:
return
SimpleClassTypeSignature
.
make
(
id
,
dollar
,
new
TypeArgument
[
0
])
;
case
'<'
:
{
return
SimpleClassTypeSignature
.
make
(
id
,
dollar
,
parseTypeArguments
());
}
default
:
{
throw
error
(
"expected < or ; or /"
);}
/**
* PackageSpecifier:
* Identifier "/" PackageSpecifier*
*/
private
SimpleClassTypeSignature
parsePackageNameAndSimpleClassTypeSignature
()
{
// Parse both any optional leading PackageSpecifier as well as
// the following SimpleClassTypeSignature.
String
id
=
parseIdentifier
();
if
(
current
()
==
'/'
)
{
// package name
StringBuilder
idBuild
=
new
StringBuilder
(
id
);
while
(
current
()
==
'/'
)
{
advance
();
idBuild
.
append
(
"."
);
idBuild
.
append
(
parseIdentifier
());
}
id
=
idBuild
.
toString
();
}
switch
(
current
())
{
case
';'
:
return
SimpleClassTypeSignature
.
make
(
id
,
false
,
new
TypeArgument
[
0
]);
// all done!
case
'<'
:
if
(
DEBUG
)
System
.
out
.
println
(
"\t remainder: "
+
remainder
());
return
SimpleClassTypeSignature
.
make
(
id
,
false
,
parseTypeArguments
());
default
:
throw
error
(
"expected '<' or ';' but got "
+
current
());
}
}
/**
* SimpleClassTypeSignature:
* Identifier TypeArguments_opt
*/
private
SimpleClassTypeSignature
parseSimpleClassTypeSignature
(
boolean
dollar
){
String
id
=
parseIdentifier
();
char
c
=
current
();
switch
(
c
)
{
case
';'
:
case
'.'
:
return
SimpleClassTypeSignature
.
make
(
id
,
dollar
,
new
TypeArgument
[
0
])
;
case
'<'
:
return
SimpleClassTypeSignature
.
make
(
id
,
dollar
,
parseTypeArguments
());
default
:
throw
error
(
"expected '<' or ';' or '.', got '"
+
c
+
"'."
);
}
}
/**
* ClassTypeSignatureSuffix:
* "." SimpleClassTypeSignature
*/
private
void
parseClassTypeSignatureSuffix
(
List
<
SimpleClassTypeSignature
>
scts
)
{
while
(
current
()
==
'/'
||
current
()
==
'.'
)
{
boolean
dollar
=
(
current
()
==
'.'
);
while
(
current
()
==
'.'
)
{
advance
();
scts
.
add
(
parseSimpleClassTypeSignature
(
dollar
));
scts
.
add
(
parseSimpleClassTypeSignature
(
true
));
}
}
...
...
@@ -294,10 +384,14 @@ public class SignatureParser {
else
{
return
new
TypeArgument
[
0
];}
}
/**
* TypeArguments:
* "<" TypeArgument+ ">"
*/
private
TypeArgument
[]
parseTypeArguments
()
{
Collection
<
TypeArgument
>
tas
=
new
ArrayList
<
TypeArgument
>(
3
);
List
<
TypeArgument
>
tas
=
new
ArrayList
<
>(
3
);
assert
(
current
()
==
'<'
);
if
(
current
()
!=
'<'
)
{
throw
error
(
"expected
<
"
);}
if
(
current
()
!=
'<'
)
{
throw
error
(
"expected
'<'
"
);}
advance
();
tas
.
add
(
parseTypeArgument
());
while
(
current
()
!=
'>'
)
{
...
...
@@ -305,10 +399,14 @@ public class SignatureParser {
tas
.
add
(
parseTypeArgument
());
}
advance
();
TypeArgument
[]
taa
=
new
TypeArgument
[
tas
.
size
()];
return
tas
.
toArray
(
taa
);
return
tas
.
toArray
(
new
TypeArgument
[
tas
.
size
()]);
}
/**
* TypeArgument:
* WildcardIndicator_opt FieldTypeSignature
* "*"
*/
private
TypeArgument
parseTypeArgument
()
{
FieldTypeSignature
[]
ub
,
lb
;
ub
=
new
FieldTypeSignature
[
1
];
...
...
@@ -334,18 +432,20 @@ public class SignatureParser {
ub
[
0
]
=
SimpleClassTypeSignature
.
make
(
"java.lang.Object"
,
false
,
ta
);
return
Wildcard
.
make
(
ub
,
lb
);
}
default
:
return
parseFieldTypeSignature
();
default
:
return
parseFieldTypeSignature
();
}
}
// TypeVariableSignature -> T identifier
private
TypeVariableSignature
parseTypeVariableSignature
(){
/**
* TypeVariableSignature:
* "T" Identifier ";"
*/
private
TypeVariableSignature
parseTypeVariableSignature
()
{
assert
(
current
()
==
'T'
);
if
(
current
()
!=
'T'
)
{
throw
error
(
"expected a type variable usage"
);}
advance
();
TypeVariableSignature
ts
=
TypeVariableSignature
.
make
(
parseIdentifier
());
TypeVariableSignature
ts
=
TypeVariableSignature
.
make
(
parseIdentifier
());
if
(
current
()
!=
';'
)
{
throw
error
(
"; expected in signature of type variable named"
+
ts
.
getIdentifier
());
...
...
@@ -354,16 +454,21 @@ public class SignatureParser {
return
ts
;
}
// ArrayTypeSignature -> [ TypeSignature
/**
* ArrayTypeSignature:
* "[" TypeSignature
*/
private
ArrayTypeSignature
parseArrayTypeSignature
()
{
if
(
current
()
!=
'['
)
{
throw
error
(
"expected array type signature"
);}
advance
();
return
ArrayTypeSignature
.
make
(
parseTypeSignature
());
}
// TypeSignature -> BaseType | FieldTypeSignature
/**
* TypeSignature:
* FieldTypeSignature
* BaseType
*/
private
TypeSignature
parseTypeSignature
()
{
switch
(
current
())
{
case
'B'
:
...
...
@@ -373,8 +478,11 @@ public class SignatureParser {
case
'I'
:
case
'J'
:
case
'S'
:
case
'Z'
:
return
parseBaseType
();
default
:
return
parseFieldTypeSignature
();
case
'Z'
:
return
parseBaseType
();
default
:
return
parseFieldTypeSignature
();
}
}
...
...
@@ -408,12 +516,18 @@ public class SignatureParser {
assert
(
false
);
throw
error
(
"expected primitive type"
);
}
}
}
}
private
FieldTypeSignature
[]
parseZeroOrMoreBounds
()
{
Collection
<
FieldTypeSignature
>
fts
=
new
ArrayList
<
FieldTypeSignature
>(
3
);
/**
* ClassBound:
* ":" FieldTypeSignature_opt
*
* InterfaceBound:
* ":" FieldTypeSignature
*/
private
FieldTypeSignature
[]
parseBounds
()
{
List
<
FieldTypeSignature
>
fts
=
new
ArrayList
<>(
3
);
if
(
current
()
==
':'
)
{
advance
();
...
...
@@ -430,24 +544,31 @@ public class SignatureParser {
advance
();
fts
.
add
(
parseFieldTypeSignature
());
}
}
}
else
error
(
"Bound expected"
);
FieldTypeSignature
[]
fta
=
new
FieldTypeSignature
[
fts
.
size
()];
return
fts
.
toArray
(
fta
);
return
fts
.
toArray
(
new
FieldTypeSignature
[
fts
.
size
()]);
}
/**
* SuperclassSignature:
* ClassTypeSignature
*/
private
ClassTypeSignature
[]
parseSuperInterfaces
()
{
Collection
<
ClassTypeSignature
>
cts
=
new
ArrayList
<
ClassTypeSignature
>(
5
);
List
<
ClassTypeSignature
>
cts
=
new
ArrayList
<>(
5
);
while
(
current
()
==
'L'
)
{
cts
.
add
(
parseClassTypeSignature
());
}
ClassTypeSignature
[]
cta
=
new
ClassTypeSignature
[
cts
.
size
()];
return
cts
.
toArray
(
cta
);
return
cts
.
toArray
(
new
ClassTypeSignature
[
cts
.
size
()]);
}
// parse a method signature based on the implicit input.
/**
* MethodTypeSignature:
* FormalTypeParameters_opt "(" TypeSignature* ")" ReturnType ThrowsSignature*
*/
private
MethodTypeSignature
parseMethodTypeSignature
()
{
// Parse a method signature based on the implicit input.
FieldTypeSignature
[]
ets
;
assert
(
index
==
0
);
...
...
@@ -457,19 +578,19 @@ public class SignatureParser {
parseZeroOrMoreThrowsSignatures
());
}
//
(TypeSignature*)
//
"(" TypeSignature* ")"
private
TypeSignature
[]
parseFormalParameters
()
{
if
(
current
()
!=
'('
)
{
throw
error
(
"expected
(
"
);}
if
(
current
()
!=
'('
)
{
throw
error
(
"expected
'('
"
);}
advance
();
TypeSignature
[]
pts
=
parseZeroOrMoreTypeSignatures
();
if
(
current
()
!=
')'
)
{
throw
error
(
"expected
)
"
);}
if
(
current
()
!=
')'
)
{
throw
error
(
"expected
')'
"
);}
advance
();
return
pts
;
}
// TypeSignature*
// TypeSignature*
private
TypeSignature
[]
parseZeroOrMoreTypeSignatures
()
{
Collection
<
TypeSignature
>
ts
=
new
ArrayList
<
TypeSignature
>();
List
<
TypeSignature
>
ts
=
new
ArrayList
<
>();
boolean
stop
=
false
;
while
(!
stop
)
{
switch
(
current
())
{
...
...
@@ -484,47 +605,46 @@ public class SignatureParser {
case
'L'
:
case
'T'
:
case
'['
:
{
ts
.
add
(
parseTypeSignature
());
break
;
}
ts
.
add
(
parseTypeSignature
());
break
;
}
default
:
stop
=
true
;
}
}
/* while( matches(current(),
'B', 'C', 'D', 'F', 'I', 'J', 'S', 'Z', 'L', 'T', '[')
) {
ts.add(parseTypeSignature());
}*/
TypeSignature
[]
ta
=
new
TypeSignature
[
ts
.
size
()];
return
ts
.
toArray
(
ta
);
return
ts
.
toArray
(
new
TypeSignature
[
ts
.
size
()]);
}
// ReturnType -> V | TypeSignature
/**
* ReturnType:
* TypeSignature
* VoidDescriptor
*/
private
ReturnType
parseReturnType
(){
if
(
current
()
==
'V'
)
{
if
(
current
()
==
'V'
)
{
advance
();
return
VoidDescriptor
.
make
();
}
else
return
parseTypeSignature
();
}
else
return
parseTypeSignature
();
}
// ThrowSignature*
private
FieldTypeSignature
[]
parseZeroOrMoreThrowsSignatures
(){
Collection
<
FieldTypeSignature
>
ets
=
new
ArrayList
<
FieldTypeSignature
>(
3
);
List
<
FieldTypeSignature
>
ets
=
new
ArrayList
<>(
3
);
while
(
current
()
==
'^'
)
{
ets
.
add
(
parseThrowsSignature
());
}
FieldTypeSignature
[]
eta
=
new
FieldTypeSignature
[
ets
.
size
()];
return
ets
.
toArray
(
eta
);
return
ets
.
toArray
(
new
FieldTypeSignature
[
ets
.
size
()]);
}
// ThrowSignature -> ^ FieldTypeSignature
/**
* ThrowsSignature:
* "^" ClassTypeSignature
* "^" TypeVariableSignature
*/
private
FieldTypeSignature
parseThrowsSignature
()
{
assert
(
current
()
==
'^'
);
if
(
current
()
!=
'^'
)
{
throw
error
(
"expected throws signature"
);}
advance
();
return
parseFieldTypeSignature
();
return
parseFieldTypeSignature
(
false
);
}
}
src/share/classes/sun/security/jgss/krb5/Krb5NameElement.java
浏览文件 @
2629adac
...
...
@@ -35,6 +35,7 @@ import java.io.UnsupportedEncodingException;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
java.security.Provider
;
import
java.util.Locale
;
/**
* Implements the GSSNameSpi for the krb5 mechanism.
...
...
@@ -184,7 +185,7 @@ public class Krb5NameElement
}
catch
(
UnknownHostException
e
)
{
// use hostname as it is
}
hostName
=
hostName
.
toLowerCase
();
hostName
=
hostName
.
toLowerCase
(
Locale
.
ENGLISH
);
temp
=
temp
.
append
(
'/'
).
append
(
hostName
);
return
temp
.
toString
();
...
...
src/share/classes/sun/security/krb5/PrincipalName.java
浏览文件 @
2629adac
...
...
@@ -35,6 +35,7 @@ import sun.security.krb5.internal.*;
import
sun.security.util.*
;
import
java.net.*
;
import
java.util.Vector
;
import
java.util.Locale
;
import
java.io.IOException
;
import
java.math.BigInteger
;
import
sun.security.krb5.internal.ccache.CCacheOutputStream
;
...
...
@@ -389,14 +390,14 @@ public class PrincipalName
// Looks if canonicalized is a longer format of hostName,
// we accept cases like
// bunny -> bunny.rabbit.hole
if
(
canonicalized
.
toLowerCase
(
)
.
startsWith
(
hostName
.
toLowerCase
(
)+
"."
))
{
if
(
canonicalized
.
toLowerCase
(
Locale
.
ENGLISH
).
startsWith
(
hostName
.
toLowerCase
(
Locale
.
ENGLISH
)+
"."
))
{
hostName
=
canonicalized
;
}
}
catch
(
UnknownHostException
e
)
{
// no canonicalization, use old
}
nameParts
[
1
]
=
hostName
.
toLowerCase
();
nameParts
[
1
]
=
hostName
.
toLowerCase
(
Locale
.
ENGLISH
);
}
nameStrings
=
nameParts
;
nameType
=
type
;
...
...
src/share/classes/sun/security/pkcs11/Session.java
浏览文件 @
2629adac
/*
* Copyright (c) 2003, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 201
1
, 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
...
...
@@ -87,7 +87,7 @@ final class Session implements Comparable<Session> {
}
long
id
()
{
if
(
token
.
isPresent
(
this
)
==
false
)
{
if
(
token
.
isPresent
(
this
.
id
)
==
false
)
{
throw
new
ProviderException
(
"Token has been removed"
);
}
lastAccess
=
System
.
currentTimeMillis
();
...
...
@@ -167,7 +167,9 @@ final class SessionRef extends PhantomReference<Session>
void
dispose
()
{
refList
.
remove
(
this
);
try
{
token
.
p11
.
C_CloseSession
(
id
);
if
(
token
.
isPresent
(
id
))
{
token
.
p11
.
C_CloseSession
(
id
);
}
}
catch
(
PKCS11Exception
e1
)
{
// ignore
}
catch
(
ProviderException
e2
)
{
...
...
src/share/classes/sun/security/pkcs11/Token.java
浏览文件 @
2629adac
/*
* Copyright (c) 2003, 20
06
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 20
11
, 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
...
...
@@ -217,7 +217,7 @@ class Token implements Serializable {
// return whether a token is present (i.e. token not removed)
// returns cached value if current, otherwise performs new check
boolean
isPresent
(
Session
session
)
{
boolean
isPresent
(
long
sessionID
)
{
if
(
removable
==
false
)
{
return
true
;
}
...
...
@@ -238,7 +238,7 @@ class Token implements Serializable {
// the token should return an error
CK_SESSION_INFO
sessInfo
=
provider
.
p11
.
C_GetSessionInfo
(
session
.
idInternal
()
);
(
session
ID
);
ok
=
true
;
}
}
catch
(
PKCS11Exception
e
)
{
...
...
src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java
浏览文件 @
2629adac
...
...
@@ -219,7 +219,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
public
Key
engineGetKey
(
String
alias
,
char
[]
password
)
throws
NoSuchAlgorithmException
,
UnrecoverableKeyException
{
KeyEntry
entry
=
entries
.
get
(
alias
.
toLowerCase
());
KeyEntry
entry
=
entries
.
get
(
alias
.
toLowerCase
(
Locale
.
ENGLISH
));
Key
key
=
null
;
if
(
entry
==
null
)
{
...
...
@@ -296,7 +296,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
* <i>key entry</i> without a certificate chain).
*/
public
Certificate
[]
engineGetCertificateChain
(
String
alias
)
{
KeyEntry
entry
=
entries
.
get
(
alias
.
toLowerCase
());
KeyEntry
entry
=
entries
.
get
(
alias
.
toLowerCase
(
Locale
.
ENGLISH
));
if
(
entry
!=
null
)
{
if
(
entry
.
chain
==
null
)
{
return
null
;
...
...
@@ -324,7 +324,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
* does not contain a certificate.
*/
public
Certificate
engineGetCertificate
(
String
alias
)
{
KeyEntry
entry
=
entries
.
get
(
alias
.
toLowerCase
());
KeyEntry
entry
=
entries
.
get
(
alias
.
toLowerCase
(
Locale
.
ENGLISH
));
if
(
entry
!=
null
)
{
if
(
entry
.
chain
==
null
)
{
return
null
;
...
...
@@ -345,7 +345,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
* not exist
*/
public
Date
engineGetCreationDate
(
String
alias
)
{
KeyEntry
entry
=
entries
.
get
(
alias
.
toLowerCase
());
KeyEntry
entry
=
entries
.
get
(
alias
.
toLowerCase
(
Locale
.
ENGLISH
));
if
(
entry
!=
null
)
{
return
new
Date
(
entry
.
date
.
getTime
());
}
else
{
...
...
@@ -409,10 +409,10 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
// set the keyId to current date
entry
.
keyId
=
(
"Time "
+
(
entry
.
date
).
getTime
()).
getBytes
(
"UTF8"
);
// set the alias
entry
.
alias
=
alias
.
toLowerCase
();
entry
.
alias
=
alias
.
toLowerCase
(
Locale
.
ENGLISH
);
// add the entry
entries
.
put
(
alias
.
toLowerCase
(),
entry
);
entries
.
put
(
alias
.
toLowerCase
(
Locale
.
ENGLISH
),
entry
);
}
catch
(
Exception
nsae
)
{
throw
new
KeyStoreException
(
"Key protection "
+
" algorithm not found: "
+
nsae
,
nsae
);
...
...
@@ -465,7 +465,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
// Won't happen
}
// set the alias
entry
.
alias
=
alias
.
toLowerCase
();
entry
.
alias
=
alias
.
toLowerCase
(
Locale
.
ENGLISH
);
entry
.
protectedPrivKey
=
key
.
clone
();
if
(
chain
!=
null
)
{
...
...
@@ -473,7 +473,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
}
// add the entry
entries
.
put
(
alias
.
toLowerCase
(),
entry
);
entries
.
put
(
alias
.
toLowerCase
(
Locale
.
ENGLISH
),
entry
);
}
...
...
@@ -618,7 +618,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
public
synchronized
void
engineSetCertificateEntry
(
String
alias
,
Certificate
cert
)
throws
KeyStoreException
{
KeyEntry
entry
=
entries
.
get
(
alias
.
toLowerCase
());
KeyEntry
entry
=
entries
.
get
(
alias
.
toLowerCase
(
Locale
.
ENGLISH
));
if
(
entry
!=
null
)
{
throw
new
KeyStoreException
(
"Cannot overwrite own certificate"
);
}
else
...
...
@@ -635,7 +635,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
public
synchronized
void
engineDeleteEntry
(
String
alias
)
throws
KeyStoreException
{
entries
.
remove
(
alias
.
toLowerCase
());
entries
.
remove
(
alias
.
toLowerCase
(
Locale
.
ENGLISH
));
}
/**
...
...
@@ -655,7 +655,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
* @return true if the alias exists, false otherwise
*/
public
boolean
engineContainsAlias
(
String
alias
)
{
return
entries
.
containsKey
(
alias
.
toLowerCase
());
return
entries
.
containsKey
(
alias
.
toLowerCase
(
Locale
.
ENGLISH
));
}
/**
...
...
@@ -675,7 +675,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
* <i>key entry</i>, false otherwise.
*/
public
boolean
engineIsKeyEntry
(
String
alias
)
{
KeyEntry
entry
=
entries
.
get
(
alias
.
toLowerCase
());
KeyEntry
entry
=
entries
.
get
(
alias
.
toLowerCase
(
Locale
.
ENGLISH
));
if
(
entry
!=
null
)
{
return
true
;
}
else
{
...
...
@@ -1274,7 +1274,8 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
if
(
password
!=
null
&&
s
.
available
()
>
0
)
{
MacData
macData
=
new
MacData
(
s
);
try
{
String
algName
=
macData
.
getDigestAlgName
().
toUpperCase
();
String
algName
=
macData
.
getDigestAlgName
().
toUpperCase
(
Locale
.
ENGLISH
);
if
(
algName
.
equals
(
"SHA"
)
||
algName
.
equals
(
"SHA1"
)
||
algName
.
equals
(
"SHA-1"
))
{
...
...
@@ -1479,7 +1480,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
if
(
alias
==
null
)
alias
=
getUnfriendlyName
();
entry
.
alias
=
alias
;
entries
.
put
(
alias
.
toLowerCase
(),
entry
);
entries
.
put
(
alias
.
toLowerCase
(
Locale
.
ENGLISH
),
entry
);
}
else
if
(
bagItem
instanceof
X509Certificate
)
{
X509Certificate
cert
=
(
X509Certificate
)
bagItem
;
// Insert a localKeyID for the corresponding cert
...
...
src/share/classes/sun/security/provider/JavaKeyStore.java
浏览文件 @
2629adac
...
...
@@ -54,7 +54,7 @@ abstract class JavaKeyStore extends KeyStoreSpi {
// regular JKS
public
static
final
class
JKS
extends
JavaKeyStore
{
String
convertAlias
(
String
alias
)
{
return
alias
.
toLowerCase
();
return
alias
.
toLowerCase
(
Locale
.
ENGLISH
);
}
}
...
...
src/share/classes/sun/security/provider/certpath/X509CertPath.java
浏览文件 @
2629adac
...
...
@@ -105,7 +105,13 @@ public class X509CertPath extends CertPath {
super
(
"X.509"
);
// Ensure that the List contains only X509Certificates
for
(
Certificate
obj
:
certs
)
{
//
// Note; The certs parameter is not necessarily to be of Certificate
// for some old code. For compatibility, to make sure the exception
// is CertificateException, rather than ClassCastException, please
// don't use
// for (Certificate obj : certs)
for
(
Object
obj
:
certs
)
{
if
(
obj
instanceof
X509Certificate
==
false
)
{
throw
new
CertificateException
(
"List is not all X509Certificates: "
...
...
src/share/classes/sun/security/provider/certpath/ldap/LDAPCertStore.java
浏览文件 @
2629adac
...
...
@@ -879,7 +879,8 @@ public class LDAPCertStore extends CertStoreSpi {
if
(
hashCode
==
0
)
{
int
result
=
17
;
result
=
37
*
result
+
getPort
();
result
=
37
*
result
+
getServerName
().
toLowerCase
().
hashCode
();
result
=
37
*
result
+
getServerName
().
toLowerCase
(
Locale
.
ENGLISH
).
hashCode
();
hashCode
=
result
;
}
return
hashCode
;
...
...
src/share/classes/sun/security/ssl/SSLSessionContextImpl.java
浏览文件 @
2629adac
...
...
@@ -33,6 +33,7 @@ import java.util.Enumeration;
import
java.util.Hashtable
;
import
java.util.NoSuchElementException
;
import
java.util.Vector
;
import
java.util.Locale
;
import
javax.net.ssl.SSLSession
;
import
javax.net.ssl.SSLSessionContext
;
...
...
@@ -166,7 +167,8 @@ final class SSLSessionContextImpl implements SSLSessionContext {
}
private
String
getKey
(
String
hostname
,
int
port
)
{
return
(
hostname
+
":"
+
String
.
valueOf
(
port
)).
toLowerCase
();
return
(
hostname
+
":"
+
String
.
valueOf
(
port
)).
toLowerCase
(
Locale
.
ENGLISH
);
}
// cache a SSLSession
...
...
src/share/classes/sun/security/tools/KeyStoreUtil.java
浏览文件 @
2629adac
...
...
@@ -25,6 +25,8 @@
package
sun.security.tools
;
import
java.util.Locale
;
/**
* <p> This class provides several utilities to <code>KeyStore</code>.
*
...
...
@@ -63,7 +65,7 @@ public class KeyStoreUtil {
}
else
if
(
storetype
.
equalsIgnoreCase
(
"Windows-ROOT"
))
{
return
"Windows-ROOT"
;
}
else
{
return
storetype
.
toUpperCase
();
return
storetype
.
toUpperCase
(
Locale
.
ENGLISH
);
}
}
}
src/share/classes/sun/security/util/HostnameChecker.java
浏览文件 @
2629adac
...
...
@@ -266,8 +266,8 @@ public class HostnameChecker {
*/
private
static
boolean
matchAllWildcards
(
String
name
,
String
template
)
{
name
=
name
.
toLowerCase
();
template
=
template
.
toLowerCase
();
name
=
name
.
toLowerCase
(
Locale
.
ENGLISH
);
template
=
template
.
toLowerCase
(
Locale
.
ENGLISH
);
StringTokenizer
nameSt
=
new
StringTokenizer
(
name
,
"."
);
StringTokenizer
templateSt
=
new
StringTokenizer
(
template
,
"."
);
...
...
@@ -296,8 +296,8 @@ public class HostnameChecker {
*/
private
static
boolean
matchLeftmostWildcard
(
String
name
,
String
template
)
{
name
=
name
.
toLowerCase
();
template
=
template
.
toLowerCase
();
name
=
name
.
toLowerCase
(
Locale
.
ENGLISH
);
template
=
template
.
toLowerCase
(
Locale
.
ENGLISH
);
// Retreive leftmost component
int
templateIdx
=
template
.
indexOf
(
"."
);
...
...
src/share/classes/sun/security/x509/DNSName.java
浏览文件 @
2629adac
...
...
@@ -159,7 +159,7 @@ public class DNSName implements GeneralNameInterface {
* @return a hash code value for this object.
*/
public
int
hashCode
()
{
return
name
.
toUpperCase
().
hashCode
();
return
name
.
toUpperCase
(
Locale
.
ENGLISH
).
hashCode
();
}
/**
...
...
src/share/classes/sun/security/x509/RFC822Name.java
浏览文件 @
2629adac
...
...
@@ -153,7 +153,7 @@ public class RFC822Name implements GeneralNameInterface
* @return a hash code value for this object.
*/
public
int
hashCode
()
{
return
name
.
toUpperCase
().
hashCode
();
return
name
.
toUpperCase
(
Locale
.
ENGLISH
).
hashCode
();
}
/**
...
...
src/share/classes/sun/security/x509/X500Name.java
浏览文件 @
2629adac
...
...
@@ -1401,8 +1401,7 @@ public class X500Name implements GeneralNameInterface, Principal {
principalConstructor
=
constr
;
principalField
=
(
Field
)
result
[
1
];
}
catch
(
Exception
e
)
{
throw
(
InternalError
)
new
InternalError
(
"Could not obtain "
+
"X500Principal access"
).
initCause
(
e
);
throw
new
InternalError
(
"Could not obtain X500Principal access"
,
e
);
}
}
...
...
src/share/classes/sun/tools/jconsole/ProxyClient.java
浏览文件 @
2629adac
...
...
@@ -208,7 +208,7 @@ public class ProxyClient implements JConsoleContext {
serverStubClass
=
Class
.
forName
(
rmiServerImplStubClassName
).
asSubclass
(
Remote
.
class
);
}
catch
(
ClassNotFoundException
e
)
{
// should never reach here
throw
(
InternalError
)
new
InternalError
(
e
.
getMessage
()).
initCause
(
e
);
throw
new
InternalError
(
e
.
getMessage
(),
e
);
}
rmiServerImplStubClass
=
serverStubClass
;
}
...
...
@@ -395,18 +395,10 @@ public class ProxyClient implements JConsoleContext {
}
catch
(
MalformedObjectNameException
e
)
{
// should not reach here
throw
new
InternalError
(
e
.
getMessage
());
}
catch
(
IntrospectionException
e
)
{
InternalError
ie
=
new
InternalError
(
e
.
getMessage
());
ie
.
initCause
(
e
);
throw
ie
;
}
catch
(
InstanceNotFoundException
e
)
{
InternalError
ie
=
new
InternalError
(
e
.
getMessage
());
ie
.
initCause
(
e
);
throw
ie
;
}
catch
(
ReflectionException
e
)
{
InternalError
ie
=
new
InternalError
(
e
.
getMessage
());
ie
.
initCause
(
e
);
throw
ie
;
}
catch
(
IntrospectionException
|
InstanceNotFoundException
|
ReflectionException
e
)
{
throw
new
InternalError
(
e
.
getMessage
(),
e
);
}
if
(
hasPlatformMXBeans
)
{
...
...
src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystem.java
浏览文件 @
2629adac
...
...
@@ -31,6 +31,7 @@
package
com.sun.nio.zipfs
;
import
java.io.BufferedOutputStream
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.EOFException
;
...
...
@@ -1165,7 +1166,6 @@ public class ZipFileSystem extends FileSystem {
// sync the zip file system, if there is any udpate
private
void
sync
()
throws
IOException
{
//System.out.printf("->sync(%s) starting....!%n", toString());
// check ex-closer
if
(!
exChClosers
.
isEmpty
())
{
for
(
ExChannelCloser
ecc
:
exChClosers
)
{
...
...
@@ -1179,84 +1179,84 @@ public class ZipFileSystem extends FileSystem {
if
(!
hasUpdate
)
return
;
Path
tmpFile
=
createTempFileInSameDirectoryAs
(
zfpath
);
OutputStream
os
=
Files
.
newOutputStream
(
tmpFile
,
WRITE
);
ArrayList
<
Entry
>
elist
=
new
ArrayList
<>(
inodes
.
size
());
long
written
=
0
;
byte
[]
buf
=
new
byte
[
8192
];
Entry
e
=
null
;
// write loc
for
(
IndexNode
inode
:
inodes
.
values
())
{
if
(
inode
instanceof
Entry
)
{
// an updated inode
e
=
(
Entry
)
inode
;
try
{
if
(
e
.
type
==
Entry
.
COPY
)
{
// entry copy: the only thing changed is the "name"
// and "nlen" in LOC header, so we udpate/rewrite the
// LOC in new file and simply copy the rest (data and
// ext) without enflating/deflating from the old zip
// file LOC entry.
written
+=
copyLOCEntry
(
e
,
true
,
os
,
written
,
buf
);
}
else
{
// NEW, FILECH or CEN
e
.
locoff
=
written
;
written
+=
e
.
writeLOC
(
os
);
// write loc header
if
(
e
.
bytes
!=
null
)
{
// in-memory, deflated
os
.
write
(
e
.
bytes
);
// already
written
+=
e
.
bytes
.
length
;
}
else
if
(
e
.
file
!=
null
)
{
// tmp file
try
(
InputStream
is
=
Files
.
newInputStream
(
e
.
file
))
{
int
n
;
if
(
e
.
type
==
Entry
.
NEW
)
{
// deflated already
while
((
n
=
is
.
read
(
buf
))
!=
-
1
)
{
os
.
write
(
buf
,
0
,
n
);
written
+=
n
;
}
}
else
if
(
e
.
type
==
Entry
.
FILECH
)
{
// the data are not deflated, use ZEOS
try
(
OutputStream
os2
=
new
EntryOutputStream
(
e
,
os
))
{
try
(
OutputStream
os
=
new
BufferedOutputStream
(
Files
.
newOutputStream
(
tmpFile
,
WRITE
)))
{
ArrayList
<
Entry
>
elist
=
new
ArrayList
<>(
inodes
.
size
());
long
written
=
0
;
byte
[]
buf
=
new
byte
[
8192
];
Entry
e
=
null
;
// write loc
for
(
IndexNode
inode
:
inodes
.
values
())
{
if
(
inode
instanceof
Entry
)
{
// an updated inode
e
=
(
Entry
)
inode
;
try
{
if
(
e
.
type
==
Entry
.
COPY
)
{
// entry copy: the only thing changed is the "name"
// and "nlen" in LOC header, so we udpate/rewrite the
// LOC in new file and simply copy the rest (data and
// ext) without enflating/deflating from the old zip
// file LOC entry.
written
+=
copyLOCEntry
(
e
,
true
,
os
,
written
,
buf
);
}
else
{
// NEW, FILECH or CEN
e
.
locoff
=
written
;
written
+=
e
.
writeLOC
(
os
);
// write loc header
if
(
e
.
bytes
!=
null
)
{
// in-memory, deflated
os
.
write
(
e
.
bytes
);
// already
written
+=
e
.
bytes
.
length
;
}
else
if
(
e
.
file
!=
null
)
{
// tmp file
try
(
InputStream
is
=
Files
.
newInputStream
(
e
.
file
))
{
int
n
;
if
(
e
.
type
==
Entry
.
NEW
)
{
// deflated already
while
((
n
=
is
.
read
(
buf
))
!=
-
1
)
{
os2
.
write
(
buf
,
0
,
n
);
os
.
write
(
buf
,
0
,
n
);
written
+=
n
;
}
}
else
if
(
e
.
type
==
Entry
.
FILECH
)
{
// the data are not deflated, use ZEOS
try
(
OutputStream
os2
=
new
EntryOutputStream
(
e
,
os
))
{
while
((
n
=
is
.
read
(
buf
))
!=
-
1
)
{
os2
.
write
(
buf
,
0
,
n
);
}
}
written
+=
e
.
csize
;
if
((
e
.
flag
&
FLAG_DATADESCR
)
!=
0
)
written
+=
e
.
writeEXT
(
os
);
}
written
+=
e
.
csize
;
if
((
e
.
flag
&
FLAG_DATADESCR
)
!=
0
)
written
+=
e
.
writeEXT
(
os
);
}
Files
.
delete
(
e
.
file
);
tmppaths
.
remove
(
e
.
file
);
}
else
{
// dir, 0-length data
}
Files
.
delete
(
e
.
file
);
tmppaths
.
remove
(
e
.
file
);
}
else
{
// dir, 0-length data
}
elist
.
add
(
e
);
}
catch
(
IOException
x
)
{
x
.
printStackTrace
();
// skip any in-accurate entry
}
}
else
{
// unchanged inode
if
(
inode
.
pos
==
-
1
)
{
continue
;
// pseudo directory node
}
e
=
Entry
.
readCEN
(
this
,
inode
.
pos
);
try
{
written
+=
copyLOCEntry
(
e
,
false
,
os
,
written
,
buf
);
elist
.
add
(
e
);
}
catch
(
IOException
x
)
{
x
.
printStackTrace
();
// skip any wrong entry
}
elist
.
add
(
e
);
}
catch
(
IOException
x
)
{
x
.
printStackTrace
();
// skip any in-accurate entry
}
}
else
{
// unchanged inode
if
(
inode
.
pos
==
-
1
)
{
continue
;
// pseudo directory node
}
e
=
Entry
.
readCEN
(
this
,
inode
.
pos
);
try
{
written
+=
copyLOCEntry
(
e
,
false
,
os
,
written
,
buf
);
elist
.
add
(
e
);
}
catch
(
IOException
x
)
{
x
.
printStackTrace
();
// skip any wrong entry
}
}
}
// now write back the cen and end table
end
.
cenoff
=
written
;
for
(
Entry
entry
:
elist
)
{
written
+=
entry
.
writeCEN
(
os
);
// now write back the cen and end table
end
.
cenoff
=
written
;
for
(
Entry
entry
:
elist
)
{
written
+=
entry
.
writeCEN
(
os
);
}
end
.
centot
=
elist
.
size
();
end
.
cenlen
=
written
-
end
.
cenoff
;
end
.
write
(
os
,
written
);
}
end
.
centot
=
elist
.
size
();
end
.
cenlen
=
written
-
end
.
cenoff
;
end
.
write
(
os
,
written
);
os
.
close
();
if
(!
streams
.
isEmpty
())
{
//
// TBD: ExChannelCloser should not be necessary if we only
...
...
@@ -1959,7 +1959,7 @@ public class ZipFileSystem extends FileSystem {
writeBytes
(
os
,
name
);
if
(
elen64
!=
0
)
{
writeShort
(
os
,
EXTID_ZIP64
);
// Zip64 extra
writeShort
(
os
,
elen64
);
// size of "this" extra block
writeShort
(
os
,
elen64
-
4
);
// size of "this" extra block
if
(
size0
==
ZIP64_MINVAL
)
writeLong
(
os
,
size
);
if
(
csize0
==
ZIP64_MINVAL
)
...
...
src/solaris/classes/sun/nio/ch/InheritedChannel.java
浏览文件 @
2629adac
...
...
@@ -166,8 +166,8 @@ class InheritedChannel {
// is implemented.
Class
paramTypes
[]
=
{
int
.
class
};
Constructor
ctr
=
Reflect
.
lookupConstructor
(
"java.io.FileDescriptor"
,
paramTypes
);
Constructor
<?>
ctr
=
Reflect
.
lookupConstructor
(
"java.io.FileDescriptor"
,
paramTypes
);
Object
args
[]
=
{
new
Integer
(
fdVal
)
};
FileDescriptor
fd
=
(
FileDescriptor
)
Reflect
.
invoke
(
ctr
,
args
);
...
...
src/solaris/classes/sun/nio/fs/LinuxWatchService.java
浏览文件 @
2629adac
...
...
@@ -58,7 +58,10 @@ class LinuxWatchService
try
{
ifd
=
inotifyInit
();
}
catch
(
UnixException
x
)
{
throw
new
IOException
(
x
.
errorString
());
String
msg
=
(
x
.
errno
()
==
EMFILE
)
?
"User limit of inotify instances reached or too many open files"
:
x
.
errorString
();
throw
new
IOException
(
msg
);
}
// configure inotify to be non-blocking
...
...
src/solaris/lib/content-types.properties
浏览文件 @
2629adac
...
...
@@ -225,6 +225,10 @@ image/png: \
icon=png;
\
action=browser
image/
bmp
:
\
description=Bitmap Image;
\
file_extensions=.bmp;
text/
html
:
\
description=HTML Document;
\
file_extensions=.htm,.html;
\
...
...
src/solaris/native/sun/nio/fs/genUnixConstants.c
浏览文件 @
2629adac
...
...
@@ -108,6 +108,7 @@ int main(int argc, const char* argv[]) {
DEF
(
EROFS
);
DEF
(
ENODATA
);
DEF
(
ERANGE
);
DEF
(
EMFILE
);
// flags used with openat/unlinkat/etc.
#if defined(AT_SYMLINK_NOFOLLOW) && defined(AT_REMOVEDIR)
...
...
src/windows/classes/sun/nio/ch/WindowsAsynchronousFileChannelImpl.java
浏览文件 @
2629adac
...
...
@@ -55,9 +55,7 @@ public class WindowsAsynchronousFileChannelImpl
try
{
return
new
Iocp
(
null
,
ThreadPool
.
createDefault
()).
start
();
}
catch
(
IOException
ioe
)
{
InternalError
e
=
new
InternalError
();
e
.
initCause
(
ioe
);
throw
e
;
throw
new
InternalError
(
ioe
);
}
}
}
...
...
src/windows/lib/content-types.properties
浏览文件 @
2629adac
...
...
@@ -222,6 +222,10 @@ image/png: \
icon=png;
\
action=browser
image/
bmp
:
\
description=Bitmap Image;
\
file_extensions=.bmp;
text/
html
:
\
description=HTML Document;
\
file_extensions=.htm,.html;
\
...
...
test/ProblemList.txt
浏览文件 @
2629adac
...
...
@@ -198,10 +198,16 @@ java/beans/XMLEncoder/6329581/Test6329581.java generic-all
# requires junit
java/lang/invoke/InvokeDynamicPrintArgs.java generic-all
# 7079093
java/lang/instrument/ManifestTest.sh windows-all
############################################################################
# jdk_management
# 6944188
java/lang/management/ThreadMXBean/ThreadStateTest.java generic-all
# 7067973
java/lang/management/MemoryMXBean/CollectionUsageThreshold.java generic-all
...
...
@@ -368,6 +374,12 @@ com/sun/net/httpserver/Test9a.java generic-all
# 7079145 java/net/ipv6tests/UdpTest.java hang at IPv6 only data exchange
java/net/ipv6tests/UdpTest.java linux-all
# 7079012
java/net/NetworkInterface/NetParamsTest.java solaris-all
# 7081476
java/net/InetSocketAddress/B6469803.java generic-all
############################################################################
# jdk_io
...
...
@@ -375,6 +387,12 @@ java/net/ipv6tests/UdpTest.java linux-all
# 6962637
java/io/File/MaxPathLength.java windows-all
# 6671616
java/io/File/BlockIsDirectory.java solaris-all
# 7076644
java/io/File/Basic.java windows-all
############################################################################
# jdk_nio
...
...
@@ -382,6 +400,9 @@ java/io/File/MaxPathLength.java windows-all
# 6963118
java/nio/channels/Selector/Wakeup.java windows-all
# 7076700
java/nio/channels/SocketChannel/AdaptSocket.java generic-all
############################################################################
# jdk_rmi
...
...
@@ -499,6 +520,12 @@ sun/security/ssl/sanity/interop/ClientJSSEServerJSSE.java generic-all
# 7079203 sun/security/tools/keytool/printssl.sh fails on solaris with timeout
sun/security/tools/keytool/printssl.sh solaris-all
# 7054637
sun/security/tools/jarsigner/ec.sh solaris-all
# 7081817
sun/security/provider/certpath/X509CertPath/IllegalCertiticates.java generic-all
############################################################################
# jdk_swing (not using samevm)
...
...
test/com/sun/security/sasl/ntlm/Conformance.java
0 → 100644
浏览文件 @
2629adac
/*
* Copyright (c) 2011, 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 7043847 7043860 7043882 7043938 7043959
* @summary NTML impl of SaslServer conformance errors
*/
import
java.io.IOException
;
import
javax.security.sasl.*
;
import
java.util.*
;
import
javax.security.auth.callback.Callback
;
import
javax.security.auth.callback.CallbackHandler
;
import
javax.security.auth.callback.UnsupportedCallbackException
;
public
class
Conformance
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
try
{
Sasl
.
createSaslClient
(
new
String
[]
{
"NTLM"
},
"abc"
,
"ldap"
,
"server"
,
new
HashMap
<
String
,
Object
>(),
null
);
}
catch
(
SaslException
se
)
{
System
.
out
.
println
(
se
);
}
try
{
Sasl
.
createSaslServer
(
"NTLM"
,
"ldap"
,
"server"
,
new
HashMap
<
String
,
Object
>(),
null
);
}
catch
(
SaslException
se
)
{
System
.
out
.
println
(
se
);
}
try
{
Sasl
.
createSaslClient
(
new
String
[]
{
"NTLM"
},
"abc"
,
"ldap"
,
"server"
,
null
,
new
CallbackHandler
()
{
@Override
public
void
handle
(
Callback
[]
callbacks
)
throws
IOException
,
UnsupportedCallbackException
{
}
});
}
catch
(
SaslException
se
)
{
System
.
out
.
println
(
se
);
}
try
{
SaslServer
saslServer
=
Sasl
.
createSaslServer
(
"NTLM"
,
"ldap"
,
"abc"
,
null
,
new
CallbackHandler
()
{
@Override
public
void
handle
(
Callback
[]
callbacks
)
throws
IOException
,
UnsupportedCallbackException
{
}
});
System
.
err
.
println
(
"saslServer = "
+
saslServer
);
System
.
err
.
println
(
"saslServer.isComplete() = "
+
saslServer
.
isComplete
());
// IllegalStateException is expected here
saslServer
.
getNegotiatedProperty
(
"prop"
);
System
.
err
.
println
(
"No IllegalStateException"
);
}
catch
(
IllegalStateException
se
)
{
System
.
out
.
println
(
se
);
}
try
{
SaslServer
saslServer
=
Sasl
.
createSaslServer
(
"NTLM"
,
"ldap"
,
"abc"
,
null
,
new
CallbackHandler
()
{
@Override
public
void
handle
(
Callback
[]
callbacks
)
throws
IOException
,
UnsupportedCallbackException
{
}
});
System
.
err
.
println
(
"saslServer = "
+
saslServer
);
System
.
err
.
println
(
"saslServer.isComplete() = "
+
saslServer
.
isComplete
());
// IllegalStateException is expected here
saslServer
.
getAuthorizationID
();
System
.
err
.
println
(
"No IllegalStateException"
);
}
catch
(
IllegalStateException
se
)
{
System
.
out
.
println
(
se
);
}
try
{
SaslServer
saslServer
=
Sasl
.
createSaslServer
(
"NTLM"
,
"ldap"
,
"abc"
,
null
,
new
CallbackHandler
()
{
@Override
public
void
handle
(
Callback
[]
callbacks
)
throws
IOException
,
UnsupportedCallbackException
{
}
});
System
.
err
.
println
(
"saslServer = "
+
saslServer
);
System
.
err
.
println
(
"saslServer.isComplete() = "
+
saslServer
.
isComplete
());
// IllegalStateException is expected here
saslServer
.
wrap
(
new
byte
[
0
],
0
,
0
);
System
.
err
.
println
(
"No IllegalStateException"
);
}
catch
(
IllegalStateException
se
)
{
System
.
out
.
println
(
se
);
}
}
}
test/java/io/IOException/LastErrorString.java
浏览文件 @
2629adac
...
...
@@ -23,6 +23,7 @@
/* @test
@bug 4167937
@ignore Test truncates system files when run as root, see 7042603
@summary Test code paths that use the JVM_LastErrorString procedure
*/
...
...
test/java/io/etc/FailingFlushAndClose.java
0 → 100644
浏览文件 @
2629adac
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import
java.io.*
;
/**
* @test
* @bug 7015589
* @summary Test that buffering streams are considered closed even when the
* close or flush from the underlying stream fails.
*/
public
class
FailingFlushAndClose
{
static
int
failed
;
static
void
fail
(
String
msg
)
{
System
.
err
.
println
(
"FAIL: "
+
msg
);
failed
++;
}
static
void
failWithIOE
(
String
msg
)
throws
IOException
{
fail
(
msg
);
throw
new
IOException
(
msg
);
}
static
class
FailingCloseInputStream
extends
InputStream
{
boolean
closed
;
@Override
public
int
read
()
throws
IOException
{
if
(
closed
)
failWithIOE
(
"input stream is closed"
);
return
1
;
}
@Override
public
void
close
()
throws
IOException
{
if
(!
closed
)
{
closed
=
true
;
throw
new
IOException
(
"close failed"
);
}
}
}
static
class
FailingCloseOutputStream
extends
OutputStream
{
boolean
closed
;
@Override
public
void
write
(
int
b
)
throws
IOException
{
if
(
closed
)
failWithIOE
(
"output stream is closed"
);
}
@Override
public
void
flush
()
throws
IOException
{
if
(
closed
)
failWithIOE
(
"output stream is closed"
);
}
@Override
public
void
close
()
throws
IOException
{
if
(!
closed
)
{
closed
=
true
;
throw
new
IOException
(
"close failed"
);
}
}
}
static
class
FailingFlushOutputStream
extends
OutputStream
{
boolean
closed
;
@Override
public
void
write
(
int
b
)
throws
IOException
{
if
(
closed
)
failWithIOE
(
"output stream is closed"
);
}
@Override
public
void
flush
()
throws
IOException
{
if
(
closed
)
{
failWithIOE
(
"output stream is closed"
);
}
else
{
throw
new
IOException
(
"flush failed"
);
}
}
@Override
public
void
close
()
throws
IOException
{
closed
=
true
;
}
}
static
class
FailingCloseReader
extends
Reader
{
boolean
closed
;
@Override
public
int
read
(
char
[]
cbuf
,
int
off
,
int
len
)
throws
IOException
{
if
(
closed
)
failWithIOE
(
"reader is closed"
);
return
1
;
}
@Override
public
void
close
()
throws
IOException
{
if
(!
closed
)
{
closed
=
true
;
throw
new
IOException
(
"close failed"
);
}
}
}
static
class
FailingCloseWriter
extends
Writer
{
boolean
closed
;
@Override
public
void
write
(
char
[]
cbuf
,
int
off
,
int
len
)
throws
IOException
{
if
(
closed
)
failWithIOE
(
"writer is closed"
);
}
@Override
public
void
flush
()
throws
IOException
{
if
(
closed
)
failWithIOE
(
"writer is closed"
);
}
@Override
public
void
close
()
throws
IOException
{
if
(!
closed
)
{
closed
=
true
;
throw
new
IOException
(
"close failed"
);
}
}
}
static
class
FailingFlushWriter
extends
Writer
{
boolean
closed
;
@Override
public
void
write
(
char
[]
cbuf
,
int
off
,
int
len
)
throws
IOException
{
if
(
closed
)
failWithIOE
(
"writer is closed"
);
}
@Override
public
void
flush
()
throws
IOException
{
if
(
closed
)
{
failWithIOE
(
"writer is closed"
);
}
else
{
throw
new
IOException
(
"flush failed"
);
}
}
@Override
public
void
close
()
throws
IOException
{
if
(!
closed
)
{
closed
=
true
;
throw
new
IOException
(
"close failed"
);
}
}
}
static
void
testFailingClose
(
InputStream
in
)
throws
IOException
{
System
.
out
.
println
(
in
.
getClass
());
in
.
read
(
new
byte
[
100
]);
try
{
in
.
close
();
fail
(
"close did not fail"
);
}
catch
(
IOException
expected
)
{
}
try
{
in
.
read
(
new
byte
[
100
]);
fail
(
"read did not fail"
);
}
catch
(
IOException
expected
)
{
}
}
static
void
testFailingClose
(
OutputStream
out
)
throws
IOException
{
System
.
out
.
println
(
out
.
getClass
());
out
.
write
(
1
);
try
{
out
.
close
();
fail
(
"close did not fail"
);
}
catch
(
IOException
expected
)
{
}
try
{
out
.
write
(
1
);
if
(!(
out
instanceof
BufferedOutputStream
))
fail
(
"write did not fail"
);
}
catch
(
IOException
expected
)
{
}
}
static
void
testFailingFlush
(
OutputStream
out
)
throws
IOException
{
System
.
out
.
println
(
out
.
getClass
());
out
.
write
(
1
);
try
{
out
.
flush
();
fail
(
"flush did not fail"
);
}
catch
(
IOException
expected
)
{
}
if
(
out
instanceof
BufferedOutputStream
)
{
out
.
write
(
1
);
try
{
out
.
close
();
fail
(
"close did not fail"
);
}
catch
(
IOException
expected
)
{
}
}
}
static
void
testFailingClose
(
Reader
r
)
throws
IOException
{
System
.
out
.
println
(
r
.
getClass
());
r
.
read
(
new
char
[
100
]);
try
{
r
.
close
();
fail
(
"close did not fail"
);
}
catch
(
IOException
expected
)
{
}
try
{
r
.
read
(
new
char
[
100
]);
fail
(
"read did not fail"
);
}
catch
(
IOException
expected
)
{
}
}
static
void
testFailingClose
(
Writer
w
)
throws
IOException
{
System
.
out
.
println
(
w
.
getClass
());
w
.
write
(
"message"
);
try
{
w
.
close
();
fail
(
"close did not fail"
);
}
catch
(
IOException
expected
)
{
}
try
{
w
.
write
(
"another message"
);
fail
(
"write did not fail"
);
}
catch
(
IOException
expected
)
{
}
}
static
void
testFailingFlush
(
Writer
w
)
throws
IOException
{
System
.
out
.
println
(
w
.
getClass
());
w
.
write
(
"message"
);
try
{
w
.
flush
();
fail
(
"flush did not fail"
);
}
catch
(
IOException
expected
)
{
}
if
(
w
instanceof
BufferedWriter
)
{
// assume this message will be buffered
w
.
write
(
"another message"
);
try
{
w
.
close
();
fail
(
"close did not fail"
);
}
catch
(
IOException
expected
)
{
}
}
}
public
static
void
main
(
String
[]
args
)
throws
IOException
{
testFailingClose
(
new
BufferedInputStream
(
new
FailingCloseInputStream
()));
testFailingClose
(
new
BufferedOutputStream
(
new
FailingCloseOutputStream
()));
testFailingClose
(
new
BufferedReader
(
new
FailingCloseReader
()));
testFailingClose
(
new
BufferedWriter
(
new
FailingCloseWriter
()));
testFailingFlush
(
new
BufferedOutputStream
(
new
FailingFlushOutputStream
()));
testFailingFlush
(
new
BufferedWriter
(
new
FailingFlushWriter
()));
if
(
failed
>
0
)
throw
new
RuntimeException
(
failed
+
" test(s) failed - see log for details"
);
}
}
test/java/lang/ProcessBuilder/Basic.java
浏览文件 @
2629adac
...
...
@@ -1803,7 +1803,7 @@ public class Basic {
p
.
getInputStream
().
close
();
p
.
getErrorStream
().
close
();
p
.
getOutputStream
().
close
();
try
{
p
.
getOutputStream
().
close
();
}
catch
(
IOException
flushFailed
)
{
}
InputStream
[]
streams
=
{
p
.
getInputStream
(),
p
.
getErrorStream
()
};
for
(
final
InputStream
in
:
streams
)
{
...
...
test/java/lang/management/ManagementFactory/GetObjectName.java
0 → 100644
浏览文件 @
2629adac
/*
* Copyright (c) 2011, 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 7068328
* @summary Test if getObjectName handles properly when called by
* multiple threads simultaneously. Run in othervm mode to
* make sure the object name is not initialized to begin with.
* @run main/othervm GetObjectName
*/
import
java.lang.management.BufferPoolMXBean
;
import
java.lang.management.ManagementFactory
;
import
java.lang.management.PlatformLoggingMXBean
;
import
java.lang.management.PlatformManagedObject
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.TimeUnit
;
public
class
GetObjectName
{
private
static
boolean
failed
=
false
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
int
tasks
=
10000
;
ExecutorService
executor
=
Executors
.
newFixedThreadPool
(
10
);
submitTasks
(
executor
,
tasks
);
executor
.
shutdown
();
executor
.
awaitTermination
(
10
,
TimeUnit
.
SECONDS
);
if
(!
failed
)
{
System
.
out
.
println
(
"Test passed."
);
}
}
static
void
submitTasks
(
ExecutorService
executor
,
int
count
)
{
for
(
int
i
=
0
;
i
<
count
&&
!
failed
;
i
++)
{
executor
.
execute
(
new
Runnable
()
{
@Override
public
void
run
()
{
List
<
PlatformManagedObject
>
mbeans
=
new
ArrayList
<>();
mbeans
.
add
(
ManagementFactory
.
getPlatformMXBean
(
PlatformLoggingMXBean
.
class
));
mbeans
.
addAll
(
ManagementFactory
.
getPlatformMXBeans
(
BufferPoolMXBean
.
class
));
for
(
PlatformManagedObject
pmo
:
mbeans
)
{
// Name should not be null
if
(
pmo
.
getObjectName
()
==
null
)
{
failed
=
true
;
throw
new
RuntimeException
(
"TEST FAILED: getObjectName() returns null"
);
}
}
}
});
}
}
}
test/java/lang/reflect/Generics/Probe.java
浏览文件 @
2629adac
/*
* Copyright (c) 2004, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 201
1
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -23,7 +23,7 @@
/*
* @test
* @bug 5003916 6704655 6873951
* @bug 5003916 6704655 6873951
6476261
* @summary Testing parsing of signatures attributes of nested classes
* @author Joseph D. Darcy
*/
...
...
@@ -38,12 +38,12 @@ import static java.util.Arrays.*;
"java.util.concurrent.ConcurrentHashMap$KeyIterator"
,
"java.util.concurrent.ConcurrentHashMap$ValueIterator"
,
"java.util.AbstractList$ListItr"
,
//
"java.util.EnumMap$EntryIterator",
//
"java.util.EnumMap$KeyIterator",
//
"java.util.EnumMap$ValueIterator",
//
"java.util.IdentityHashMap$EntryIterator",
//
"java.util.IdentityHashMap$KeyIterator",
//
"java.util.IdentityHashMap$ValueIterator",
"java.util.EnumMap$EntryIterator"
,
"java.util.EnumMap$KeyIterator"
,
"java.util.EnumMap$ValueIterator"
,
"java.util.IdentityHashMap$EntryIterator"
,
"java.util.IdentityHashMap$KeyIterator"
,
"java.util.IdentityHashMap$ValueIterator"
,
"java.util.WeakHashMap$EntryIterator"
,
"java.util.WeakHashMap$KeyIterator"
,
"java.util.WeakHashMap$ValueIterator"
,
...
...
@@ -52,12 +52,12 @@ import static java.util.Arrays.*;
"java.util.HashMap$ValueIterator"
,
"java.util.LinkedHashMap$EntryIterator"
,
"java.util.LinkedHashMap$KeyIterator"
,
"java.util.LinkedHashMap$ValueIterator"
})
"java.util.LinkedHashMap$ValueIterator"
,
"javax.swing.JComboBox$AccessibleJComboBox"
})
public
class
Probe
{
public
static
void
main
(
String
...
args
)
throws
Throwable
{
Classes
classesAnnotation
=
(
Probe
.
class
).
getAnnotation
(
Classes
.
class
);
List
<
String
>
names
=
new
ArrayList
<
String
>(
asList
(
classesAnnotation
.
value
()));
List
<
String
>
names
=
new
ArrayList
<>(
asList
(
classesAnnotation
.
value
()));
int
errs
=
0
;
for
(
String
name:
names
)
{
...
...
test/java/lang/reflect/Generics/SignatureTest.java
0 → 100644
浏览文件 @
2629adac
/*
* Copyright (c) 2006, 2011, 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 6476261
* @summary More testing of parsing of signatures attributes of nested classes
*/
import
java.lang.reflect.*
;
public
class
SignatureTest
<
T
>
{
class
Inner1
{
class
Inner11
{
}
}
public
void
f
(
SignatureTest
<
String
>.
Inner1
.
Inner11
x
)
{}
public
void
g
(
SignatureTest
<
String
>.
Inner1
x
)
{}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Class
clazz
=
SignatureTest
.
class
;
for
(
Method
m
:
clazz
.
getDeclaredMethods
())
{
System
.
out
.
println
();
System
.
out
.
println
(
m
.
toString
());
System
.
out
.
println
(
m
.
toGenericString
());
System
.
out
.
println
(
m
.
getGenericParameterTypes
());
}
}
}
test/java/lang/reflect/Generics/TestBadSignatures.java
0 → 100644
浏览文件 @
2629adac
/*
* Copyright (c) 2011, 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 6832374 7052898
* @summary Test bad signatures get a GenericSignatureFormatError thrown.
* @author Joseph D. Darcy
*/
import
java.lang.reflect.*
;
import
sun.reflect.generics.parser.SignatureParser
;
public
class
TestBadSignatures
{
public
static
void
main
(
String
[]
args
)
{
String
[]
badSignatures
=
{
// Missing ":" after first type bound
"<T:Lfoo/tools/nsc/symtab/Names;Lfoo/tools/nsc/symtab/Symbols;"
,
// Arrays improperly indicated for exception information
"<E:Ljava/lang/Exception;>(TE;[Ljava/lang/RuntimeException;)V^[TE;"
,
};
for
(
String
badSig
:
badSignatures
)
{
try
{
SignatureParser
.
make
().
parseMethodSig
(
badSig
);
throw
new
RuntimeException
(
"Expected GenericSignatureFormatError for "
+
badSig
);
}
catch
(
GenericSignatureFormatError
gsfe
)
{
System
.
out
.
println
(
gsfe
.
toString
());
// Expected
}
}
}
}
test/java/net/CookieHandler/TestHttpCookie.java
浏览文件 @
2629adac
...
...
@@ -362,12 +362,13 @@ public class TestHttpCookie {
eq
(
c1
,
c2
,
false
);
header
(
"Test domainMatches()"
);
dm
(
".foo.com"
,
"y.x.foo.com"
,
false
);
dm
(
".foo.com"
,
"x.foo.com"
,
true
);
dm
(
".com"
,
"whatever.com"
,
false
);
dm
(
".com."
,
"whatever.com"
,
false
);
dm
(
".ajax.com"
,
"ajax.com"
,
true
);
dm
(
".local"
,
"example.local"
,
true
);
dm
(
".foo.com"
,
"y.x.foo.com"
,
false
);
dm
(
".foo.com"
,
"x.foo.com"
,
true
);
dm
(
".com"
,
"whatever.com"
,
false
);
dm
(
".com."
,
"whatever.com"
,
false
);
dm
(
".ajax.com"
,
"ajax.com"
,
true
);
dm
(
".local"
,
"example.local"
,
true
);
dm
(
"example.local"
,
"example"
,
true
);
// bug 6277808
testCount
++;
...
...
test/java/nio/channels/DatagramChannel/NetworkConfiguration.java
浏览文件 @
2629adac
...
...
@@ -57,11 +57,22 @@ class NetworkConfiguration {
return
ip6Interfaces
.
get
(
nif
);
}
// IPv6 not supported for Windows XP/Server 2003
static
boolean
isIPv6Supported
()
{
if
(
System
.
getProperty
(
"os.name"
).
startsWith
(
"Windows"
))
{
String
ver
=
System
.
getProperty
(
"os.version"
);
int
major
=
Integer
.
parseInt
(
ver
.
split
(
"\\."
)[
0
]);
return
(
major
>=
6
);
}
return
true
;
}
static
NetworkConfiguration
probe
()
throws
IOException
{
Map
<
NetworkInterface
,
List
<
InetAddress
>>
ip4Interfaces
=
new
HashMap
<
NetworkInterface
,
List
<
InetAddress
>>();
Map
<
NetworkInterface
,
List
<
InetAddress
>>
ip6Interfaces
=
new
HashMap
<
NetworkInterface
,
List
<
InetAddress
>>();
boolean
isIPv6Supported
=
isIPv6Supported
();
// find the interfaces that support IPv4 and IPv6
List
<
NetworkInterface
>
nifs
=
Collections
...
...
@@ -81,7 +92,7 @@ class NetworkConfiguration {
}
list
.
add
(
addr
);
ip4Interfaces
.
put
(
nif
,
list
);
}
else
if
(
addr
instanceof
Inet6Address
)
{
}
else
if
(
isIPv6Supported
&&
(
addr
instanceof
Inet6Address
)
)
{
List
<
InetAddress
>
list
=
ip6Interfaces
.
get
(
nif
);
if
(
list
==
null
)
{
list
=
new
LinkedList
<
InetAddress
>();
...
...
test/java/nio/channels/DatagramChannel/SelectWhenRefused.java
浏览文件 @
2629adac
...
...
@@ -22,7 +22,7 @@
*/
/* @test
* @bug 6935563
* @bug 6935563
7044870
* @summary Test that Selector does not select an unconnected DatagramChannel when
* ICMP port unreachable received
*/
...
...
@@ -35,14 +35,15 @@ import java.io.IOException;
public
class
SelectWhenRefused
{
public
static
void
main
(
String
[]
args
)
throws
IOException
{
DatagramChannel
dc
=
DatagramChannel
.
open
().
bind
(
new
InetSocketAddress
(
0
));
int
port
=
dc
.
socket
().
getLocalPort
();
dc
.
close
();
DatagramChannel
dc1
=
DatagramChannel
.
open
().
bind
(
new
InetSocketAddress
(
0
));
int
port
=
dc1
.
socket
().
getLocalPort
();
// datagram sent to this address should be refused
SocketAddress
refuser
=
new
InetSocketAddress
(
InetAddress
.
getLocalHost
(),
port
);
dc
=
DatagramChannel
.
open
().
bind
(
new
InetSocketAddress
(
0
));
DatagramChannel
dc
=
DatagramChannel
.
open
().
bind
(
new
InetSocketAddress
(
0
));
dc1
.
close
();
Selector
sel
=
Selector
.
open
();
try
{
dc
.
configureBlocking
(
false
);
...
...
@@ -52,6 +53,10 @@ public class SelectWhenRefused {
sendDatagram
(
dc
,
refuser
);
int
n
=
sel
.
select
(
2000
);
if
(
n
>
0
)
{
sel
.
selectedKeys
().
clear
();
// BindException will be thrown if another service is using
// our expected refuser port, cannot run just exit.
DatagramChannel
.
open
().
bind
(
refuser
).
close
();
throw
new
RuntimeException
(
"Unexpected wakeup"
);
}
...
...
@@ -80,6 +85,8 @@ public class SelectWhenRefused {
throw
new
RuntimeException
(
"Unexpected wakeup after disconnect"
);
}
}
catch
(
BindException
e
)
{
// Do nothing, some other test has used this port
}
finally
{
sel
.
close
();
dc
.
close
();
...
...
test/java/util/zip/LargeZip.java
浏览文件 @
2629adac
...
...
@@ -25,173 +25,242 @@
import
java.io.*
;
import
java.nio.*
;
import
java.nio.file.*
;
import
java.nio.file.attribute.*
;
import
java.nio.file.spi.*
;
import
java.util.*
;
import
java.util.zip.*
;
import
static
java
.
nio
.
file
.
StandardCopyOption
.*;
public
class
LargeZip
{
// If true, don't delete large ZIP file created for test.
static
final
boolean
debug
=
System
.
getProperty
(
"debug"
)
!=
null
;
//static final int DATA_LEN = 1024 * 1024;
static
final
int
DATA_LEN
=
80
*
1024
;
static
final
int
DATA_SIZE
=
8
;
static
long
fileSize
=
6L
*
1024L
*
1024L
*
1024L
;
// 6GB
static
boolean
userFile
=
false
;
static
byte
[]
data
;
static
File
largeFile
;
static
String
lastEntryName
;
/* args can be empty, in which case check a 3 GB file which is created for
* this test (and then deleted). Or it can be a number, in which case
* that designates the size of the file that's created for this test (and
* then deleted). Or it can be the name of a file to use for the test, in
* which case it is *not* deleted. Note that in this last case, the data
* comparison might fail.
*/
static
void
realMain
(
String
[]
args
)
throws
Throwable
{
if
(
args
.
length
>
0
)
{
try
{
fileSize
=
Long
.
parseLong
(
args
[
0
]);
System
.
out
.
println
(
"Testing with file of size "
+
fileSize
);
}
catch
(
NumberFormatException
ex
)
{
largeFile
=
new
File
(
args
[
0
]);
if
(!
largeFile
.
exists
())
{
throw
new
Exception
(
"Specified file "
+
args
[
0
]
+
" does not exist"
);
}
userFile
=
true
;
System
.
out
.
println
(
"Testing with user-provided file "
+
largeFile
);
}
}
File
testDir
=
null
;
if
(
largeFile
==
null
)
{
testDir
=
new
File
(
System
.
getProperty
(
"test.scratch"
,
"."
),
"LargeZip"
);
if
(
testDir
.
exists
())
{
if
(!
testDir
.
delete
())
{
throw
new
Exception
(
"Cannot delete already-existing test directory"
);
}
}
check
(!
testDir
.
exists
()
&&
testDir
.
mkdirs
());
largeFile
=
new
File
(
testDir
,
"largezip.zip"
);
createLargeZip
();
}
readLargeZip1
();
readLargeZip2
();
if
(!
userFile
&&
!
debug
)
{
check
(
largeFile
.
delete
());
check
(
testDir
.
delete
());
}
}
static
void
createLargeZip
()
throws
Throwable
{
int
iterations
=
DATA_LEN
/
DATA_SIZE
;
ByteBuffer
bb
=
ByteBuffer
.
allocate
(
DATA_SIZE
);
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
for
(
int
i
=
0
;
i
<
iterations
;
i
++)
{
bb
.
putDouble
(
0
,
Math
.
random
());
baos
.
write
(
bb
.
array
(),
0
,
DATA_SIZE
);
}
data
=
baos
.
toByteArray
();
try
(
FileOutputStream
fos
=
new
FileOutputStream
(
largeFile
);
BufferedOutputStream
bos
=
new
BufferedOutputStream
(
fos
);
ZipOutputStream
zos
=
new
ZipOutputStream
(
bos
))
{
long
length
=
0
;
while
(
length
<
fileSize
)
{
ZipEntry
ze
=
new
ZipEntry
(
"entry-"
+
length
);
lastEntryName
=
ze
.
getName
();
zos
.
putNextEntry
(
ze
);
zos
.
write
(
data
,
0
,
data
.
length
);
zos
.
closeEntry
();
length
=
largeFile
.
length
();
}
System
.
out
.
println
(
"Last entry written is "
+
lastEntryName
);
}
}
static
void
readLargeZip1
()
throws
Throwable
{
ZipFile
zipFile
=
new
ZipFile
(
largeFile
);
ZipEntry
entry
=
null
;
String
entryName
=
null
;
int
count
=
0
;
Enumeration
<?
extends
ZipEntry
>
entries
=
zipFile
.
entries
();
while
(
entries
.
hasMoreElements
())
{
entry
=
entries
.
nextElement
();
entryName
=
entry
.
getName
();
count
++;
}
System
.
out
.
println
(
"Number of entries read: "
+
count
);
System
.
out
.
println
(
"Last entry read is "
+
entryName
);
check
(!
entry
.
isDirectory
());
if
(
check
(
entryName
.
equals
(
lastEntryName
)))
{
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
InputStream
is
=
zipFile
.
getInputStream
(
entry
);
byte
buf
[]
=
new
byte
[
4096
];
int
len
;
while
((
len
=
is
.
read
(
buf
))
>=
0
)
{
baos
.
write
(
buf
,
0
,
len
);
}
baos
.
close
();
is
.
close
();
check
(
Arrays
.
equals
(
data
,
baos
.
toByteArray
()));
}
}
static
void
readLargeZip2
()
throws
Throwable
{
try
(
FileInputStream
fis
=
new
FileInputStream
(
largeFile
);
BufferedInputStream
bis
=
new
BufferedInputStream
(
fis
);
ZipInputStream
zis
=
new
ZipInputStream
(
bis
))
{
ZipEntry
entry
=
null
;
String
entryName
=
null
;
int
count
=
0
;
while
((
entry
=
zis
.
getNextEntry
())
!=
null
)
{
entryName
=
entry
.
getName
();
if
(
entryName
.
equals
(
lastEntryName
))
{
break
;
}
count
++;
}
System
.
out
.
println
(
"Number of entries read: "
+
count
);
System
.
out
.
println
(
"Last entry read is "
+
entryName
);
check
(!
entry
.
isDirectory
());
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
byte
buf
[]
=
new
byte
[
4096
];
int
len
;
while
((
len
=
zis
.
read
(
buf
))
>=
0
)
{
baos
.
write
(
buf
,
0
,
len
);
}
baos
.
close
();
check
(
Arrays
.
equals
(
data
,
baos
.
toByteArray
()));
check
(
zis
.
getNextEntry
()
==
null
);
}
}
//--------------------- Infrastructure ---------------------------
static
volatile
int
passed
=
0
,
failed
=
0
;
static
void
pass
()
{
passed
++;}
static
void
pass
(
String
msg
)
{
System
.
out
.
println
(
msg
);
passed
++;}
static
void
fail
()
{
failed
++;
Thread
.
dumpStack
();}
static
void
fail
(
String
msg
)
{
System
.
out
.
println
(
msg
);
fail
();}
static
void
unexpected
(
Throwable
t
)
{
failed
++;
t
.
printStackTrace
();}
static
void
unexpected
(
Throwable
t
,
String
msg
)
{
System
.
out
.
println
(
msg
);
failed
++;
t
.
printStackTrace
();}
static
boolean
check
(
boolean
cond
)
{
if
(
cond
)
pass
();
else
fail
();
return
cond
;}
static
void
equal
(
Object
x
,
Object
y
)
{
if
(
x
==
null
?
y
==
null
:
x
.
equals
(
y
))
pass
();
else
fail
(
x
+
" not equal to "
+
y
);}
public
static
void
main
(
String
[]
args
)
throws
Throwable
{
try
{
realMain
(
args
);}
catch
(
Throwable
t
)
{
unexpected
(
t
);}
System
.
out
.
println
(
"\nPassed = "
+
passed
+
" failed = "
+
failed
);
if
(
failed
>
0
)
throw
new
AssertionError
(
"Some tests failed"
);}
// If true, don't delete large ZIP file created for test.
static
final
boolean
debug
=
System
.
getProperty
(
"debug"
)
!=
null
;
//static final int DATA_LEN = 1024 * 1024;
static
final
int
DATA_LEN
=
80
*
1024
;
static
final
int
DATA_SIZE
=
8
;
static
long
fileSize
=
6L
*
1024L
*
1024L
*
1024L
;
// 6GB
static
boolean
userFile
=
false
;
static
byte
[]
data
;
static
File
largeFile
;
static
String
lastEntryName
;
/* args can be empty, in which case check a 3 GB file which is created for
* this test (and then deleted). Or it can be a number, in which case
* that designates the size of the file that's created for this test (and
* then deleted). Or it can be the name of a file to use for the test, in
* which case it is *not* deleted. Note that in this last case, the data
* comparison might fail.
*/
static
void
realMain
(
String
[]
args
)
throws
Throwable
{
if
(
args
.
length
>
0
)
{
try
{
fileSize
=
Long
.
parseLong
(
args
[
0
]);
System
.
out
.
println
(
"Testing with file of size "
+
fileSize
);
}
catch
(
NumberFormatException
ex
)
{
largeFile
=
new
File
(
args
[
0
]);
if
(!
largeFile
.
exists
())
{
throw
new
Exception
(
"Specified file "
+
args
[
0
]
+
" does not exist"
);
}
userFile
=
true
;
System
.
out
.
println
(
"Testing with user-provided file "
+
largeFile
);
}
}
File
testDir
=
null
;
if
(
largeFile
==
null
)
{
testDir
=
new
File
(
System
.
getProperty
(
"test.scratch"
,
"."
),
"LargeZip"
);
if
(
testDir
.
exists
())
{
if
(!
testDir
.
delete
())
{
throw
new
Exception
(
"Cannot delete already-existing test directory"
);
}
}
check
(!
testDir
.
exists
()
&&
testDir
.
mkdirs
());
largeFile
=
new
File
(
testDir
,
"largezip.zip"
);
createLargeZip
();
}
else
{
if
(
args
.
length
>
1
)
updateLargeZip
(
args
[
1
]);
// add new entry with zfs
}
readLargeZip1
();
readLargeZip2
();
if
(!
userFile
&&
!
debug
)
{
check
(
largeFile
.
delete
());
check
(
testDir
.
delete
());
}
}
static
void
createLargeZip
()
throws
Throwable
{
int
iterations
=
DATA_LEN
/
DATA_SIZE
;
ByteBuffer
bb
=
ByteBuffer
.
allocate
(
DATA_SIZE
);
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
for
(
int
i
=
0
;
i
<
iterations
;
i
++)
{
bb
.
putDouble
(
0
,
Math
.
random
());
baos
.
write
(
bb
.
array
(),
0
,
DATA_SIZE
);
}
data
=
baos
.
toByteArray
();
try
(
FileOutputStream
fos
=
new
FileOutputStream
(
largeFile
);
BufferedOutputStream
bos
=
new
BufferedOutputStream
(
fos
);
ZipOutputStream
zos
=
new
ZipOutputStream
(
bos
))
{
long
length
=
0
;
while
(
length
<
fileSize
)
{
ZipEntry
ze
=
new
ZipEntry
(
"entry-"
+
length
);
lastEntryName
=
ze
.
getName
();
zos
.
putNextEntry
(
ze
);
zos
.
write
(
data
,
0
,
data
.
length
);
zos
.
closeEntry
();
length
=
largeFile
.
length
();
}
System
.
out
.
println
(
"Last entry written is "
+
lastEntryName
);
}
}
private
static
byte
buf
[]
=
new
byte
[
4096
];
static
void
checkEntry
(
ZipEntry
e
,
InputStream
is
)
throws
Throwable
{
long
N
=
0
;
int
n
=
0
;
while
((
n
=
is
.
read
(
buf
))
>=
0
)
{
N
+=
n
;
}
check
(
N
==
e
.
getSize
());
}
static
void
readLargeZip1
()
throws
Throwable
{
ZipFile
zipFile
=
new
ZipFile
(
largeFile
);
ZipEntry
entry
=
null
;
String
entryName
=
null
;
int
count
=
0
;
System
.
out
.
println
(
"ZipFile:"
);
Enumeration
<?
extends
ZipEntry
>
entries
=
zipFile
.
entries
();
while
(
entries
.
hasMoreElements
())
{
entry
=
entries
.
nextElement
();
entryName
=
entry
.
getName
();
System
.
out
.
println
(
" checking "
+
entryName
);
if
(!
entry
.
isDirectory
())
{
try
(
InputStream
zeis
=
zipFile
.
getInputStream
(
entry
))
{
checkEntry
(
entry
,
zeis
);
}
}
count
++;
}
System
.
out
.
println
(
"Number of entries read: "
+
count
);
check
(!
entry
.
isDirectory
());
if
(
userFile
||
check
(
entryName
.
equals
(
lastEntryName
)))
{
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
InputStream
is
=
zipFile
.
getInputStream
(
entry
);
int
len
;
while
((
len
=
is
.
read
(
buf
))
>=
0
)
{
baos
.
write
(
buf
,
0
,
len
);
}
baos
.
close
();
is
.
close
();
if
(!
userFile
)
check
(
Arrays
.
equals
(
data
,
baos
.
toByteArray
()));
}
}
static
void
readLargeZip2
()
throws
Throwable
{
System
.
out
.
println
(
"ZipInputStream:"
);
try
(
FileInputStream
fis
=
new
FileInputStream
(
largeFile
);
BufferedInputStream
bis
=
new
BufferedInputStream
(
fis
);
ZipInputStream
zis
=
new
ZipInputStream
(
bis
))
{
ZipEntry
entry
=
null
;
String
entryName
=
null
;
int
count
=
0
;
while
((
entry
=
zis
.
getNextEntry
())
!=
null
)
{
entryName
=
entry
.
getName
();
System
.
out
.
println
(
" checking "
+
entryName
+
", method="
+
entry
.
getMethod
());
if
(
entryName
.
equals
(
lastEntryName
))
{
break
;
}
if
(!
entry
.
isDirectory
())
{
checkEntry
(
entry
,
zis
);
}
count
++;
}
System
.
out
.
println
(
"Number of entries read: "
+
count
);
System
.
out
.
println
(
"Last entry read is "
+
entryName
);
if
(!
userFile
)
{
check
(!
entry
.
isDirectory
());
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
byte
buf
[]
=
new
byte
[
4096
];
int
len
;
while
((
len
=
zis
.
read
(
buf
))
>=
0
)
{
baos
.
write
(
buf
,
0
,
len
);
}
baos
.
close
();
check
(
Arrays
.
equals
(
data
,
baos
.
toByteArray
()));
check
(
zis
.
getNextEntry
()
==
null
);
}
}
}
private
static
void
updateFile
(
FileSystem
fs
,
Path
src
)
throws
IOException
{
Path
dst
=
fs
.
getPath
(
src
.
toString
());
Path
parent
=
dst
.
getParent
();
if
(
parent
!=
null
&&
Files
.
notExists
(
parent
))
Files
.
createDirectories
(
parent
);
Files
.
copy
(
src
,
dst
,
REPLACE_EXISTING
);
}
private
static
FileSystemProvider
getZipFSProvider
()
{
for
(
FileSystemProvider
provider
:
FileSystemProvider
.
installedProviders
())
{
if
(
"jar"
.
equalsIgnoreCase
(
provider
.
getScheme
()))
return
provider
;
}
return
null
;
}
static
void
updateLargeZip
(
String
pName
)
throws
Throwable
{
FileSystemProvider
provider
=
getZipFSProvider
();
if
(
provider
==
null
)
{
System
.
err
.
println
(
"ZIP filesystem provider is not installed"
);
System
.
exit
(
1
);
}
Map
<
String
,
Object
>
env
=
env
=
new
HashMap
<>();
try
(
FileSystem
fs
=
provider
.
newFileSystem
(
largeFile
.
toPath
(),
env
))
{
Path
path
=
FileSystems
.
getDefault
().
getPath
(
pName
);
Files
.
walkFileTree
(
path
,
new
SimpleFileVisitor
<
Path
>()
{
@Override
public
FileVisitResult
visitFile
(
Path
file
,
BasicFileAttributes
attrs
)
throws
IOException
{
updateFile
(
fs
,
file
);
return
FileVisitResult
.
CONTINUE
;
}
});
}
}
//--------------------- Infrastructure ---------------------------
static
volatile
int
passed
=
0
,
failed
=
0
;
static
void
pass
()
{
passed
++;}
static
void
pass
(
String
msg
)
{
System
.
out
.
println
(
msg
);
passed
++;}
static
void
fail
()
{
failed
++;
Thread
.
dumpStack
();}
static
void
fail
(
String
msg
)
{
System
.
out
.
println
(
msg
);
fail
();}
static
void
unexpected
(
Throwable
t
)
{
failed
++;
t
.
printStackTrace
();}
static
void
unexpected
(
Throwable
t
,
String
msg
)
{
System
.
out
.
println
(
msg
);
failed
++;
t
.
printStackTrace
();}
static
boolean
check
(
boolean
cond
)
{
if
(
cond
)
pass
();
else
fail
();
return
cond
;}
static
void
equal
(
Object
x
,
Object
y
)
{
if
(
x
==
null
?
y
==
null
:
x
.
equals
(
y
))
pass
();
else
fail
(
x
+
" not equal to "
+
y
);}
public
static
void
main
(
String
[]
args
)
throws
Throwable
{
try
{
realMain
(
args
);}
catch
(
Throwable
t
)
{
unexpected
(
t
);}
System
.
out
.
println
(
"\nPassed = "
+
passed
+
" failed = "
+
failed
);
if
(
failed
>
0
)
throw
new
AssertionError
(
"Some tests failed"
);}
}
test/javax/naming/ldap/LdapName/CompareToEqualsTests.java
浏览文件 @
2629adac
/*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003,
2011,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -23,12 +23,14 @@
/*
* @test
* @bug 4635618
* @bug 4635618
7059542
* @summary Support for manipulating LDAP Names
* JNDI name operations should be locale independent
*/
import
javax.naming.ldap.*
;
import
java.util.ArrayList
;
import
java.util.Locale
;
import
java.util.List
;
import
javax.naming.InvalidNameException
;
...
...
@@ -39,52 +41,61 @@ public class CompareToEqualsTests {
public
static
void
main
(
String
args
[])
throws
Exception
{
/**
* Test cases:
* 1) Same RDNs.
* 2) same RDN sequence with an AVA ordered differently.
* 3) RDN sequences of a differing AVA.
* 4) RDN sequence of different length.
* 5) RDN sequence of different Case.
* 6) Matching binary return values.
* 7) Binary values that don't match.
*/
String
names1
[]
=
new
String
[]
{
Locale
reservedLocale
=
Locale
.
getDefault
();
try
{
/**
* Test cases:
* 1) Same RDNs.
* 2) same RDN sequence with an AVA ordered differently.
* 3) RDN sequences of a differing AVA.
* 4) RDN sequence of different length.
* 5) RDN sequence of different Case.
* 6) Matching binary return values.
* 7) Binary values that don't match.
*/
String
names1
[]
=
new
String
[]
{
"ou=Sales+cn=Bob"
,
"ou=Sales+cn=Bob"
,
"ou=Sales+cn=Bob"
,
"ou=Sales+cn=Scott+c=US"
,
"cn=config"
};
String
names2
[]
=
new
String
[]
{
String
names2
[]
=
new
String
[]
{
"ou=Sales+cn=Bob"
,
"cn=Bob+ou=Sales"
,
"ou=Sales+cn=Scott"
,
"ou=Sales+cn=Scott"
,
"Cn=COnFIG"
};
int
expectedResults
[]
=
{
0
,
0
,
-
1
,
-
1
,
0
};
int
expectedResults
[]
=
{
0
,
0
,
-
1
,
-
1
,
0
};
for
(
Locale
locale
:
Locale
.
getAvailableLocales
())
{
// reset the default locale
Locale
.
setDefault
(
locale
);
for
(
int
i
=
0
;
i
<
names1
.
length
;
i
++)
{
checkResults
(
new
LdapName
(
names1
[
i
]),
for
(
int
i
=
0
;
i
<
names1
.
length
;
i
++)
{
checkResults
(
new
LdapName
(
names1
[
i
]),
new
LdapName
(
names2
[
i
]),
expectedResults
[
i
]);
}
byte
[]
value
=
"abcxyz"
.
getBytes
();
Rdn
rdn1
=
new
Rdn
(
"binary"
,
value
);
ArrayList
rdns1
=
new
ArrayList
();
rdns1
.
add
(
rdn1
);
LdapName
l1
=
new
LdapName
(
rdns1
);
Rdn
rdn2
=
new
Rdn
(
"binary"
,
value
);
ArrayList
rdns2
=
new
ArrayList
();
rdns2
.
add
(
rdn2
);
LdapName
l2
=
new
LdapName
(
rdns2
);
checkResults
(
l1
,
l2
,
0
);
l2
=
new
LdapName
(
"binary=#61626378797A"
);
checkResults
(
l1
,
l2
,
0
);
l2
=
new
LdapName
(
"binary=#61626378797B"
);
checkResults
(
l1
,
l2
,
-
1
);
System
.
out
.
println
(
"Tests passed"
);
}
}
finally
{
// restore the reserved locale
Locale
.
setDefault
(
reservedLocale
);
}
byte
[]
value
=
"abcxyz"
.
getBytes
();
Rdn
rdn1
=
new
Rdn
(
"binary"
,
value
);
ArrayList
rdns1
=
new
ArrayList
();
rdns1
.
add
(
rdn1
);
LdapName
l1
=
new
LdapName
(
rdns1
);
Rdn
rdn2
=
new
Rdn
(
"binary"
,
value
);
ArrayList
rdns2
=
new
ArrayList
();
rdns2
.
add
(
rdn2
);
LdapName
l2
=
new
LdapName
(
rdns2
);
checkResults
(
l1
,
l2
,
0
);
l2
=
new
LdapName
(
"binary=#61626378797A"
);
checkResults
(
l1
,
l2
,
0
);
l2
=
new
LdapName
(
"binary=#61626378797B"
);
checkResults
(
l1
,
l2
,
-
1
);
System
.
out
.
println
(
"Tests passed"
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录