Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
12a6372d
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看板
提交
12a6372d
编写于
6月 22, 2010
作者:
O
ohair
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6933622: Duplicate class files in rt.jar and charsets.jar
6895003: JarReorder is not excluding a requested file. Reviewed-by: jjg
上级
6f42644e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
178 addition
and
182 deletion
+178
-182
make/common/Release.gmk
make/common/Release.gmk
+2
-0
make/tools/src/build/tools/jarreorder/JarReorder.java
make/tools/src/build/tools/jarreorder/JarReorder.java
+176
-179
test/ProblemList.txt
test/ProblemList.txt
+0
-3
未找到文件。
make/common/Release.gmk
浏览文件 @
12a6372d
...
...
@@ -549,6 +549,7 @@ DIRDIFF_JARFILE = $(BUILDTOOLJARDIR)/dirdiff.jar
######################################################
# List of directories in classes directory that should NOT be in rt.jar
# sun/nio/cs/ext/ will go into charsets.jar
######################################################
NOT_RT_JAR_LIST = $(ABS_TEMPDIR)/not_rt_jar.list
...
...
@@ -571,6 +572,7 @@ $(NOT_RT_JAR_LIST): FRC
$(ECHO) "META-INF/services/com.sun.tools.xjc.Plugin" >> $@
$(ECHO) "com/sun/tools/" >> $@
$(ECHO) "sun/jvmstat/" >> $@
$(ECHO) "sun/nio/cs/ext/" >> $@
$(ECHO) "sun/rmi/rmic/" >> $@
$(ECHO) "sun/tools/asm/" >> $@
$(ECHO) "sun/tools/java/" >> $@
...
...
make/tools/src/build/tools/jarreorder/JarReorder.java
浏览文件 @
12a6372d
...
...
@@ -28,7 +28,6 @@
* combine with an argument list of files and directories, and
* write a list of items to be included in a jar file.
*/
package
build.tools.jarreorder
;
import
java.io.BufferedReader
;
...
...
@@ -36,74 +35,68 @@ import java.io.File;
import
java.io.FileNotFoundException
;
import
java.io.FileReader
;
import
java.io.IOException
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.Collections
;
import
java.util.HashSet
;
import
java.util.Vector
;
import
java.io.PrintStream
;
import
java.io.FileOutputStream
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Set
;
public
class
JarReorder
{
// To deal with output
private
static
PrintStream
out
;
private
final
static
boolean
useTopDir
=
false
;
private
PrintStream
out
;
private
static
void
usage
()
{
private
void
usage
()
{
String
help
;
help
=
"Usage: jar JarReorder [-o <outputfile>] <order_list> <exclude_list> <file> ...\n"
+
" order_list is a file containing names of files to load\n"
+
" in order at the end of a jar file.\n"
+
" exclude_list is a file containing names of files/directories\n"
+
" NOT to be included in a jar file.\n"
;
if
(
useTopDir
)
help
+=
" top_dir is the top of the directory structure to be searched;\n"
+
" the contents of the lists and remaining arguments are\n"
+
" relative to this.\n"
;
help
+=
"\n"
+
"The order_list or exclude_list may be replaced by a \"_\" if no\n"
+
"data is to be provided.\n"
+
"\n"
+
" The remaining arguments are files or directories to be included\n"
+
" in a jar file, from which will be excluded thse entries which\n"
+
" appear in the exclude list.\n"
;
"Usage: jar JarReorder [-o <outputfile>] <order_list> <exclude_list> <file> ...\n"
+
" order_list is a file containing names of files to load\n"
+
" in order at the end of a jar file unless\n"
+
" excluded in the exclude list.\n"
+
" exclude_list is a file containing names of files/directories\n"
+
" NOT to be included in a jar file.\n"
+
"\n"
+
"The order_list or exclude_list may be replaced by a \"-\" if no\n"
+
"data is to be provided.\n"
+
"\n"
+
" The remaining arguments are files or directories to be included\n"
+
" in a jar file, from which will be excluded those entries which\n"
+
" appear in the exclude list.\n"
;
System
.
err
.
println
(
help
);
System
.
exit
(
1
);
}
/*
* Create
a list of files
to be included in a jar file, such that the
*
some the files
will appear in a specific order, and allowing certain
* Create
the file list
to be included in a jar file, such that the
*
list
will appear in a specific order, and allowing certain
* files and directories to be excluded.
*
* Command
line
arguments are
* Command
path
arguments are
* - optional -o outputfile
* - name of a file containing a
lis
t of files to be included in a jar file.
* - name of a file containing a
lis
t of files (or directories) to be
* - name of a file containing a
se
t of files to be included in a jar file.
* - name of a file containing a
se
t of files (or directories) to be
* excluded from the jar file.
* - names of files or directories to be searched for files to include
* in the jar file.
*/
public
static
void
main
(
String
[]
args
)
{
JarReorder
jr
=
new
JarReorder
();
jr
.
run
(
args
);
}
private
void
run
(
String
args
[])
{
HashMap
filesExcluded
=
new
HashMap
();
Vector
filesIncluded
=
new
Vector
();
int
fileArgs
;
String
topDirName
=
""
;
int
arglen
=
args
.
length
;
int
argpos
=
0
;
// Look for "-o outputfilename" option
if
(
arglen
>
0
)
{
if
(
arglen
>=
2
&&
args
[
0
].
equals
(
"-o"
)
)
{
if
(
arglen
>
0
)
{
if
(
arglen
>=
2
&&
args
[
0
].
equals
(
"-o"
)
)
{
try
{
out
=
new
PrintStream
(
new
FileOutputStream
(
args
[
1
]));
}
catch
(
FileNotFoundException
e
)
{
}
catch
(
FileNotFoundException
e
)
{
System
.
err
.
println
(
"Error: "
+
e
.
getMessage
());
e
.
printStackTrace
(
System
.
err
);
System
.
exit
(
1
);
...
...
@@ -118,128 +111,111 @@ public class JarReorder {
out
=
System
.
out
;
}
fileArgs
=
useTopDir
?
3
:
2
;
if
(
arglen
<=
fileArgs
)
{
// Should be 2 or more args left
if
(
arglen
<=
2
)
{
usage
();
System
.
exit
(
1
);
}
// Read the ordered list of files to be included in rt.jar.
// Read the list of files/directories to be excluded from rt.jar.
// Read the ordered set of files to be included in rt.jar.
// Read the set of files/directories to be excluded from rt.jar.
String
classListFile
=
args
[
argpos
];
String
excludeListFile
=
args
[
argpos
+
1
];
argpos
+=
2
;
arglen
-=
2
;
Vector
orderList
=
readListFromFile
(
args
[
argpos
],
true
);
Vector
excludeList
=
readListFromFile
(
args
[
argpos
+
1
],
false
);
if
(
useTopDir
)
{
topDirName
=
args
[
argpos
+
2
];
if
(!
topDirName
.
endsWith
(
File
.
separator
))
topDirName
=
topDirName
+
File
.
separator
;
}
// Create 2 lists and a set of processed files
List
<
String
>
orderList
=
readListFromFile
(
classListFile
,
true
);
List
<
String
>
excludeList
=
readListFromFile
(
excludeListFile
,
false
);
Set
<
String
>
processed
=
new
HashSet
<
String
>();
// Copy these lists into filesExcluded so that these files will be excluded
// from the file list. (The orderList files will be appended later.)
// Create set of all files and directories excluded, then expand
// that list completely
Set
<
String
>
excludeSet
=
new
HashSet
<
String
>(
excludeList
);
Set
<
String
>
allFilesExcluded
=
expand
(
null
,
excludeSet
,
processed
);
for
(
int
i
=
0
;
i
<
orderList
.
size
();
++
i
)
{
String
s
=
(
String
)
orderList
.
elementAt
(
i
);
filesExcluded
.
put
(
s
,
s
);
}
for
(
int
i
=
0
;
i
<
excludeList
.
size
();
++
i
)
{
String
s
=
(
String
)
excludeList
.
elementAt
(
i
);
filesExcluded
.
put
(
s
,
s
);
}
// Indicate all these have been processed, orderList too, kept to end.
processed
.
addAll
(
orderList
);
// The remaining arguments are names of files/directories to be included
// in the jar file.
String
[]
files
=
new
String
[
arglen
-
fileArgs
];
for
(
int
i
=
fileArgs
;
i
<
arglen
;
++
i
)
{
files
[
i
-
fileArgs
]
=
args
[
argpos
+
i
];
filesExcluded
.
put
(
args
[
argpos
+
i
],
args
[
argpos
+
i
]);
Set
<
String
>
inputSet
=
new
HashSet
<
String
>();
for
(
int
i
=
0
;
i
<
arglen
;
++
i
)
{
String
name
=
args
[
argpos
+
i
];
name
=
cleanPath
(
new
File
(
name
));
if
(
name
!=
null
&&
name
.
length
()
>
0
&&
!
inputSet
.
contains
(
name
)
)
{
inputSet
.
add
(
name
);
}
}
// Expand file/directory list to file list excluding those
// read from the class list.
// Expand file/directory input so we get a complete set (except ordered)
// Should be everything not excluded and not in order list.
Set
<
String
>
allFilesIncluded
=
expand
(
null
,
inputSet
,
processed
);
if
(
useTopDir
)
expand
(
new
File
(
topDirName
),
files
,
filesIncluded
,
filesExcluded
,
topDirName
);
else
expand
(
null
,
files
,
filesIncluded
,
filesExcluded
,
null
);
// Create simple sorted list so we can add ordered items at end.
List
<
String
>
allFiles
=
new
ArrayList
<
String
>(
allFilesIncluded
);
Collections
.
sort
(
allFiles
);
// Now add the ordered
list to the end of the expanded
list.
// Now add the ordered
set to the end of the
list.
// Add in REVERSE ORDER, so that the first element is closest to
// the end (and the index).
HashSet
excludeSet
=
new
HashSet
(
excludeList
);
for
(
int
i
=
orderList
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
String
s
=
(
String
)
orderList
.
elementAt
(
i
);
if
(
excludeSet
.
contains
(
s
))
{
System
.
err
.
println
(
"Included file "
+
s
+
" is also excluded, skipping."
);
continue
;
String
s
=
orderList
.
get
(
i
);
if
(
allFilesExcluded
.
contains
(
s
))
{
System
.
err
.
println
(
"Included order file "
+
s
+
" is also excluded, skipping."
);
}
else
if
(
new
File
(
s
).
exists
())
{
allFiles
.
add
(
s
);
}
else
{
System
.
err
.
println
(
"Included order file "
+
s
+
" missing, skipping."
);
}
if
(
new
File
(
topDirName
+
s
).
exists
())
filesIncluded
.
addElement
(
s
);
else
System
.
err
.
println
(
"Included file "
+
s
+
" missing, skipping."
);
}
// Print results.
for
(
int
i
=
0
;
i
<
filesIncluded
.
size
();
++
i
)
{
if
(
useTopDir
)
{
out
.
print
(
"-C "
);
out
.
print
(
topDirName
);
out
.
print
(
" "
);
}
out
.
println
((
String
)
filesIncluded
.
elementAt
(
i
));
// Print final results.
for
(
String
str
:
allFiles
)
{
out
.
println
(
str
);
}
out
.
flush
();
out
.
close
();
}
/*
* Read a file containing a list of files
into a Vector
.
* Read a file containing a list of files
and directories into a List
.
*/
private
static
Vector
readListFromFile
(
String
fileName
,
boolean
addClassSuffix
)
{
private
List
<
String
>
readListFromFile
(
String
fileName
,
boolean
addClassSuffix
)
{
BufferedReader
br
=
null
;
Vector
v
=
new
Vector
(
2000
);
if
(
"-"
.
equals
(
fileName
))
return
v
;
List
<
String
>
list
=
new
ArrayList
<
String
>(
);
// If you see "-" for the name, just assume nothing was provided.
if
(
"-"
.
equals
(
fileName
))
{
return
list
;
}
try
{
br
=
new
BufferedReader
(
new
FileReader
(
fileName
));
// Read the input file a line at a time. # in column 1 is a comment.
// Read the input file a path at a time. # in column 1 is a comment.
while
(
true
)
{
String
line
=
null
;
line
=
br
.
readLine
();
if
(
line
==
null
)
String
path
=
br
.
readLine
();
if
(
path
==
null
)
{
break
;
if
(
line
.
length
()
==
0
||
line
.
charAt
(
0
)
==
'#'
)
}
// Look for comments
path
=
path
.
trim
();
if
(
path
.
length
()
==
0
||
path
.
charAt
(
0
)
==
'#'
)
{
continue
;
// Convert forward or back slashes to the type expected for
// the current platform.
if
(
File
.
separatorChar
==
'/'
)
line
=
line
.
replace
(
'\\'
,
'/'
);
else
line
=
line
.
replace
(
'/'
,
'\\'
);
line
=
line
.
trim
();
if
(
addClassSuffix
)
{
if
(!
line
.
endsWith
(
".class"
))
{
line
=
line
+
".class"
;
}
}
v
.
addElement
(
line
);
// Add trailing .class if necessary
if
(
addClassSuffix
&&
!
path
.
endsWith
(
".class"
))
{
path
=
path
+
".class"
;
}
// Normalize the path
path
=
cleanPath
(
new
File
(
path
));
// Add to list
if
(
path
!=
null
&&
path
.
length
()
>
0
&&
!
list
.
contains
(
path
))
{
list
.
add
(
path
);
}
}
br
.
close
();
}
catch
(
FileNotFoundException
e
)
{
...
...
@@ -249,68 +225,89 @@ public class JarReorder {
e
.
printStackTrace
();
System
.
exit
(
2
);
}
return
v
;
return
list
;
}
/*
* Expands
list of files to process into full lis
t of all files that
* Expands
inputSet (files or dirs) into full se
t of all files that
* can be found by recursively descending directories.
* @param dir root directory
* @param inputSet set of files or dirs to look into
* @param processed files or dirs already processed
* @return set of files
*/
private
static
void
expand
(
File
dir
,
String
[]
files
,
Vector
includedFiles
,
HashMap
excludedFiles
,
String
topDirName
)
{
if
(
files
==
null
)
{
return
;
private
Set
<
String
>
expand
(
File
dir
,
Set
<
String
>
inputSet
,
Set
<
String
>
processed
)
{
Set
<
String
>
includedFiles
=
new
HashSet
<
String
>();
if
(
inputSet
.
isEmpty
())
{
return
includedFiles
;
}
for
(
int
i
=
0
;
i
<
files
.
length
;
i
++)
{
File
f
=
(
dir
==
null
)
?
new
File
(
files
[
i
])
:
new
File
(
dir
,
files
[
i
]);
if
(
f
.
isFile
())
{
String
filePath
=
f
.
getPath
();
if
(
useTopDir
)
{
if
(
filePath
.
startsWith
(
topDirName
))
filePath
=
filePath
.
substring
(
topDirName
.
length
());
}
if
(
filePath
.
length
()
>=
2
&&
filePath
.
charAt
(
0
)
==
'.'
&&
filePath
.
charAt
(
1
)
==
File
.
separatorChar
)
filePath
=
filePath
.
substring
(
2
);
if
(!
excludedFiles
.
containsKey
(
filePath
))
{
excludedFiles
.
put
(
filePath
,
filePath
);
includedFiles
.
addElement
(
filePath
);
}
}
else
if
(
f
.
isDirectory
())
{
String
dirPath
=
f
.
getPath
();
dirPath
=
(
dirPath
.
endsWith
(
File
.
separator
))
?
dirPath
:
(
dirPath
+
File
.
separator
);
if
(
useTopDir
)
{
if
(
dirPath
.
startsWith
(
topDirName
))
dirPath
=
dirPath
.
substring
(
topDirName
.
length
());
for
(
String
name
:
inputSet
)
{
// Depending on start location
File
f
=
(
dir
==
null
)
?
new
File
(
name
)
:
new
File
(
dir
,
name
);
// Normalized path to use
String
path
=
cleanPath
(
f
);
if
(
path
!=
null
&&
path
.
length
()
>
0
&&
!
processed
.
contains
(
path
))
{
if
(
f
.
isFile
())
{
// Not in the excludeList, add it to both lists
includedFiles
.
add
(
path
);
processed
.
add
(
path
);
}
else
if
(
f
.
isDirectory
())
{
// Add the directory entries
String
[]
dirList
=
f
.
list
();
Set
<
String
>
dirInputSet
=
new
HashSet
<
String
>();
for
(
String
x
:
dirList
)
{
dirInputSet
.
add
(
x
);
}
// Process all entries in this directory
Set
<
String
>
subList
=
expand
(
f
,
dirInputSet
,
processed
);
includedFiles
.
addAll
(
subList
);
processed
.
add
(
path
);
}
}
}
return
includedFiles
;
}
if
(
dirPath
.
length
()
>=
2
&&
dirPath
.
charAt
(
0
)
==
'.'
&&
dirPath
.
charAt
(
1
)
==
File
.
separatorChar
)
dirPath
=
dirPath
.
substring
(
2
);
if
(!
excludedFiles
.
containsKey
(
dirPath
))
{
private
String
cleanPath
(
File
f
)
{
String
path
=
f
.
getPath
();
if
(
f
.
isFile
())
{
path
=
cleanFilePath
(
path
);
}
else
if
(
f
.
isDirectory
())
{
path
=
cleanDirPath
(
path
);
}
else
{
System
.
err
.
println
(
"WARNING: Path does not exist as file or directory: "
+
path
);
path
=
null
;
}
return
path
;
}
// Sort the directory list so that entries in the jar file
// are in a repeatable order. The order itself is not particularly
// important. [File.list() is unpredictable.]
private
String
cleanFilePath
(
String
path
)
{
// Remove leading and trailing whitespace
path
=
path
.
trim
();
// Make all / and \ chars one
if
(
File
.
separatorChar
==
'/'
)
{
path
=
path
.
replace
(
'\\'
,
'/'
);
}
else
{
path
=
path
.
replace
(
'/'
,
'\\'
);
}
// Remove leading ./
if
(
path
.
startsWith
(
"."
+
File
.
separator
))
{
path
=
path
.
substring
(
2
);
}
return
path
;
}
String
[]
dirList
=
f
.
list
();
Arrays
.
sort
(
dirList
);
expand
(
f
,
dirList
,
includedFiles
,
excludedFiles
,
topDirName
);
}
}
else
{
System
.
err
.
println
(
"Error accessing: "
+
f
.
getPath
());
}
private
String
cleanDirPath
(
String
path
)
{
path
=
cleanFilePath
(
path
);
// Make sure it ends with a file separator
if
(!
path
.
endsWith
(
File
.
separator
))
{
path
=
path
+
File
.
separator
;
}
return
path
;
}
}
test/ProblemList.txt
浏览文件 @
12a6372d
...
...
@@ -586,9 +586,6 @@ java/nio/channels/ServerSocketChannel/AdaptServerSocket.java windows-all
java/nio/channels/SocketChannel/ConnectState.java windows-all
java/nio/channels/SocketChannel/FinishConnect.java windows-all
# Fails on all platforms due to overlap of JDK jar file contents:
sun/nio/cs/Test4200310.sh generic-all
############################################################################
# jdk_rmi
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录