Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
0f545a87
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
0f545a87
编写于
8月 18, 2009
作者:
T
tbell
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
d1363d73
6d31bb0e
变更
24
隐藏空白更改
内联
并排
Showing
24 changed file
with
772 addition
and
44 deletion
+772
-44
src/share/classes/com/sun/security/auth/callback/TextCallbackHandler.java
...s/com/sun/security/auth/callback/TextCallbackHandler.java
+1
-1
src/share/classes/com/sun/security/sasl/Provider.java
src/share/classes/com/sun/security/sasl/Provider.java
+1
-1
src/share/classes/java/lang/String.java
src/share/classes/java/lang/String.java
+48
-0
src/share/classes/sun/nio/cs/ext/ISO2022.java
src/share/classes/sun/nio/cs/ext/ISO2022.java
+3
-3
src/share/classes/sun/nio/cs/ext/ISO2022_CN_CNS.java
src/share/classes/sun/nio/cs/ext/ISO2022_CN_CNS.java
+9
-0
src/share/classes/sun/security/jgss/SunProvider.java
src/share/classes/sun/security/jgss/SunProvider.java
+1
-1
src/share/classes/sun/security/provider/Sun.java
src/share/classes/sun/security/provider/Sun.java
+1
-1
src/share/classes/sun/security/smartcardio/SunPCSC.java
src/share/classes/sun/security/smartcardio/SunPCSC.java
+1
-1
src/share/classes/sun/security/ssl/SunJSSE.java
src/share/classes/sun/security/ssl/SunJSSE.java
+1
-1
src/share/classes/sun/security/util/Password.java
src/share/classes/sun/security/util/Password.java
+10
-2
src/windows/classes/sun/nio/fs/WindowsFileSystem.java
src/windows/classes/sun/nio/fs/WindowsFileSystem.java
+4
-14
test/com/sun/security/auth/callback/TextCallbackHandler/Password.java
.../security/auth/callback/TextCallbackHandler/Password.java
+47
-0
test/java/lang/String/Split.java
test/java/lang/String/Split.java
+47
-0
test/java/nio/file/PathMatcher/Basic.java
test/java/nio/file/PathMatcher/Basic.java
+21
-15
test/java/util/prefs/CommentsInXml.java
test/java/util/prefs/CommentsInXml.java
+60
-0
test/java/util/prefs/ConflictInFlush.java
test/java/util/prefs/ConflictInFlush.java
+49
-0
test/java/util/prefs/ExportNode.java
test/java/util/prefs/ExportNode.java
+53
-0
test/java/util/prefs/ExportSubtree.java
test/java/util/prefs/ExportSubtree.java
+95
-0
test/java/util/prefs/PrefsSpi.java
test/java/util/prefs/PrefsSpi.java
+44
-0
test/java/util/prefs/PrefsSpi.sh
test/java/util/prefs/PrefsSpi.sh
+100
-0
test/java/util/prefs/RemoveReadOnlyNode.java
test/java/util/prefs/RemoveReadOnlyNode.java
+63
-0
test/java/util/prefs/RemoveUnregedListener.java
test/java/util/prefs/RemoveUnregedListener.java
+63
-0
test/java/util/prefs/SerializeExceptions.java
test/java/util/prefs/SerializeExceptions.java
+48
-0
test/sun/nio/cs/FindCanEncodeBugs.java
test/sun/nio/cs/FindCanEncodeBugs.java
+2
-4
未找到文件。
src/share/classes/com/sun/security/auth/callback/TextCallbackHandler.java
浏览文件 @
0f545a87
...
...
@@ -129,7 +129,7 @@ public class TextCallbackHandler implements CallbackHandler {
System
.
err
.
print
(
pc
.
getPrompt
());
System
.
err
.
flush
();
pc
.
setPassword
(
Password
.
readPassword
(
System
.
in
));
pc
.
setPassword
(
Password
.
readPassword
(
System
.
in
,
pc
.
isEchoOn
()
));
}
else
if
(
callbacks
[
i
]
instanceof
ConfirmationCallback
)
{
confirmation
=
(
ConfirmationCallback
)
callbacks
[
i
];
...
...
src/share/classes/com/sun/security/sasl/Provider.java
浏览文件 @
0f545a87
...
...
@@ -51,7 +51,7 @@ public final class Provider extends java.security.Provider {
" server mechanisms for: DIGEST-MD5, GSSAPI, CRAM-MD5)"
;
public
Provider
()
{
super
(
"SunSASL"
,
1.
5
,
info
);
super
(
"SunSASL"
,
1.
7d
,
info
);
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
Void
>()
{
public
Void
run
()
{
...
...
src/share/classes/java/lang/String.java
浏览文件 @
0f545a87
...
...
@@ -2301,6 +2301,54 @@ public final class String
* @spec JSR-51
*/
public
String
[]
split
(
String
regex
,
int
limit
)
{
/* fastpath if the regex is a
(1)one-char String and this character is not one of the
RegEx's meta characters ".$|()[{^?*+\\", or
(2)two-char String and the first char is the backslash and
the second is not the ascii digit or ascii letter.
*/
char
ch
=
0
;
if
(((
regex
.
count
==
1
&&
".$|()[{^?*+\\"
.
indexOf
(
ch
=
regex
.
charAt
(
0
))
==
-
1
)
||
(
regex
.
length
()
==
2
&&
regex
.
charAt
(
0
)
==
'\\'
&&
(((
ch
=
regex
.
charAt
(
1
))-
'0'
)|(
'9'
-
ch
))
<
0
&&
((
ch
-
'a'
)|(
'z'
-
ch
))
<
0
&&
((
ch
-
'A'
)|(
'Z'
-
ch
))
<
0
))
&&
(
ch
<
Character
.
MIN_HIGH_SURROGATE
||
ch
>
Character
.
MAX_LOW_SURROGATE
))
{
int
off
=
0
;
int
next
=
0
;
boolean
limited
=
limit
>
0
;
ArrayList
<
String
>
list
=
new
ArrayList
<
String
>();
while
((
next
=
indexOf
(
ch
,
off
))
!=
-
1
)
{
if
(!
limited
||
list
.
size
()
<
limit
-
1
)
{
list
.
add
(
substring
(
off
,
next
));
off
=
next
+
1
;
}
else
{
// last one
//assert (list.size() == limit - 1);
list
.
add
(
substring
(
off
,
count
));
off
=
count
;
break
;
}
}
// If no match was found, return this
if
(
off
==
0
)
return
new
String
[]
{
this
};
// Add remaining segment
if
(!
limited
||
list
.
size
()
<
limit
)
list
.
add
(
substring
(
off
,
count
));
// Construct result
int
resultSize
=
list
.
size
();
if
(
limit
==
0
)
while
(
resultSize
>
0
&&
list
.
get
(
resultSize
-
1
).
length
()
==
0
)
resultSize
--;
String
[]
result
=
new
String
[
resultSize
];
return
list
.
subList
(
0
,
resultSize
).
toArray
(
result
);
}
return
Pattern
.
compile
(
regex
).
split
(
this
,
limit
);
}
...
...
src/share/classes/sun/nio/cs/ext/ISO2022.java
浏览文件 @
0f545a87
...
...
@@ -388,9 +388,9 @@ abstract class ISO2022
protected
static
class
Encoder
extends
CharsetEncoder
{
private
final
Surrogate
.
Parser
sgp
=
new
Surrogate
.
Parser
();
p
rivate
final
byte
SS2
=
(
byte
)
0x8e
;
p
rivate
final
byte
PLANE2
=
(
byte
)
0xA2
;
p
rivate
final
byte
PLANE3
=
(
byte
)
0xA3
;
p
ublic
static
final
byte
SS2
=
(
byte
)
0x8e
;
p
ublic
static
final
byte
PLANE2
=
(
byte
)
0xA2
;
p
ublic
static
final
byte
PLANE3
=
(
byte
)
0xA3
;
private
final
byte
MSB
=
(
byte
)
0x80
;
protected
final
byte
maximumDesignatorLength
=
4
;
...
...
src/share/classes/sun/nio/cs/ext/ISO2022_CN_CNS.java
浏览文件 @
0f545a87
...
...
@@ -76,6 +76,15 @@ public class ISO2022_CN_CNS extends ISO2022 implements HistoricallyNamedCharset
}
catch
(
Exception
e
)
{
}
}
private
byte
[]
bb
=
new
byte
[
4
];
public
boolean
canEncode
(
char
c
)
{
int
n
=
0
;
return
(
c
<=
'\u007f'
||
(
n
=
((
EUC_TW
.
Encoder
)
ISOEncoder
).
toEUC
(
c
,
bb
))
==
2
||
(
n
==
4
&&
bb
[
0
]
==
SS2
&&
(
bb
[
1
]
==
PLANE2
||
bb
[
1
]
==
PLANE3
)));
}
/*
* Since ISO2022-CN-CNS possesses a CharsetEncoder
* without the corresponding CharsetDecoder half the
...
...
src/share/classes/sun/security/jgss/SunProvider.java
浏览文件 @
0f545a87
...
...
@@ -62,7 +62,7 @@ public final class SunProvider extends Provider {
public
SunProvider
()
{
/* We are the Sun JGSS provider */
super
(
"SunJGSS"
,
1.
0
,
INFO
);
super
(
"SunJGSS"
,
1.
7d
,
INFO
);
AccessController
.
doPrivileged
(
new
java
.
security
.
PrivilegedAction
<
Void
>()
{
...
...
src/share/classes/sun/security/provider/Sun.java
浏览文件 @
0f545a87
...
...
@@ -46,7 +46,7 @@ public final class Sun extends Provider {
public
Sun
()
{
/* We are the SUN provider */
super
(
"SUN"
,
1.
6
,
INFO
);
super
(
"SUN"
,
1.
7
,
INFO
);
// if there is no security manager installed, put directly into
// the provider. Otherwise, create a temporary map and use a
...
...
src/share/classes/sun/security/smartcardio/SunPCSC.java
浏览文件 @
0f545a87
...
...
@@ -40,7 +40,7 @@ public final class SunPCSC extends Provider {
private
static
final
long
serialVersionUID
=
6168388284028876579L
;
public
SunPCSC
()
{
super
(
"SunPCSC"
,
1.
6
d
,
"Sun PC/SC provider"
);
super
(
"SunPCSC"
,
1.
7
d
,
"Sun PC/SC provider"
);
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
Void
>()
{
public
Void
run
()
{
put
(
"TerminalFactory.PC/SC"
,
"sun.security.smartcardio.SunPCSC$Factory"
);
...
...
src/share/classes/sun/security/ssl/SunJSSE.java
浏览文件 @
0f545a87
...
...
@@ -103,7 +103,7 @@ public abstract class SunJSSE extends java.security.Provider {
// standard constructor
protected
SunJSSE
()
{
super
(
"SunJSSE"
,
1.
6
d
,
info
);
super
(
"SunJSSE"
,
1.
7
d
,
info
);
subclassCheck
();
if
(
Boolean
.
TRUE
.
equals
(
fips
))
{
throw
new
ProviderException
...
...
src/share/classes/sun/security/util/Password.java
浏览文件 @
0f545a87
/*
* Copyright 2003-200
6
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2003-200
9
Sun Microsystems, Inc. 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
...
...
@@ -37,6 +37,14 @@ import java.util.Arrays;
public
class
Password
{
/** Reads user password from given input stream. */
public
static
char
[]
readPassword
(
InputStream
in
)
throws
IOException
{
return
readPassword
(
in
,
false
);
}
/** Reads user password from given input stream.
* @param isEchoOn true if the password should be echoed on the screen
*/
public
static
char
[]
readPassword
(
InputStream
in
,
boolean
isEchoOn
)
throws
IOException
{
char
[]
consoleEntered
=
null
;
byte
[]
consoleBytes
=
null
;
...
...
@@ -44,7 +52,7 @@ public class Password {
try
{
// Use the new java.io.Console class
Console
con
=
null
;
if
(
in
==
System
.
in
&&
((
con
=
System
.
console
())
!=
null
))
{
if
(
!
isEchoOn
&&
in
==
System
.
in
&&
((
con
=
System
.
console
())
!=
null
))
{
consoleEntered
=
con
.
readPassword
();
// readPassword returns "" if you just print ENTER,
// to be compatible with old Password class, change to null
...
...
src/windows/classes/sun/nio/fs/WindowsFileSystem.java
浏览文件 @
0f545a87
...
...
@@ -283,25 +283,15 @@ class WindowsFileSystem
}
}
// match in uppercase
StringBuilder
sb
=
new
StringBuilder
(
expr
.
length
());
for
(
int
i
=
0
;
i
<
expr
.
length
();
i
++)
{
sb
.
append
(
Character
.
toUpperCase
(
expr
.
charAt
(
i
)));
}
expr
=
sb
.
toString
();
// match in unicode_case_insensitive
final
Pattern
pattern
=
Pattern
.
compile
(
expr
,
Pattern
.
CASE_INSENSITIVE
|
Pattern
.
UNICODE_CASE
);
// return matcher
final
Pattern
pattern
=
Pattern
.
compile
(
expr
);
return
new
PathMatcher
()
{
@Override
public
boolean
matches
(
Path
path
)
{
// match in uppercase
String
s
=
path
.
toString
();
StringBuilder
sb
=
new
StringBuilder
(
s
.
length
());
for
(
int
i
=
0
;
i
<
s
.
length
();
i
++)
{
sb
.
append
(
Character
.
toUpperCase
(
s
.
charAt
(
i
))
);
}
return
pattern
.
matcher
(
sb
).
matches
();
return
pattern
.
matcher
(
path
.
toString
()).
matches
();
}
};
}
...
...
test/com/sun/security/auth/callback/TextCallbackHandler/Password.java
0 → 100644
浏览文件 @
0f545a87
/*
* Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6825240
* @summary Password.readPassword() echos the input when System.Console is null
* @ignore run these by hand
*/
import
com.sun.security.auth.callback.TextCallbackHandler
;
import
javax.security.auth.callback.*
;
public
class
Password
{
public
static
void
main
(
String
args
[])
throws
Exception
{
TextCallbackHandler
h
=
new
TextCallbackHandler
();
PasswordCallback
nc
=
new
PasswordCallback
(
"Invisible: "
,
false
);
PasswordCallback
nc2
=
new
PasswordCallback
(
"Visible: "
,
true
);
System
.
out
.
println
(
"Two passwords will be prompted for. The first one "
+
"should have echo off, the second one on. Otherwise, this test fails"
);
Callback
[]
callbacks
=
{
nc
,
nc2
};
h
.
handle
(
callbacks
);
System
.
out
.
println
(
"You input "
+
new
String
(
nc
.
getPassword
())
+
" and "
+
new
String
(
nc2
.
getPassword
()));
}
}
test/java/lang/String/Split.java
浏览文件 @
0f545a87
...
...
@@ -23,14 +23,18 @@
/**
* @test
* @bug 6840246
* @summary test String.split()
*/
import
java.util.Arrays
;
import
java.util.Random
;
import
java.util.regex.*
;
public
class
Split
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
source
=
"0123456789"
;
for
(
int
limit
=-
2
;
limit
<
3
;
limit
++)
{
for
(
int
x
=
0
;
x
<
10
;
x
++)
{
String
[]
result
=
source
.
split
(
Integer
.
toString
(
x
),
limit
);
...
...
@@ -80,5 +84,48 @@ public class Split {
throw
new
RuntimeException
(
"String.split failure 8"
);
if
(!
result
[
0
].
equals
(
source
))
throw
new
RuntimeException
(
"String.split failure 9"
);
// check fastpath of String.split()
source
=
"0123456789abcdefgABCDEFG"
;
Random
r
=
new
Random
();
for
(
boolean
doEscape:
new
boolean
[]
{
false
,
true
})
{
for
(
int
cp
=
0
;
cp
<
0x11000
;
cp
++)
{
Pattern
p
=
null
;
String
regex
=
new
String
(
Character
.
toChars
(
cp
));
if
(
doEscape
)
regex
=
"\\"
+
regex
;
try
{
p
=
Pattern
.
compile
(
regex
);
}
catch
(
PatternSyntaxException
pse
)
{
// illegal syntax
try
{
"abc"
.
split
(
regex
);
}
catch
(
PatternSyntaxException
pse0
)
{
continue
;
}
throw
new
RuntimeException
(
"String.split failure 11"
);
}
int
off
=
r
.
nextInt
(
source
.
length
());
String
[]
srcStrs
=
new
String
[]
{
""
,
source
,
regex
+
source
,
source
+
regex
,
source
.
substring
(
0
,
3
)
+
regex
+
source
.
substring
(
3
,
9
)
+
regex
+
source
.
substring
(
9
,
15
)
+
regex
+
source
.
substring
(
15
),
source
.
substring
(
0
,
off
)
+
regex
+
source
.
substring
(
off
)
};
for
(
String
src:
srcStrs
)
{
for
(
int
limit
=-
2
;
limit
<
3
;
limit
++)
{
if
(!
Arrays
.
equals
(
src
.
split
(
regex
,
limit
),
p
.
split
(
src
,
limit
)))
throw
new
RuntimeException
(
"String.split failure 12"
);
}
}
}
}
}
}
test/java/nio/file/PathMatcher/Basic.java
浏览文件 @
0f545a87
...
...
@@ -22,7 +22,7 @@
*/
/* @test
* @bug 4313887
* @bug 4313887
6866397
* @summary Unit test for java.nio.file.PathMatcher
*/
...
...
@@ -68,6 +68,20 @@ public class Basic {
}
}
static
void
assertRegExMatch
(
String
path
,
String
pattern
)
{
System
.
out
.
format
(
"Test regex pattern: %s"
,
pattern
);
Path
file
=
Paths
.
get
(
path
);
boolean
matched
=
file
.
getFileSystem
()
.
getPathMatcher
(
"regex:"
+
pattern
).
matches
(
file
);
if
(
matched
)
{
System
.
out
.
println
(
" OKAY"
);
}
else
{
System
.
out
.
println
(
" ==> UNEXPECTED RESULT!"
);
failures
++;
}
}
public
static
void
main
(
String
[]
args
)
{
// basic
assertMatch
(
"foo.html"
,
"foo.html"
);
...
...
@@ -140,21 +154,13 @@ public class Basic {
assertMatch
(
"one*two"
,
"one\\*two"
);
}
// regex syntax
{
String
pattern
=
".*\\.html"
;
System
.
out
.
format
(
"Test regex pattern: %s"
,
pattern
);
Path
file
=
Paths
.
get
(
"foo.html"
);
boolean
matched
=
file
.
getFileSystem
()
.
getPathMatcher
(
"regex:"
+
pattern
).
matches
(
file
);
if
(
matched
)
{
System
.
out
.
println
(
" OKAY"
);
}
else
{
System
.
out
.
println
(
" ==> UNEXPECTED RESULT!"
);
failures
++;
}
assertRegExMatch
(
"foo.html"
,
".*\\.html"
);
if
(
System
.
getProperty
(
"os.name"
).
startsWith
(
"Windows"
))
{
assertRegExMatch
(
"foo012"
,
"foo\\d+"
);
assertRegExMatch
(
"fo o"
,
"fo\\so"
);
assertRegExMatch
(
"foo"
,
"\\w+"
);
}
// unknown syntax
...
...
test/java/util/prefs/CommentsInXml.java
0 → 100644
浏览文件 @
0f545a87
/*
* Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 4619564
* @summary XMl Comments in Preferences File lead to ClassCastException
* @author kladko
*/
import
java.io.*
;
import
java.util.prefs.*
;
public
class
CommentsInXml
{
public
static
void
main
(
String
[]
argv
)
throws
Exception
{
ByteArrayOutputStream
bos
=
new
ByteArrayOutputStream
();
bos
.
write
(
new
String
(
"<!DOCTYPE preferences SYSTEM "
+
"\"http://java.sun.com/dtd/preferences.dtd\"> "
+
"<preferences EXTERNAL_XML_VERSION=\"1.0\"> "
+
" <root type=\"user\"> "
+
" <map> "
+
" </map> "
+
" <node name=\"hlrAgent\"> <!-- HLR Agent --> "
+
" <map> "
+
" <entry key=\"agentName\" value=\"HLRAgent\" />"
+
" </map> "
+
" </node> "
+
" </root> "
+
"</preferences> "
).
getBytes
());
Preferences
ur
=
Preferences
.
userRoot
();
ur
.
importPreferences
(
new
ByteArrayInputStream
(
bos
.
toByteArray
()));
ur
.
node
(
"hlrAgent"
).
removeNode
();
// clean
}
}
test/java/util/prefs/ConflictInFlush.java
0 → 100644
浏览文件 @
0f545a87
/*
* Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 4703132
* @summary flush() throws an IllegalStateException on a removed node
* @author Sucheta Dambalkar
*/
import
java.util.prefs.*
;
public
final
class
ConflictInFlush
{
public
static
void
main
(
String
args
[])
{
Preferences
root
=
Preferences
.
userRoot
();
try
{
Preferences
node
=
root
.
node
(
"1/2/3"
);
node
.
flush
();
System
.
out
.
println
(
"Node "
+
node
+
" has been created"
);
System
.
out
.
println
(
"Removing node "
+
node
);
node
.
removeNode
();
node
.
flush
();
}
catch
(
BackingStoreException
bse
){
bse
.
printStackTrace
();
}
}
}
test/java/util/prefs/ExportNode.java
0 → 100644
浏览文件 @
0f545a87
/*
* Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 4387136 4947349
* @summary Due to a bug in XMLSupport.putPreferencesInXml(...),
* node's keys would not get exported.
* @author Konstantin Kladko
*/
import
java.util.prefs.*
;
import
java.io.*
;
public
class
ExportNode
{
public
static
void
main
(
String
[]
args
)
throws
BackingStoreException
,
IOException
{
Preferences
N1
=
Preferences
.
userRoot
().
node
(
"ExportNodeTest1"
);
N1
.
put
(
"ExportNodeTestName1"
,
"ExportNodeTestValue1"
);
Preferences
N2
=
N1
.
node
(
"ExportNodeTest2"
);
N2
.
put
(
"ExportNodeTestName2"
,
"ExportNodeTestValue2"
);
ByteArrayOutputStream
exportStream
=
new
ByteArrayOutputStream
();
N2
.
exportNode
(
exportStream
);
// Removal of preference node should always succeed on Solaris/Linux
// by successfully acquiring the appropriate file lock (4947349)
N1
.
removeNode
();
if
(((
exportStream
.
toString
()).
lastIndexOf
(
"ExportNodeTestName2"
)==
-
1
)
||
((
exportStream
.
toString
()).
lastIndexOf
(
"ExportNodeTestName1"
)!=
-
1
))
{
}
}
}
test/java/util/prefs/ExportSubtree.java
0 → 100644
浏览文件 @
0f545a87
/*
* Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
@bug 6203576 4700020
@summary checks if the output of exportSubtree() is identical to
the output from previous release.
*/
import
java.io.*
;
import
java.util.prefs.*
;
public
class
ExportSubtree
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
try
{
//File f = new File(System.getProperty("test.src", "."), "TestPrefs.xml");
ByteArrayInputStream
bais
=
new
ByteArrayInputStream
(
importPrefs
.
getBytes
(
"utf-8"
));
Preferences
.
importPreferences
(
bais
);
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
Preferences
.
userRoot
().
node
(
"testExportSubtree"
).
exportSubtree
(
baos
);
Preferences
.
userRoot
().
node
(
"testExportSubtree"
).
removeNode
();
if
(!
expectedResult
.
equals
(
baos
.
toString
()))
{
//System.out.print(baos.toString());
//System.out.print(expectedResult);
throw
new
IOException
(
"exportSubtree does not output expected result"
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
static
String
ls
=
System
.
getProperty
(
"line.separator"
);
static
String
importPrefs
=
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+
"<!DOCTYPE preferences SYSTEM \"http://java.sun.com/dtd/preferences.dtd\">"
+
"<preferences EXTERNAL_XML_VERSION=\"1.0\">"
+
" <root type=\"user\">"
+
" <map>"
+
" <entry key=\"key1\" value=\"value1\"/>"
+
" </map>"
+
" <node name=\"testExportSubtree\">"
+
" <map>"
+
" <entry key=\"key2\" value=\"value2\"/>"
+
" </map>"
+
" <node name=\"test\">"
+
" <map>"
+
" <entry key=\"key3\" value=\"value3\"/>"
+
" </map>"
+
" </node>"
+
" </node>"
+
" </root>"
+
"</preferences>"
;
static
String
expectedResult
=
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+
ls
+
"<!DOCTYPE preferences SYSTEM \"http://java.sun.com/dtd/preferences.dtd\">"
+
ls
+
"<preferences EXTERNAL_XML_VERSION=\"1.0\">"
+
ls
+
" <root type=\"user\">"
+
ls
+
" <map/>"
+
ls
+
" <node name=\"testExportSubtree\">"
+
ls
+
" <map>"
+
ls
+
" <entry key=\"key2\" value=\"value2\"/>"
+
ls
+
" </map>"
+
ls
+
" <node name=\"test\">"
+
ls
+
" <map>"
+
ls
+
" <entry key=\"key3\" value=\"value3\"/>"
+
ls
+
" </map>"
+
ls
+
" </node>"
+
ls
+
" </node>"
+
ls
+
" </root>"
+
ls
+
"</preferences>"
+
ls
;
}
test/java/util/prefs/PrefsSpi.java
0 → 100644
浏览文件 @
0f545a87
/*
* Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
import
java.util.prefs.Preferences
;
/*
* main class used by regtest PrefsSpi.sh
*/
public
class
PrefsSpi
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
if
(
args
.
length
!=
1
)
throw
new
Exception
(
"Usage: java PrefsSpi REGEXP"
);
String
className
=
Preferences
.
userRoot
().
getClass
().
getName
();
System
.
out
.
printf
(
"className=%s%n"
,
className
);
if
(!
className
.
matches
(
args
[
0
]))
throw
new
Exception
(
"Preferences class name \""
+
className
+
"\" does not match regular expression \""
+
args
[
0
]
+
"\"."
);
}
}
test/java/util/prefs/PrefsSpi.sh
0 → 100644
浏览文件 @
0f545a87
#!/bin/sh
#
# Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
# @test
# @bug 4991526 6514993
# @summary Unit test for Preferences jar providers
#
# @build PrefsSpi
# @run shell PrefsSpi.sh
# @author Martin Buchholz
# Command-line usage: sh PrefsSpi.sh /path/to/build
if
[
-z
"
$TESTJAVA
"
]
;
then
if
[
$#
-lt
1
]
;
then
exit
1
;
fi
TESTJAVA
=
"
$1
"
;
shift
TESTSRC
=
"
`
pwd
`
"
TESTCLASSES
=
"
`
pwd
`
"
fi
java
=
"
$TESTJAVA
/bin/java"
javac
=
"
$TESTJAVA
/bin/javac"
jar
=
"
$TESTJAVA
/bin/jar"
Die
()
{
printf
"%s
\n
"
"
$*
"
;
exit
1
;
}
Sys
()
{
printf
"%s
\n
"
"
$*
"
;
"
$@
"
;
rc
=
"
$?
"
;
test
"
$rc
"
-eq
0
||
Die
"Command
\"
$*
\"
failed with exitValue
$rc
"
;
}
cat
>
StubPreferences.java
<<
'
EOF
'
import java.util.prefs.*;
public class StubPreferences extends AbstractPreferences {
public StubPreferences() { super(null, ""); }
public String getSpi(String x) { return null; }
public void putSpi(String x, String y) { }
public void removeSpi(String x) { }
public AbstractPreferences childSpi(String x) { return null; }
public void removeNodeSpi() { }
public String[] keysSpi() { return null; }
public String[] childrenNamesSpi() { return null; }
public void syncSpi() { }
public void flushSpi() { }
}
EOF
cat
>
StubPreferencesFactory.java
<<
'
EOF
'
import java.util.prefs.*;
public class StubPreferencesFactory implements PreferencesFactory {
public Preferences userRoot() { return new StubPreferences(); }
public Preferences systemRoot() { return new StubPreferences(); }
}
EOF
Sys
rm
-rf
jarDir extDir
Sys
mkdir
-p
jarDir/META-INF/services extDir
echo
"StubPreferencesFactory"
\
>
"jarDir/META-INF/services/java.util.prefs.PreferencesFactory"
Sys
"
$javac
"
-d
jarDir StubPreferencesFactory.java StubPreferences.java
(
cd
jarDir
&&
"
$jar
"
"cf"
"../extDir/PrefsSpi.jar"
"."
)
case
"
`
uname
`
"
in
Windows
*
|
CYGWIN
*
)
CPS
=
';'
;;
*
)
CPS
=
':'
;;
esac
Sys
"
$java
"
"-cp"
"
$TESTCLASSES
${
CPS
}
extDir/PrefsSpi.jar"
\
-Djava
.util.prefs.PreferencesFactory
=
StubPreferencesFactory
\
PrefsSpi
"StubPreferences"
Sys
"
$java
"
"-cp"
"
$TESTCLASSES
"
\
PrefsSpi
"java.util.prefs.*"
Sys
"
$java
"
"-cp"
"
$TESTCLASSES
${
CPS
}
extDir/PrefsSpi.jar"
\
PrefsSpi
"StubPreferences"
Sys
"
$java
"
"-cp"
"
$TESTCLASSES
"
"-Djava.ext.dirs=extDir"
\
PrefsSpi
"StubPreferences"
rm
-rf
jarDir extDir
test/java/util/prefs/RemoveReadOnlyNode.java
0 → 100644
浏览文件 @
0f545a87
/*
* Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
@bug 6178148
@summary check if wrong exception gets thrown if one of the child
nodes is readonly on underlying filesystem when node is
being removed.
*/
import
java.io.*
;
import
java.util.prefs.*
;
public
class
RemoveReadOnlyNode
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
osName
=
System
.
getProperty
(
"os.name"
);
if
(
osName
.
startsWith
(
"Windows"
))
return
;
Preferences
root
=
Preferences
.
userRoot
();
Preferences
node1
=
root
.
node
(
"node1"
);
Preferences
node1A
=
node1
.
node
(
"node1A"
);
Preferences
node1B
=
node1
.
node
(
"node1B"
);
node1B
.
put
(
"mykey"
,
"myvalue"
);
node1
.
flush
();
String
node1BDirName
=
System
.
getProperty
(
"user.home"
)
+
"/.java/.userPrefs"
+
"/node1/node1B"
;
File
node1BDir
=
new
File
(
node1BDirName
);
node1BDir
.
setReadOnly
();
try
{
node1
.
removeNode
();
}
catch
(
BackingStoreException
ex
)
{
//expected exception
}
finally
{
Runtime
.
getRuntime
().
exec
(
"chmod 755 "
+
node1BDirName
).
waitFor
();
try
{
node1
.
removeNode
();
}
catch
(
Exception
e
)
{}
}
}
}
test/java/util/prefs/RemoveUnregedListener.java
0 → 100644
浏览文件 @
0f545a87
/*
* Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
* @bug 4705094
* @summary Checks if correct exception gets thrown when removing an
* unregistered NodeChangeListener .
*/
import
java.util.prefs.*
;
import
java.util.*
;
public
class
RemoveUnregedListener
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Preferences
userRoot
=
null
;
Preferences
N1
=
null
;
NodeChangeListenerTestAdd
ncl
=
new
NodeChangeListenerTestAdd
();
NodeChangeListenerTestAdd
ncl2
=
new
NodeChangeListenerTestAdd
();
NodeChangeListenerTestAdd
ncl3
=
new
NodeChangeListenerTestAdd
();
try
{
userRoot
=
Preferences
.
userRoot
();
N1
=
userRoot
.
node
(
"N1"
);
userRoot
.
flush
();
//add ncl nc2
N1
.
addNodeChangeListener
(
ncl
);
N1
.
addNodeChangeListener
(
ncl2
);
N1
.
removeNodeChangeListener
(
ncl3
);
throw
new
RuntimeException
();
}
catch
(
IllegalArgumentException
iae
)
{
System
.
out
.
println
(
"Test Passed!"
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"Test Failed"
);
throw
e
;
}
}
}
class
NodeChangeListenerTestAdd
implements
NodeChangeListener
{
public
void
childAdded
(
NodeChangeEvent
evt
)
{}
public
void
childRemoved
(
NodeChangeEvent
evt
)
{}
}
test/java/util/prefs/SerializeExceptions.java
0 → 100644
浏览文件 @
0f545a87
/*
* Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 4811356
* @summary Prefs exceptions were unintentionally not serializable
* @author Josh Bloch
*/
import
java.util.prefs.*
;
import
java.io.*
;
public
class
SerializeExceptions
{
public
static
void
main
(
String
args
[])
throws
Exception
{
test
(
new
BackingStoreException
(
"Hi"
));
test
(
new
InvalidPreferencesFormatException
(
"Mom!"
));
}
static
void
test
(
Object
o
)
throws
IOException
{
ByteArrayOutputStream
bos
=
new
ByteArrayOutputStream
();
ObjectOutputStream
out
=
new
ObjectOutputStream
(
bos
);
out
.
writeObject
(
o
);
out
.
flush
();
out
.
close
();
}
}
test/sun/nio/cs/FindCanEncodeBugs.java
浏览文件 @
0f545a87
...
...
@@ -22,7 +22,7 @@
*/
/* @test
@bug 5066863 5066867 5066874 5066879 5066884 5066887 5065777
@bug 5066863 5066867 5066874 5066879 5066884 5066887 5065777
6730652
@summary canEncode() false iff encode() throws CharacterCodingException
@run main/timeout=1200 FindCanEncodeBugs
@author Martin Buchholz
...
...
@@ -52,9 +52,7 @@ public class FindCanEncodeBugs {
String
csn
=
e
.
getKey
();
Charset
cs
=
e
.
getValue
();
if
(!
cs
.
canEncode
()
||
csn
.
matches
(
"x-COMPOUND_TEXT"
)
||
csn
.
matches
(
"x-ISO-2022-CN-CNS"
))
// ISO2022_CN_CNS supports less
if
(!
cs
.
canEncode
()
||
csn
.
matches
(
"x-COMPOUND_TEXT"
))
continue
;
//System.out.println(csn);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录