Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
1889def4
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
3
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1889def4
编写于
8月 15, 2012
作者:
R
robm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6931128: (spec) File attribute tests fail when run as root.
Reviewed-by: alanb
上级
39996608
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
105 addition
and
21 deletion
+105
-21
src/share/classes/java/io/File.java
src/share/classes/java/io/File.java
+37
-14
test/java/io/File/Basic.java
test/java/io/File/Basic.java
+3
-3
test/java/io/File/SetAccess.java
test/java/io/File/SetAccess.java
+8
-1
test/java/io/File/SetReadOnly.java
test/java/io/File/SetReadOnly.java
+8
-1
test/java/io/File/SymLinks.java
test/java/io/File/SymLinks.java
+4
-2
test/java/io/File/Util.java
test/java/io/File/Util.java
+45
-0
未找到文件。
src/share/classes/java/io/File.java
浏览文件 @
1889def4
/*
* Copyright (c) 1994, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 201
2
, 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
...
...
@@ -711,7 +711,10 @@ public class File
/**
* Tests whether the application can read the file denoted by this
* abstract pathname.
* abstract pathname. On some platforms it may be possible to start the
* Java virtual machine with special privileges that allow it to read
* files that are marked as unreadable. Consequently this method may return
* {@code true} even though the file does not have read permissions.
*
* @return <code>true</code> if and only if the file specified by this
* abstract pathname exists <em>and</em> can be read by the
...
...
@@ -732,7 +735,10 @@ public class File
/**
* Tests whether the application can modify the file denoted by this
* abstract pathname.
* abstract pathname. On some platforms it may be possible to start the
* Java virtual machine with special privileges that allow it to modify
* files that are marked read-only. Consequently this method may return
* {@code true} even though the file is marked read-only.
*
* @return <code>true</code> if and only if the file system actually
* contains a file denoted by this abstract pathname <em>and</em>
...
...
@@ -1352,8 +1358,10 @@ public class File
/**
* Marks the file or directory named by this abstract pathname so that
* only read operations are allowed. After invoking this method the file
* or directory is guaranteed not to change until it is either deleted or
* marked to allow write access. Whether or not a read-only file or
* or directory will not change until it is either deleted or marked
* to allow write access. On some platforms it may be possible to start the
* Java virtual machine with special privileges that allow it to modify
* files that are marked read-only. Whether or not a read-only file or
* directory may be deleted depends upon the underlying system.
*
* @return <code>true</code> if and only if the operation succeeded;
...
...
@@ -1376,7 +1384,9 @@ public class File
/**
* Sets the owner's or everybody's write permission for this abstract
* pathname.
* pathname. On some platforms it may be possible to start the Java virtual
* machine with special privileges that allow it to modify files that
* disallow write operations.
*
* <p> The {@link java.nio.file.Files} class defines methods that operate on
* file attributes including file permissions. This may be used when finer
...
...
@@ -1414,7 +1424,9 @@ public class File
/**
* A convenience method to set the owner's write permission for this abstract
* pathname.
* pathname. On some platforms it may be possible to start the Java virtual
* machine with special privileges that allow it to modify files that
* disallow write operations.
*
* <p> An invocation of this method of the form <tt>file.setWritable(arg)</tt>
* behaves in exactly the same way as the invocation
...
...
@@ -1443,7 +1455,9 @@ public class File
/**
* Sets the owner's or everybody's read permission for this abstract
* pathname.
* pathname. On some platforms it may be possible to start the Java virtual
* machine with special privileges that allow it to read files that are
* marked as unreadable.
*
* <p> The {@link java.nio.file.Files} class defines methods that operate on
* file attributes including file permissions. This may be used when finer
...
...
@@ -1484,7 +1498,9 @@ public class File
/**
* A convenience method to set the owner's read permission for this abstract
* pathname.
* pathname. On some platforms it may be possible to start the Java virtual
* machine with special privileges that allow it to read files that that are
* marked as unreadable.
*
* <p>An invocation of this method of the form <tt>file.setReadable(arg)</tt>
* behaves in exactly the same way as the invocation
...
...
@@ -1516,7 +1532,9 @@ public class File
/**
* Sets the owner's or everybody's execute permission for this abstract
* pathname.
* pathname. On some platforms it may be possible to start the Java virtual
* machine with special privileges that allow it to execute files that are
* not marked executable.
*
* <p> The {@link java.nio.file.Files} class defines methods that operate on
* file attributes including file permissions. This may be used when finer
...
...
@@ -1556,8 +1574,10 @@ public class File
}
/**
* A convenience method to set the owner's execute permission for this abstract
* pathname.
* A convenience method to set the owner's execute permission for this
* abstract pathname. On some platforms it may be possible to start the Java
* virtual machine with special privileges that allow it to execute files
* that are not marked executable.
*
* <p>An invocation of this method of the form <tt>file.setExcutable(arg)</tt>
* behaves in exactly the same way as the invocation
...
...
@@ -1589,7 +1609,10 @@ public class File
/**
* Tests whether the application can execute the file denoted by this
* abstract pathname.
* abstract pathname. On some platforms it may be possible to start the
* Java virtual machine with special privileges that allow it to execute
* files that are not marked executable. Consequently this method may return
* {@code true} even though the file does not have execute permissions.
*
* @return <code>true</code> if and only if the abstract pathname exists
* <em>and</em> the application is allowed to execute the file
...
...
test/java/io/File/Basic.java
浏览文件 @
1889def4
/*
* Copyright (c) 1998, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 201
2
, 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,7 +25,7 @@
@bug 4165666 4203706 4288670 4290024
@summary Basic heartbeat test for File methods that access the filesystem
@build Basic
@build Basic
Util
@run shell basic.sh
*/
...
...
@@ -73,7 +73,7 @@ public class Basic {
if
(!
f
.
isFile
())
fail
(
f
,
"is not a file"
);
if
(
f
.
isDirectory
())
fail
(
f
,
"is a directory"
);
if
(!
f
.
canRead
())
fail
(
f
,
"is not readable"
);
if
(
f
.
canWrite
()
!=
writeable
)
if
(
!
Util
.
isPrivileged
()
&&
f
.
canWrite
()
!=
writeable
)
fail
(
f
,
writeable
?
"is not writeable"
:
"is writeable"
);
int
rwLen
=
6
;
if
(
f
.
length
()
!=
length
)
fail
(
f
,
"has wrong length"
);
...
...
test/java/io/File/SetAccess.java
浏览文件 @
1889def4
/*
* Copyright (c) 2005, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 201
2
, 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
...
...
@@ -24,6 +24,8 @@
/* @test
@bug 4167472 5097703 6216563 6284003 6728842 6464744
@summary Basic test for setWritable/Readable/Executable methods
@build SetAccess Util
@run main SetAccess
*/
import
java.io.*
;
...
...
@@ -32,6 +34,11 @@ import java.nio.file.attribute.*;
public
class
SetAccess
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
if
(
Util
.
isPrivileged
())
{
System
.
out
.
println
(
"Unable to test file permissions when running with privileges"
);
return
;
}
File
d
=
new
File
(
System
.
getProperty
(
"test.dir"
,
"."
));
File
f
=
new
File
(
d
,
"x.SetAccessPermission"
);
...
...
test/java/io/File/SetReadOnly.java
浏览文件 @
1889def4
/*
* Copyright (c) 1998, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 201
2
, 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
...
...
@@ -24,6 +24,8 @@
/* @test
@bug 4091757 4939819 6728842
@summary Basic test for setReadOnly method
@build SetReadOnly Util
@run main SetReadOnly
*/
import
java.io.*
;
...
...
@@ -32,6 +34,11 @@ import java.io.*;
public
class
SetReadOnly
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
if
(
Util
.
isPrivileged
())
{
System
.
out
.
println
(
"Unable to test file permissions when running with privileges"
);
return
;
}
File
d
=
new
File
(
System
.
getProperty
(
"test.dir"
,
"."
));
File
f
=
new
File
(
d
,
"x.SetReadOnly"
);
...
...
test/java/io/File/SymLinks.java
浏览文件 @
1889def4
/*
* Copyright (c) 2009, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 201
2
, 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
...
...
@@ -24,6 +24,8 @@
/* @test
* @bug 6595866
* @summary Test java.io.File operations with sym links
* @build SymLinks Util
* @run main SymLinks
*/
import
java.io.*
;
...
...
@@ -338,7 +340,7 @@ public class SymLinks {
assertTrue
(
link2link2file
.
canRead
());
assertTrue
(
link2link2file
.
canWrite
());
if
(
file
.
setReadOnly
())
{
if
(
!
Util
.
isPrivileged
()
&&
file
.
setReadOnly
())
{
assertFalse
(
file
.
canWrite
());
assertFalse
(
link2file
.
canWrite
());
assertFalse
(
link2link2file
.
canWrite
());
...
...
test/java/io/File/Util.java
0 → 100644
浏览文件 @
1889def4
/*
* Copyright (c) 2012, 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.File
;
/**
* Utility class used by tests for java.io.File.
*/
class
Util
{
private
Util
()
{
}
/**
* Returns {@code true} if the Java virtual machine is running with
* privileges (loosely defined here as have write access to /etc/passwd).
*/
static
boolean
isPrivileged
()
{
String
osname
=
System
.
getProperty
(
"os.name"
);
if
(
osname
.
startsWith
(
"Windows"
))
return
false
;
return
(
new
File
(
"/etc/passwd"
)).
canWrite
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录