Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
8106d5d2
D
dragonwell8_langtools
项目概览
openanolis
/
dragonwell8_langtools
通知
0
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_langtools
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
8106d5d2
编写于
1月 28, 2011
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7006126: (fs) Updates to file system API (1/2011)
Reviewed-by: jjg
上级
64f8eda3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
21 addition
and
28 deletion
+21
-28
src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java
...classes/com/sun/tools/javac/nio/JavacPathFileManager.java
+10
-13
src/share/classes/com/sun/tools/javac/nio/PathFileObject.java
...share/classes/com/sun/tools/javac/nio/PathFileObject.java
+10
-13
test/tools/javac/nio/compileTest/CompileTest.java
test/tools/javac/nio/compileTest/CompileTest.java
+1
-2
未找到文件。
src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java
浏览文件 @
8106d5d2
...
...
@@ -39,7 +39,6 @@ import java.nio.file.FileVisitOption;
import
java.nio.file.FileVisitResult
;
import
java.nio.file.Path
;
import
java.nio.file.SimpleFileVisitor
;
import
java.nio.file.attribute.Attributes
;
import
java.nio.file.attribute.BasicFileAttributes
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
...
...
@@ -223,9 +222,7 @@ public class JavacPathFileManager extends BaseFileManager implements PathFileMan
Path
path
=
pathIter
.
next
();
if
(
pathIter
.
hasNext
())
throw
new
IllegalArgumentException
(
"path too long for directory"
);
if
(!
path
.
exists
())
throw
new
FileNotFoundException
(
path
+
": does not exist"
);
else
if
(!
isDirectory
(
path
))
if
(!
isDirectory
(
path
))
throw
new
IOException
(
path
+
": not a directory"
);
}
...
...
@@ -326,7 +323,7 @@ public class JavacPathFileManager extends BaseFileManager implements PathFileMan
private
void
list
(
Path
path
,
String
packageName
,
final
Set
<
Kind
>
kinds
,
boolean
recurse
,
final
ListBuffer
<
JavaFileObject
>
results
)
throws
IOException
{
if
(!
path
.
exists
(
))
if
(!
Files
.
exists
(
path
))
return
;
final
Path
pathDir
;
...
...
@@ -341,7 +338,7 @@ public class JavacPathFileManager extends BaseFileManager implements PathFileMan
String
sep
=
path
.
getFileSystem
().
getSeparator
();
Path
packageDir
=
packageName
.
isEmpty
()
?
pathDir
:
pathDir
.
resolve
(
packageName
.
replace
(
"."
,
sep
));
if
(!
packageDir
.
exists
(
))
if
(!
Files
.
exists
(
packageDir
))
return
;
/* Alternate impl of list, superceded by use of Files.walkFileTree */
...
...
@@ -353,7 +350,7 @@ public class JavacPathFileManager extends BaseFileManager implements PathFileMan
// DirectoryStream<Path> ds = dir.newDirectoryStream();
// try {
// for (Path p: ds) {
// String name = p.getName().toString();
// String name = p.get
File
Name().toString();
// if (isDirectory(p)) {
// if (recurse && SourceVersion.isIdentifier(name)) {
// queue.add(p);
...
...
@@ -376,7 +373,7 @@ public class JavacPathFileManager extends BaseFileManager implements PathFileMan
new
SimpleFileVisitor
<
Path
>()
{
@Override
public
FileVisitResult
preVisitDirectory
(
Path
dir
,
BasicFileAttributes
attrs
)
{
Path
name
=
dir
.
getName
();
Path
name
=
dir
.
get
File
Name
();
if
(
name
==
null
||
SourceVersion
.
isIdentifier
(
name
.
toString
()))
// JSR 292?
return
FileVisitResult
.
CONTINUE
;
else
...
...
@@ -385,7 +382,7 @@ public class JavacPathFileManager extends BaseFileManager implements PathFileMan
@Override
public
FileVisitResult
visitFile
(
Path
file
,
BasicFileAttributes
attrs
)
{
if
(
attrs
.
isRegularFile
()
&&
kinds
.
contains
(
getKind
(
file
.
getName
().
toString
())))
{
if
(
attrs
.
isRegularFile
()
&&
kinds
.
contains
(
getKind
(
file
.
get
File
Name
().
toString
())))
{
JavaFileObject
fe
=
PathFileObject
.
createDirectoryPathFileObject
(
JavacPathFileManager
.
this
,
file
,
pathDir
);
...
...
@@ -431,13 +428,13 @@ public class JavacPathFileManager extends BaseFileManager implements PathFileMan
for
(
Path
p:
getLocation
(
location
))
{
if
(
isDirectory
(
p
))
{
Path
f
=
resolve
(
p
,
relativePath
);
if
(
f
.
exists
(
))
if
(
Files
.
exists
(
f
))
return
PathFileObject
.
createDirectoryPathFileObject
(
this
,
f
,
p
);
}
else
{
FileSystem
fs
=
getFileSystem
(
p
);
if
(
fs
!=
null
)
{
Path
file
=
getPath
(
fs
,
relativePath
);
if
(
file
.
exists
(
))
if
(
Files
.
exists
(
file
))
return
PathFileObject
.
createJarPathFileObject
(
this
,
file
);
}
}
...
...
@@ -504,7 +501,7 @@ public class JavacPathFileManager extends BaseFileManager implements PathFileMan
private
FileSystem
getFileSystem
(
Path
p
)
throws
IOException
{
FileSystem
fs
=
fileSystems
.
get
(
p
);
if
(
fs
==
null
)
{
fs
=
FileSystems
.
newFileSystem
(
p
,
Collections
.<
String
,
Void
>
emptyMap
(),
null
);
fs
=
FileSystems
.
newFileSystem
(
p
,
null
);
fileSystems
.
put
(
p
,
fs
);
}
return
fs
;
...
...
@@ -530,7 +527,7 @@ public class JavacPathFileManager extends BaseFileManager implements PathFileMan
}
private
static
boolean
isDirectory
(
Path
path
)
throws
IOException
{
BasicFileAttributes
attrs
=
Attributes
.
readBasicFileAttributes
(
path
);
BasicFileAttributes
attrs
=
Files
.
readAttributes
(
path
,
BasicFileAttributes
.
class
);
return
attrs
.
isDirectory
();
}
...
...
src/share/classes/com/sun/tools/javac/nio/PathFileObject.java
浏览文件 @
8106d5d2
...
...
@@ -38,7 +38,6 @@ import java.nio.CharBuffer;
import
java.nio.charset.CharsetDecoder
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.attribute.Attributes
;
import
java.nio.file.attribute.BasicFileAttributes
;
import
javax.lang.model.element.Modifier
;
import
javax.lang.model.element.NestingKind
;
...
...
@@ -153,7 +152,7 @@ abstract class PathFileObject implements JavaFileObject {
@Override
public
Kind
getKind
()
{
return
BaseFileManager
.
getKind
(
path
.
getName
().
toString
());
return
BaseFileManager
.
getKind
(
path
.
get
File
Name
().
toString
());
}
@Override
...
...
@@ -164,14 +163,14 @@ abstract class PathFileObject implements JavaFileObject {
return
false
;
}
String
sn
=
simpleName
+
kind
.
extension
;
String
pn
=
path
.
getName
().
toString
();
String
pn
=
path
.
get
File
Name
().
toString
();
if
(
pn
.
equals
(
sn
))
{
return
true
;
}
if
(
pn
.
equalsIgnoreCase
(
sn
))
{
try
{
// allow for Windows
return
path
.
toRealPath
(
false
).
getName
().
toString
().
equals
(
sn
);
return
path
.
toRealPath
(
false
).
get
File
Name
().
toString
().
equals
(
sn
);
}
catch
(
IOException
e
)
{
}
}
...
...
@@ -200,13 +199,13 @@ abstract class PathFileObject implements JavaFileObject {
@Override
public
InputStream
openInputStream
()
throws
IOException
{
return
path
.
newInputStream
(
);
return
Files
.
newInputStream
(
path
);
}
@Override
public
OutputStream
openOutputStream
()
throws
IOException
{
ensureParentDirectoriesExist
();
return
path
.
newOutputStream
(
);
return
Files
.
newOutputStream
(
path
);
}
@Override
...
...
@@ -242,14 +241,13 @@ abstract class PathFileObject implements JavaFileObject {
@Override
public
Writer
openWriter
()
throws
IOException
{
ensureParentDirectoriesExist
();
return
new
OutputStreamWriter
(
path
.
newOutputStream
(
),
fileManager
.
getEncodingName
());
return
new
OutputStreamWriter
(
Files
.
newOutputStream
(
path
),
fileManager
.
getEncodingName
());
}
@Override
public
long
getLastModified
()
{
try
{
BasicFileAttributes
attrs
=
Attributes
.
readBasicFileAttributes
(
path
);
return
attrs
.
lastModifiedTime
().
toMillis
();
return
Files
.
getLastModifiedTime
(
path
).
toMillis
();
}
catch
(
IOException
e
)
{
return
-
1
;
}
...
...
@@ -258,7 +256,7 @@ abstract class PathFileObject implements JavaFileObject {
@Override
public
boolean
delete
()
{
try
{
path
.
delete
(
);
Files
.
delete
(
path
);
return
true
;
}
catch
(
IOException
e
)
{
return
false
;
...
...
@@ -267,7 +265,7 @@ abstract class PathFileObject implements JavaFileObject {
public
boolean
isSameFile
(
PathFileObject
other
)
{
try
{
return
path
.
isSameFile
(
other
.
path
);
return
Files
.
isSameFile
(
path
,
other
.
path
);
}
catch
(
IOException
e
)
{
return
false
;
}
...
...
@@ -296,8 +294,7 @@ abstract class PathFileObject implements JavaFileObject {
private
long
size
()
{
try
{
BasicFileAttributes
attrs
=
Attributes
.
readBasicFileAttributes
(
path
);
return
attrs
.
size
();
return
Files
.
size
(
path
);
}
catch
(
IOException
e
)
{
return
-
1
;
}
...
...
test/tools/javac/nio/compileTest/CompileTest.java
浏览文件 @
8106d5d2
...
...
@@ -84,8 +84,7 @@ public class CompileTest {
System
.
err
.
println
(
"Test "
+
count
+
" "
+
Arrays
.
asList
(
opts
)
+
" "
+
className
);
Path
testSrcDir
=
Paths
.
get
(
System
.
getProperty
(
"test.src"
));
Path
testClassesDir
=
Paths
.
get
(
System
.
getProperty
(
"test.classes"
));
Path
classes
=
Paths
.
get
(
"classes."
+
count
);
classes
.
createDirectory
();
Path
classes
=
Files
.
createDirectory
(
Paths
.
get
(
"classes."
+
count
));
Context
ctx
=
new
Context
();
PathFileManager
fm
=
new
JavacPathFileManager
(
ctx
,
true
,
null
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录