Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
7142b15a
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看板
提交
7142b15a
编写于
10月 18, 2013
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7050570: (fs) FileSysteProvider fails to initializes if run with file.encoding set to Cp037
Reviewed-by: sherman, ulfzibis
上级
07b9e3b6
变更
14
显示空白变更内容
内联
并排
Showing
14 changed file
with
66 addition
and
36 deletion
+66
-36
src/share/classes/sun/nio/fs/Util.java
src/share/classes/sun/nio/fs/Util.java
+30
-0
src/solaris/classes/sun/nio/fs/GnomeFileTypeDetector.java
src/solaris/classes/sun/nio/fs/GnomeFileTypeDetector.java
+2
-2
src/solaris/classes/sun/nio/fs/LinuxDosFileAttributeView.java
...solaris/classes/sun/nio/fs/LinuxDosFileAttributeView.java
+3
-3
src/solaris/classes/sun/nio/fs/LinuxFileStore.java
src/solaris/classes/sun/nio/fs/LinuxFileStore.java
+2
-1
src/solaris/classes/sun/nio/fs/LinuxFileSystem.java
src/solaris/classes/sun/nio/fs/LinuxFileSystem.java
+1
-1
src/solaris/classes/sun/nio/fs/LinuxUserDefinedFileAttributeView.java
...classes/sun/nio/fs/LinuxUserDefinedFileAttributeView.java
+2
-2
src/solaris/classes/sun/nio/fs/SolarisUserDefinedFileAttributeView.java
...asses/sun/nio/fs/SolarisUserDefinedFileAttributeView.java
+11
-12
src/solaris/classes/sun/nio/fs/UnixException.java
src/solaris/classes/sun/nio/fs/UnixException.java
+1
-1
src/solaris/classes/sun/nio/fs/UnixFileStore.java
src/solaris/classes/sun/nio/fs/UnixFileStore.java
+1
-1
src/solaris/classes/sun/nio/fs/UnixFileSystem.java
src/solaris/classes/sun/nio/fs/UnixFileSystem.java
+2
-2
src/solaris/classes/sun/nio/fs/UnixMountEntry.java
src/solaris/classes/sun/nio/fs/UnixMountEntry.java
+3
-3
src/solaris/classes/sun/nio/fs/UnixNativeDispatcher.java
src/solaris/classes/sun/nio/fs/UnixNativeDispatcher.java
+3
-3
src/solaris/classes/sun/nio/fs/UnixPath.java
src/solaris/classes/sun/nio/fs/UnixPath.java
+3
-3
src/solaris/classes/sun/nio/fs/UnixUserPrincipals.java
src/solaris/classes/sun/nio/fs/UnixUserPrincipals.java
+2
-2
未找到文件。
src/share/classes/sun/nio/fs/Util.java
浏览文件 @
7142b15a
...
...
@@ -27,6 +27,9 @@ package sun.nio.fs;
import
java.util.*
;
import
java.nio.file.*
;
import
java.nio.charset.Charset
;
import
java.security.*
;
import
sun.security.action.*
;
/**
* Utility methods
...
...
@@ -35,6 +38,33 @@ import java.nio.file.*;
class
Util
{
private
Util
()
{
}
private
static
final
Charset
jnuEncoding
=
Charset
.
forName
(
AccessController
.
doPrivileged
(
new
GetPropertyAction
(
"sun.jnu.encoding"
)));
/**
* Returns {@code Charset} corresponding to the sun.jnu.encoding property
*/
static
Charset
jnuEncoding
()
{
return
jnuEncoding
;
}
/**
* Encodes the given String into a sequence of bytes using the {@code Charset}
* specified by the sun.jnu.encoding property.
*/
static
byte
[]
toBytes
(
String
s
)
{
return
s
.
getBytes
(
jnuEncoding
);
}
/**
* Constructs a new String by decoding the specified array of bytes using the
* {@code Charset} specified by the sun.jnu.encoding property.
*/
static
String
toString
(
byte
[]
bytes
)
{
return
new
String
(
bytes
,
jnuEncoding
);
}
/**
* Splits a string around the given character. The array returned by this
* method contains each substring that is terminated by the character. Use
...
...
src/solaris/classes/sun/nio/fs/GnomeFileTypeDetector.java
浏览文件 @
7142b15a
...
...
@@ -70,12 +70,12 @@ public class GnomeFileTypeDetector
// GIO may access file so need permission check
path
.
checkRead
();
byte
[]
type
=
probeUsingGio
(
buffer
.
address
());
return
(
type
==
null
)
?
null
:
new
String
(
type
);
return
(
type
==
null
)
?
null
:
Util
.
to
String
(
type
);
}
else
{
byte
[]
type
=
probeUsingGnomeVfs
(
buffer
.
address
());
if
(
type
==
null
)
return
null
;
String
s
=
new
String
(
type
);
String
s
=
Util
.
to
String
(
type
);
return
s
.
equals
(
GNOME_VFS_MIME_TYPE_UNKNOWN
)
?
null
:
s
;
}
}
finally
{
...
...
src/solaris/classes/sun/nio/fs/LinuxDosFileAttributeView.java
浏览文件 @
7142b15a
...
...
@@ -51,7 +51,7 @@ class LinuxDosFileAttributeView
private
static
final
String
HIDDEN_NAME
=
"hidden"
;
private
static
final
String
DOS_XATTR_NAME
=
"user.DOSATTRIB"
;
private
static
final
byte
[]
DOS_XATTR_NAME_AS_BYTES
=
DOS_XATTR_NAME
.
getBytes
(
);
private
static
final
byte
[]
DOS_XATTR_NAME_AS_BYTES
=
Util
.
toBytes
(
DOS_XATTR_NAME
);
private
static
final
int
DOS_XATTR_READONLY
=
0x01
;
private
static
final
int
DOS_XATTR_HIDDEN
=
0x02
;
...
...
@@ -225,7 +225,7 @@ class LinuxDosFileAttributeView
byte
[]
buf
=
new
byte
[
len
];
unsafe
.
copyMemory
(
null
,
buffer
.
address
(),
buf
,
Unsafe
.
ARRAY_BYTE_BASE_OFFSET
,
len
);
String
value
=
new
String
(
buf
);
// platform encoding
String
value
=
Util
.
toString
(
buf
);
// should be something like 0x20
if
(
value
.
length
()
>=
3
&&
value
.
startsWith
(
"0x"
))
{
...
...
@@ -263,7 +263,7 @@ class LinuxDosFileAttributeView
newValue
&=
~
flag
;
}
if
(
newValue
!=
oldValue
)
{
byte
[]
value
=
(
"0x"
+
Integer
.
toHexString
(
newValue
)).
getBytes
(
);
byte
[]
value
=
Util
.
toBytes
(
"0x"
+
Integer
.
toHexString
(
newValue
)
);
NativeBuffer
buffer
=
NativeBuffers
.
asNativeBuffer
(
value
);
try
{
LinuxNativeDispatcher
.
fsetxattr
(
fd
,
DOS_XATTR_NAME_AS_BYTES
,
...
...
src/solaris/classes/sun/nio/fs/LinuxFileStore.java
浏览文件 @
7142b15a
...
...
@@ -98,7 +98,8 @@ class LinuxFileStore
int
fd
=
path
.
openForAttributeAccess
(
false
);
try
{
// fgetxattr returns size if called with size==0
LinuxNativeDispatcher
.
fgetxattr
(
fd
,
"user.java"
.
getBytes
(),
0L
,
0
);
byte
[]
name
=
Util
.
toBytes
(
"user.java"
);
LinuxNativeDispatcher
.
fgetxattr
(
fd
,
name
,
0L
,
0
);
return
true
;
}
catch
(
UnixException
e
)
{
// attribute does not exist
...
...
src/solaris/classes/sun/nio/fs/LinuxFileSystem.java
浏览文件 @
7142b15a
...
...
@@ -78,7 +78,7 @@ class LinuxFileSystem extends UnixFileSystem {
Iterable
<
UnixMountEntry
>
getMountEntries
(
String
fstab
)
{
ArrayList
<
UnixMountEntry
>
entries
=
new
ArrayList
<>();
try
{
long
fp
=
setmntent
(
fstab
.
getBytes
(),
"r"
.
getBytes
(
));
long
fp
=
setmntent
(
Util
.
toBytes
(
fstab
),
Util
.
toBytes
(
"r"
));
try
{
for
(;;)
{
UnixMountEntry
entry
=
new
UnixMountEntry
();
...
...
src/solaris/classes/sun/nio/fs/LinuxUserDefinedFileAttributeView.java
浏览文件 @
7142b15a
...
...
@@ -53,7 +53,7 @@ class LinuxUserDefinedFileAttributeView
if
(
name
==
null
)
throw
new
NullPointerException
(
"'name' is null"
);
name
=
USER_NAMESPACE
+
name
;
byte
[]
bytes
=
name
.
getBytes
(
);
byte
[]
bytes
=
Util
.
toBytes
(
name
);
if
(
bytes
.
length
>
XATTR_NAME_MAX
)
{
throw
new
FileSystemException
(
file
.
getPathForExceptionMessage
(),
null
,
"'"
+
name
+
"' is too big"
);
...
...
@@ -72,7 +72,7 @@ class LinuxUserDefinedFileAttributeView
byte
[]
value
=
new
byte
[
len
];
unsafe
.
copyMemory
(
null
,
address
+
start
,
value
,
Unsafe
.
ARRAY_BYTE_BASE_OFFSET
,
len
);
String
s
=
new
String
(
value
);
String
s
=
Util
.
to
String
(
value
);
if
(
s
.
startsWith
(
USER_NAMESPACE
))
{
s
=
s
.
substring
(
USER_NAMESPACE
.
length
());
list
.
add
(
s
);
...
...
src/solaris/classes/sun/nio/fs/SolarisUserDefinedFileAttributeView.java
浏览文件 @
7142b15a
...
...
@@ -42,17 +42,16 @@ import static sun.nio.fs.SolarisConstants.*;
class
SolarisUserDefinedFileAttributeView
extends
AbstractUserDefinedFileAttributeView
{
private
static
final
byte
[]
HERE
=
{
'.'
};
private
byte
[]
nameAsBytes
(
UnixPath
file
,
String
name
)
throws
IOException
{
byte
[]
bytes
=
name
.
getBytes
(
);
byte
[]
bytes
=
Util
.
toBytes
(
name
);
// "", "." and ".." not allowed
if
(
bytes
.
length
==
0
||
bytes
[
0
]
==
'.'
)
{
if
(
bytes
.
length
<=
1
||
(
bytes
.
length
==
2
&&
bytes
[
1
]
==
'.'
))
{
if
((
bytes
.
length
==
0
||
bytes
[
0
]
==
'.'
)
&&
((
bytes
.
length
<=
1
||
(
bytes
.
length
==
2
&&
bytes
[
1
]
==
'.'
))
{
throw
new
FileSystemException
(
file
.
getPathForExceptionMessage
(),
null
,
"'"
+
name
+
"' is not a valid name"
);
}
}
return
bytes
;
}
...
...
@@ -73,7 +72,7 @@ class SolarisUserDefinedFileAttributeView
try
{
try
{
// open extended attribute directory
int
dfd
=
openat
(
fd
,
"."
.
getBytes
()
,
(
O_RDONLY
|
O_XATTR
),
0
);
int
dfd
=
openat
(
fd
,
HERE
,
(
O_RDONLY
|
O_XATTR
),
0
);
long
dp
;
try
{
dp
=
fdopendir
(
dfd
);
...
...
@@ -87,7 +86,7 @@ class SolarisUserDefinedFileAttributeView
try
{
byte
[]
name
;
while
((
name
=
readdir
(
dp
))
!=
null
)
{
String
s
=
new
String
(
name
);
String
s
=
Util
.
to
String
(
name
);
if
(!
s
.
equals
(
"."
)
&&
!
s
.
equals
(
".."
))
list
.
add
(
s
);
}
...
...
@@ -217,7 +216,7 @@ class SolarisUserDefinedFileAttributeView
int
fd
=
file
.
openForAttributeAccess
(
followLinks
);
try
{
int
dfd
=
openat
(
fd
,
"."
.
getBytes
()
,
(
O_RDONLY
|
O_XATTR
),
0
);
int
dfd
=
openat
(
fd
,
HERE
,
(
O_RDONLY
|
O_XATTR
),
0
);
try
{
unlinkat
(
dfd
,
nameAsBytes
(
file
,
name
),
0
);
}
finally
{
...
...
@@ -243,7 +242,7 @@ class SolarisUserDefinedFileAttributeView
static
void
copyExtendedAttributes
(
int
ofd
,
int
nfd
)
{
try
{
// open extended attribute directory
int
dfd
=
openat
(
ofd
,
"."
.
getBytes
()
,
(
O_RDONLY
|
O_XATTR
),
0
);
int
dfd
=
openat
(
ofd
,
HERE
,
(
O_RDONLY
|
O_XATTR
),
0
);
long
dp
=
0L
;
try
{
dp
=
fdopendir
(
dfd
);
...
...
src/solaris/classes/sun/nio/fs/UnixException.java
浏览文件 @
7142b15a
...
...
@@ -61,7 +61,7 @@ class UnixException extends Exception {
if
(
msg
!=
null
)
{
return
msg
;
}
else
{
return
new
String
(
UnixNativeDispatcher
.
strerror
(
errno
()));
return
Util
.
to
String
(
UnixNativeDispatcher
.
strerror
(
errno
()));
}
}
...
...
src/solaris/classes/sun/nio/fs/UnixFileStore.java
浏览文件 @
7142b15a
...
...
@@ -196,7 +196,7 @@ abstract class UnixFileStore
@Override
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
(
new
String
(
entry
.
dir
()));
StringBuilder
sb
=
new
StringBuilder
(
Util
.
to
String
(
entry
.
dir
()));
sb
.
append
(
" ("
);
sb
.
append
(
entry
.
name
());
sb
.
append
(
")"
);
...
...
src/solaris/classes/sun/nio/fs/UnixFileSystem.java
浏览文件 @
7142b15a
...
...
@@ -49,7 +49,7 @@ abstract class UnixFileSystem
// package-private
UnixFileSystem
(
UnixFileSystemProvider
provider
,
String
dir
)
{
this
.
provider
=
provider
;
this
.
defaultDirectory
=
U
nixPath
.
normalizeAndCheck
(
dir
).
getBytes
(
);
this
.
defaultDirectory
=
U
til
.
toBytes
(
UnixPath
.
normalizeAndCheck
(
dir
)
);
if
(
this
.
defaultDirectory
[
0
]
!=
'/'
)
{
throw
new
RuntimeException
(
"default directory must be absolute"
);
}
...
...
@@ -204,7 +204,7 @@ abstract class UnixFileSystem
SecurityManager
sm
=
System
.
getSecurityManager
();
if
(
sm
!=
null
)
{
try
{
sm
.
checkRead
(
new
String
(
entry
.
dir
()));
sm
.
checkRead
(
Util
.
to
String
(
entry
.
dir
()));
}
catch
(
SecurityException
x
)
{
continue
;
}
...
...
src/solaris/classes/sun/nio/fs/UnixMountEntry.java
浏览文件 @
7142b15a
...
...
@@ -43,12 +43,12 @@ class UnixMountEntry {
}
String
name
()
{
return
new
String
(
name
);
return
Util
.
to
String
(
name
);
}
String
fstype
()
{
if
(
fstypeAsString
==
null
)
fstypeAsString
=
new
String
(
fstype
);
fstypeAsString
=
Util
.
to
String
(
fstype
);
return
fstypeAsString
;
}
...
...
@@ -65,7 +65,7 @@ class UnixMountEntry {
*/
boolean
hasOption
(
String
requested
)
{
if
(
optionsAsString
==
null
)
optionsAsString
=
new
String
(
opts
);
optionsAsString
=
Util
.
to
String
(
opts
);
for
(
String
opt:
Util
.
split
(
optionsAsString
,
','
))
{
if
(
opt
.
equals
(
requested
))
return
true
;
...
...
src/solaris/classes/sun/nio/fs/UnixNativeDispatcher.java
浏览文件 @
7142b15a
...
...
@@ -100,7 +100,7 @@ class UnixNativeDispatcher {
*/
static
long
fopen
(
UnixPath
filename
,
String
mode
)
throws
UnixException
{
NativeBuffer
pathBuffer
=
copyToNativeBuffer
(
filename
);
NativeBuffer
modeBuffer
=
NativeBuffers
.
asNativeBuffer
(
mode
.
getBytes
(
));
NativeBuffer
modeBuffer
=
NativeBuffers
.
asNativeBuffer
(
Util
.
toBytes
(
mode
));
try
{
return
fopen0
(
pathBuffer
.
address
(),
modeBuffer
.
address
());
}
finally
{
...
...
@@ -473,7 +473,7 @@ class UnixNativeDispatcher {
* @return passwd->pw_uid
*/
static
int
getpwnam
(
String
name
)
throws
UnixException
{
NativeBuffer
buffer
=
NativeBuffers
.
asNativeBuffer
(
name
.
getBytes
(
));
NativeBuffer
buffer
=
NativeBuffers
.
asNativeBuffer
(
Util
.
toBytes
(
name
));
try
{
return
getpwnam0
(
buffer
.
address
());
}
finally
{
...
...
@@ -488,7 +488,7 @@ class UnixNativeDispatcher {
* @return group->gr_name
*/
static
int
getgrnam
(
String
name
)
throws
UnixException
{
NativeBuffer
buffer
=
NativeBuffers
.
asNativeBuffer
(
name
.
getBytes
(
));
NativeBuffer
buffer
=
NativeBuffers
.
asNativeBuffer
(
Util
.
toBytes
(
name
));
try
{
return
getgrnam0
(
buffer
.
address
());
}
finally
{
...
...
src/solaris/classes/sun/nio/fs/UnixPath.java
浏览文件 @
7142b15a
...
...
@@ -120,7 +120,7 @@ class UnixPath
SoftReference
<
CharsetEncoder
>
ref
=
encoder
.
get
();
CharsetEncoder
ce
=
(
ref
!=
null
)
?
ref
.
get
()
:
null
;
if
(
ce
==
null
)
{
ce
=
Charset
.
defaultCharset
().
newEncoder
()
ce
=
Util
.
jnuEncoding
().
newEncoder
()
.
onMalformedInput
(
CodingErrorAction
.
REPORT
)
.
onUnmappableCharacter
(
CodingErrorAction
.
REPORT
);
encoder
.
set
(
new
SoftReference
<
CharsetEncoder
>(
ce
));
...
...
@@ -186,7 +186,7 @@ class UnixPath
// use this path for permission checks
String
getPathForPermissionCheck
()
{
if
(
getFileSystem
().
needToResolveAgainstDefaultDirectory
())
{
return
new
String
(
getByteArrayForSysCalls
());
return
Util
.
to
String
(
getByteArrayForSysCalls
());
}
else
{
return
toString
();
}
...
...
@@ -758,7 +758,7 @@ class UnixPath
public
String
toString
()
{
// OK if two or more threads create a String
if
(
stringValue
==
null
)
{
stringValue
=
fs
.
normalizeJavaPath
(
new
String
(
path
));
// platform encoding
stringValue
=
fs
.
normalizeJavaPath
(
Util
.
to
String
(
path
));
// platform encoding
}
return
stringValue
;
}
...
...
src/solaris/classes/sun/nio/fs/UnixUserPrincipals.java
浏览文件 @
7142b15a
...
...
@@ -115,7 +115,7 @@ class UnixUserPrincipals {
static
User
fromUid
(
int
uid
)
{
String
name
=
null
;
try
{
name
=
new
String
(
getpwuid
(
uid
));
name
=
Util
.
to
String
(
getpwuid
(
uid
));
}
catch
(
UnixException
x
)
{
name
=
Integer
.
toString
(
uid
);
}
...
...
@@ -126,7 +126,7 @@ class UnixUserPrincipals {
static
Group
fromGid
(
int
gid
)
{
String
name
=
null
;
try
{
name
=
new
String
(
getgrgid
(
gid
));
name
=
Util
.
to
String
(
getgrgid
(
gid
));
}
catch
(
UnixException
x
)
{
name
=
Integer
.
toString
(
gid
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录