Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
73924d21
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看板
提交
73924d21
编写于
2月 10, 2014
作者:
S
sla
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8033917: Keep track of file paths in file streams and channels for instrumentation purposes
Reviewed-by: alanb, dsamersoff
上级
558d8d76
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
62 addition
and
21 deletion
+62
-21
src/share/classes/java/io/FileInputStream.java
src/share/classes/java/io/FileInputStream.java
+9
-1
src/share/classes/java/io/FileOutputStream.java
src/share/classes/java/io/FileOutputStream.java
+9
-1
src/share/classes/java/io/RandomAccessFile.java
src/share/classes/java/io/RandomAccessFile.java
+8
-1
src/share/classes/sun/nio/ch/FileChannelImpl.java
src/share/classes/sun/nio/ch/FileChannelImpl.java
+22
-7
src/solaris/classes/sun/nio/fs/SolarisUserDefinedFileAttributeView.java
...asses/sun/nio/fs/SolarisUserDefinedFileAttributeView.java
+2
-2
src/solaris/classes/sun/nio/fs/UnixChannelFactory.java
src/solaris/classes/sun/nio/fs/UnixChannelFactory.java
+3
-3
src/windows/classes/sun/nio/fs/WindowsChannelFactory.java
src/windows/classes/sun/nio/fs/WindowsChannelFactory.java
+9
-6
未找到文件。
src/share/classes/java/io/FileInputStream.java
浏览文件 @
73924d21
...
...
@@ -51,6 +51,12 @@ class FileInputStream extends InputStream
/* File Descriptor - handle to the open file */
private
final
FileDescriptor
fd
;
/**
* The path of the referenced file
* (null if the stream is created with a file descriptor)
*/
private
final
String
path
;
private
FileChannel
channel
=
null
;
private
final
Object
closeLock
=
new
Object
();
...
...
@@ -128,6 +134,7 @@ class FileInputStream extends InputStream
}
fd
=
new
FileDescriptor
();
fd
.
attach
(
this
);
path
=
name
;
open
(
name
);
}
...
...
@@ -164,6 +171,7 @@ class FileInputStream extends InputStream
security
.
checkRead
(
fdObj
);
}
fd
=
fdObj
;
path
=
null
;
/*
* FileDescriptor is being shared by streams.
...
...
@@ -349,7 +357,7 @@ class FileInputStream extends InputStream
public
FileChannel
getChannel
()
{
synchronized
(
this
)
{
if
(
channel
==
null
)
{
channel
=
FileChannelImpl
.
open
(
fd
,
true
,
false
,
this
);
channel
=
FileChannelImpl
.
open
(
fd
,
path
,
true
,
false
,
this
);
}
return
channel
;
}
...
...
src/share/classes/java/io/FileOutputStream.java
浏览文件 @
73924d21
...
...
@@ -67,6 +67,12 @@ class FileOutputStream extends OutputStream
*/
private
FileChannel
channel
;
/**
* The path of the referenced file
* (null if the stream is created with a file descriptor)
*/
private
final
String
path
;
private
final
Object
closeLock
=
new
Object
();
private
volatile
boolean
closed
=
false
;
...
...
@@ -202,6 +208,7 @@ class FileOutputStream extends OutputStream
this
.
fd
=
new
FileDescriptor
();
fd
.
attach
(
this
);
this
.
append
=
append
;
this
.
path
=
name
;
open
(
name
,
append
);
}
...
...
@@ -239,6 +246,7 @@ class FileOutputStream extends OutputStream
}
this
.
fd
=
fdObj
;
this
.
append
=
false
;
this
.
path
=
null
;
fd
.
attach
(
this
);
}
...
...
@@ -376,7 +384,7 @@ class FileOutputStream extends OutputStream
public
FileChannel
getChannel
()
{
synchronized
(
this
)
{
if
(
channel
==
null
)
{
channel
=
FileChannelImpl
.
open
(
fd
,
false
,
true
,
append
,
this
);
channel
=
FileChannelImpl
.
open
(
fd
,
path
,
false
,
true
,
append
,
this
);
}
return
channel
;
}
...
...
src/share/classes/java/io/RandomAccessFile.java
浏览文件 @
73924d21
...
...
@@ -62,6 +62,12 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
private
FileChannel
channel
=
null
;
private
boolean
rw
;
/**
* The path of the referenced file
* (null if the stream is created with a file descriptor)
*/
private
final
String
path
;
private
Object
closeLock
=
new
Object
();
private
volatile
boolean
closed
=
false
;
...
...
@@ -233,6 +239,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
}
fd
=
new
FileDescriptor
();
fd
.
attach
(
this
);
path
=
name
;
open
(
name
,
imode
);
}
...
...
@@ -272,7 +279,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
public
final
FileChannel
getChannel
()
{
synchronized
(
this
)
{
if
(
channel
==
null
)
{
channel
=
FileChannelImpl
.
open
(
fd
,
true
,
rw
,
this
);
channel
=
FileChannelImpl
.
open
(
fd
,
path
,
true
,
rw
,
this
);
}
return
channel
;
}
...
...
src/share/classes/sun/nio/ch/FileChannelImpl.java
浏览文件 @
73924d21
...
...
@@ -29,10 +29,20 @@ import java.io.FileDescriptor;
import
java.io.IOException
;
import
java.nio.ByteBuffer
;
import
java.nio.MappedByteBuffer
;
import
java.nio.channels.*
;
import
java.nio.channels.ClosedByInterruptException
;
import
java.nio.channels.ClosedChannelException
;
import
java.nio.channels.FileChannel
;
import
java.nio.channels.FileLock
;
import
java.nio.channels.FileLockInterruptionException
;
import
java.nio.channels.NonReadableChannelException
;
import
java.nio.channels.NonWritableChannelException
;
import
java.nio.channels.OverlappingFileLockException
;
import
java.nio.channels.ReadableByteChannel
;
import
java.nio.channels.WritableByteChannel
;
import
java.security.AccessController
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.security.AccessController
;
import
sun.misc.Cleaner
;
import
sun.security.action.GetPropertyAction
;
...
...
@@ -56,13 +66,17 @@ public class FileChannelImpl
// Required to prevent finalization of creating stream (immutable)
private
final
Object
parent
;
// The path of the referenced file
// (null if the parent stream is created with a file descriptor)
private
final
String
path
;
// Thread-safe set of IDs of native threads, for signalling
private
final
NativeThreadSet
threads
=
new
NativeThreadSet
(
2
);
// Lock for operations involving position and size
private
final
Object
positionLock
=
new
Object
();
private
FileChannelImpl
(
FileDescriptor
fd
,
boolean
readable
,
private
FileChannelImpl
(
FileDescriptor
fd
,
String
path
,
boolean
readable
,
boolean
writable
,
boolean
append
,
Object
parent
)
{
this
.
fd
=
fd
;
...
...
@@ -70,23 +84,24 @@ public class FileChannelImpl
this
.
writable
=
writable
;
this
.
append
=
append
;
this
.
parent
=
parent
;
this
.
path
=
path
;
this
.
nd
=
new
FileDispatcherImpl
(
append
);
}
// Used by FileInputStream.getChannel() and RandomAccessFile.getChannel()
public
static
FileChannel
open
(
FileDescriptor
fd
,
public
static
FileChannel
open
(
FileDescriptor
fd
,
String
path
,
boolean
readable
,
boolean
writable
,
Object
parent
)
{
return
new
FileChannelImpl
(
fd
,
readable
,
writable
,
false
,
parent
);
return
new
FileChannelImpl
(
fd
,
path
,
readable
,
writable
,
false
,
parent
);
}
// Used by FileOutputStream.getChannel
public
static
FileChannel
open
(
FileDescriptor
fd
,
public
static
FileChannel
open
(
FileDescriptor
fd
,
String
path
,
boolean
readable
,
boolean
writable
,
boolean
append
,
Object
parent
)
{
return
new
FileChannelImpl
(
fd
,
readable
,
writable
,
append
,
parent
);
return
new
FileChannelImpl
(
fd
,
path
,
readable
,
writable
,
append
,
parent
);
}
private
void
ensureOpen
()
throws
IOException
{
...
...
src/solaris/classes/sun/nio/fs/SolarisUserDefinedFileAttributeView.java
浏览文件 @
73924d21
...
...
@@ -149,7 +149,7 @@ class SolarisUserDefinedFileAttributeView
int
afd
=
openat
(
fd
,
nameAsBytes
(
file
,
name
),
(
O_RDONLY
|
O_XATTR
),
0
);
// wrap with channel
FileChannel
fc
=
UnixChannelFactory
.
newFileChannel
(
afd
,
true
,
false
);
FileChannel
fc
=
UnixChannelFactory
.
newFileChannel
(
afd
,
file
.
toString
(),
true
,
false
);
// read to EOF (nothing we can do if I/O error occurs)
try
{
...
...
@@ -190,7 +190,7 @@ class SolarisUserDefinedFileAttributeView
UnixFileModeAttribute
.
ALL_PERMISSIONS
);
// wrap with channel
FileChannel
fc
=
UnixChannelFactory
.
newFileChannel
(
afd
,
false
,
true
);
FileChannel
fc
=
UnixChannelFactory
.
newFileChannel
(
afd
,
f
ile
.
toString
(),
f
alse
,
true
);
// write value (nothing we can do if I/O error occurs)
try
{
...
...
src/solaris/classes/sun/nio/fs/UnixChannelFactory.java
浏览文件 @
73924d21
...
...
@@ -100,10 +100,10 @@ class UnixChannelFactory {
/**
* Constructs a file channel from an existing (open) file descriptor
*/
static
FileChannel
newFileChannel
(
int
fd
,
boolean
reading
,
boolean
writing
)
{
static
FileChannel
newFileChannel
(
int
fd
,
String
path
,
boolean
reading
,
boolean
writing
)
{
FileDescriptor
fdObj
=
new
FileDescriptor
();
fdAccess
.
set
(
fdObj
,
fd
);
return
FileChannelImpl
.
open
(
fdObj
,
reading
,
writing
,
null
);
return
FileChannelImpl
.
open
(
fdObj
,
path
,
reading
,
writing
,
null
);
}
/**
...
...
@@ -134,7 +134,7 @@ class UnixChannelFactory {
throw
new
IllegalArgumentException
(
"APPEND + TRUNCATE_EXISTING not allowed"
);
FileDescriptor
fdObj
=
open
(
dfd
,
path
,
pathForPermissionCheck
,
flags
,
mode
);
return
FileChannelImpl
.
open
(
fdObj
,
flags
.
read
,
flags
.
write
,
flags
.
append
,
null
);
return
FileChannelImpl
.
open
(
fdObj
,
path
.
toString
(),
flags
.
read
,
flags
.
write
,
flags
.
append
,
null
);
}
/**
...
...
src/windows/classes/sun/nio/fs/WindowsChannelFactory.java
浏览文件 @
73924d21
...
...
@@ -25,19 +25,22 @@
package
sun.nio.fs
;
import
java.nio.file.*
;
import
java.nio.channels.*
;
import
java.io.FileDescriptor
;
import
java.io.IOException
;
import
java.util.*
;
import
java.nio.channels.AsynchronousFileChannel
;
import
java.nio.channels.FileChannel
;
import
java.nio.file.LinkOption
;
import
java.nio.file.OpenOption
;
import
java.nio.file.StandardOpenOption
;
import
java.util.Set
;
import
com.sun.nio.file.ExtendedOpenOption
;
import
sun.misc.JavaIOFileDescriptorAccess
;
import
sun.misc.SharedSecrets
;
import
sun.nio.ch.FileChannelImpl
;
import
sun.nio.ch.ThreadPool
;
import
sun.nio.ch.WindowsAsynchronousFileChannelImpl
;
import
sun.misc.SharedSecrets
;
import
sun.misc.JavaIOFileDescriptorAccess
;
import
static
sun
.
nio
.
fs
.
WindowsNativeDispatcher
.*;
import
static
sun
.
nio
.
fs
.
WindowsConstants
.*;
...
...
@@ -157,7 +160,7 @@ class WindowsChannelFactory {
throw
new
IllegalArgumentException
(
"APPEND + TRUNCATE_EXISTING not allowed"
);
FileDescriptor
fdObj
=
open
(
pathForWindows
,
pathToCheck
,
flags
,
pSecurityDescriptor
);
return
FileChannelImpl
.
open
(
fdObj
,
flags
.
read
,
flags
.
write
,
flags
.
append
,
null
);
return
FileChannelImpl
.
open
(
fdObj
,
pathForWindows
,
flags
.
read
,
flags
.
write
,
flags
.
append
,
null
);
}
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录