Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
671533fd
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看板
提交
671533fd
编写于
3月 17, 2011
作者:
S
smarks
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7022382: convert pack200 library code to use try-with-resources
Reviewed-by: ksrini
上级
7ff04ffb
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
107 addition
and
110 deletion
+107
-110
src/share/classes/com/sun/java/util/jar/pack/BandStructure.java
...are/classes/com/sun/java/util/jar/pack/BandStructure.java
+22
-22
src/share/classes/com/sun/java/util/jar/pack/Driver.java
src/share/classes/com/sun/java/util/jar/pack/Driver.java
+8
-11
src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java
...hare/classes/com/sun/java/util/jar/pack/NativeUnpack.java
+3
-3
src/share/classes/com/sun/java/util/jar/pack/PackageReader.java
...are/classes/com/sun/java/util/jar/pack/PackageReader.java
+22
-21
src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java
...are/classes/com/sun/java/util/jar/pack/PackageWriter.java
+29
-28
src/share/classes/com/sun/java/util/jar/pack/PropMap.java
src/share/classes/com/sun/java/util/jar/pack/PropMap.java
+14
-17
src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java
...hare/classes/com/sun/java/util/jar/pack/UnpackerImpl.java
+3
-2
src/share/classes/com/sun/java/util/jar/pack/Utils.java
src/share/classes/com/sun/java/util/jar/pack/Utils.java
+6
-6
未找到文件。
src/share/classes/com/sun/java/util/jar/pack/BandStructure.java
浏览文件 @
671533fd
...
...
@@ -743,24 +743,24 @@ class BandStructure {
private
void
dumpBand
()
throws
IOException
{
assert
(
optDumpBands
);
PrintStream
ps
=
new
PrintStream
(
getDumpStream
(
this
,
".txt"
));
String
irr
=
(
bandCoding
==
regularCoding
)
?
""
:
" irregular"
;
ps
.
print
(
"# length="
+
length
+
" size="
+
outputSize
()+
irr
+
" coding="
+
bandCoding
);
if
(
metaCoding
!=
noMetaCoding
)
{
StringBuffer
sb
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
metaCoding
.
length
;
i
++)
{
if
(
i
==
1
)
sb
.
append
(
" /"
);
sb
.
append
(
" "
).
append
(
metaCoding
[
i
]
&
0xFF
);
try
(
PrintStream
ps
=
new
PrintStream
(
getDumpStream
(
this
,
".txt"
)))
{
String
irr
=
(
bandCoding
==
regularCoding
)
?
""
:
" irregular"
;
ps
.
print
(
"# length="
+
length
+
" size="
+
outputSize
()+
irr
+
" coding="
+
bandCoding
);
if
(
metaCoding
!=
noMetaCoding
)
{
StringBuffer
sb
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
metaCoding
.
length
;
i
++)
{
if
(
i
==
1
)
sb
.
append
(
" /"
);
sb
.
append
(
" "
).
append
(
metaCoding
[
i
]
&
0xFF
);
}
ps
.
print
(
" //header: "
+
sb
);
}
ps
.
print
(
" //header: "
+
sb
);
printArrayTo
(
ps
,
values
,
0
,
length
);
}
try
(
OutputStream
ds
=
getDumpStream
(
this
,
".bnd"
))
{
bandCoding
.
writeArrayTo
(
ds
,
values
,
0
,
length
);
}
printArrayTo
(
ps
,
values
,
0
,
length
);
ps
.
close
();
OutputStream
ds
=
getDumpStream
(
this
,
".bnd"
);
bandCoding
.
writeArrayTo
(
ds
,
values
,
0
,
length
);
ds
.
close
();
}
/** Disburse one value. */
...
...
@@ -829,12 +829,12 @@ class BandStructure {
private
void
dumpBand
()
throws
IOException
{
assert
(
optDumpBands
);
OutputStream
ds
=
getDumpStream
(
this
,
".bnd"
);
if
(
bytesForDump
!=
null
)
bytesForDump
.
writeTo
(
ds
);
else
bytes
.
writeTo
(
ds
);
ds
.
close
();
try
(
OutputStream
ds
=
getDumpStream
(
this
,
".bnd"
))
{
if
(
bytesForDump
!=
null
)
bytesForDump
.
writeTo
(
ds
);
else
bytes
.
writeTo
(
ds
);
}
}
public
void
readDataFrom
(
InputStream
in
)
throws
IOException
{
...
...
src/share/classes/com/sun/java/util/jar/pack/Driver.java
浏览文件 @
671533fd
...
...
@@ -150,12 +150,12 @@ class Driver {
// See if there is any other action to take.
if
(
"--config-file="
.
equals
(
state
))
{
String
propFile
=
av
.
remove
(
0
);
InputStream
propIn
=
new
FileInputStream
(
propFile
);
Properties
fileProps
=
new
Properties
();
fileProps
.
load
(
new
BufferedInputStream
(
propIn
));
try
(
InputStream
propIn
=
new
FileInputStream
(
propFile
))
{
fileProps
.
load
(
propIn
);
}
if
(
engProps
.
get
(
verboseProp
)
!=
null
)
fileProps
.
list
(
System
.
out
);
propIn
.
close
();
for
(
Map
.
Entry
<
Object
,
Object
>
me
:
fileProps
.
entrySet
())
{
engProps
.
put
((
String
)
me
.
getKey
(),
(
String
)
me
.
getValue
());
}
...
...
@@ -348,10 +348,10 @@ class Driver {
else
fileOut
=
new
FileOutputStream
(
outfile
);
fileOut
=
new
BufferedOutputStream
(
fileOut
);
JarOutputStream
out
=
new
JarOutputStream
(
fileOut
);
junpack
.
unpack
(
in
,
out
);
//in.close();
// p200 closes in but not out
out
.
close
();
try
(
JarOutputStream
out
=
new
JarOutputStream
(
fileOut
))
{
junpack
.
unpack
(
in
,
out
);
// p200 closes in but not out
}
// At this point, we have a good jarfile (or newfile, if -r)
}
...
...
@@ -411,8 +411,7 @@ class Driver {
long
filelen
=
new
File
(
jarfile
).
length
();
if
(
filelen
<=
0
)
return
""
;
long
skiplen
=
Math
.
max
(
0
,
filelen
-
tail
.
length
);
InputStream
in
=
new
FileInputStream
(
new
File
(
jarfile
));
try
{
try
(
InputStream
in
=
new
FileInputStream
(
new
File
(
jarfile
)))
{
in
.
skip
(
skiplen
);
in
.
read
(
tail
);
for
(
int
i
=
tail
.
length
-
4
;
i
>=
0
;
i
--)
{
...
...
@@ -426,8 +425,6 @@ class Driver {
}
}
return
""
;
}
finally
{
in
.
close
();
}
}
...
...
src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java
浏览文件 @
671533fd
...
...
@@ -241,9 +241,9 @@ class NativeUnpack {
void
run
(
File
inFile
,
JarOutputStream
jstream
)
throws
IOException
{
// %%% maybe memory-map the file, and pass it straight into unpacker
ByteBuffer
mappedFile
=
null
;
FileInputStream
fis
=
new
FileInputStream
(
inFile
);
run
(
fis
,
jstream
,
mappedFile
);
fis
.
close
();
try
(
FileInputStream
fis
=
new
FileInputStream
(
inFile
))
{
run
(
fis
,
jstream
,
mappedFile
);
}
// Note: caller is responsible to finish with jstream.
}
...
...
src/share/classes/com/sun/java/util/jar/pack/PackageReader.java
浏览文件 @
671533fd
...
...
@@ -540,9 +540,9 @@ class PackageReader extends BandStructure {
Index
index
=
initCPIndex
(
tag
,
cpMap
);
if
(
optDumpBands
)
{
PrintStream
ps
=
new
PrintStream
(
getDumpStream
(
index
,
".idx"
));
printArrayTo
(
ps
,
index
.
cpMap
,
0
,
index
.
cpMap
.
length
);
ps
.
close
();
try
(
PrintStream
ps
=
new
PrintStream
(
getDumpStream
(
index
,
".idx"
)))
{
printArrayTo
(
ps
,
index
.
cpMap
,
0
,
index
.
cpMap
.
length
);
}
}
}
...
...
@@ -828,26 +828,27 @@ class PackageReader extends BandStructure {
attr_definition_headers
.
readFrom
(
in
);
attr_definition_name
.
readFrom
(
in
);
attr_definition_layout
.
readFrom
(
in
);
PrintStream
dump
=
!
optDumpBands
?
null
:
new
PrintStream
(
getDumpStream
(
attr_definition_headers
,
".def"
));
for
(
int
i
=
0
;
i
<
numAttrDefs
;
i
++)
{
int
header
=
attr_definition_headers
.
getByte
();
Utf8Entry
name
=
(
Utf8Entry
)
attr_definition_name
.
getRef
();
Utf8Entry
layout
=
(
Utf8Entry
)
attr_definition_layout
.
getRef
();
int
ctype
=
(
header
&
ADH_CONTEXT_MASK
);
int
index
=
(
header
>>
ADH_BIT_SHIFT
)
-
ADH_BIT_IS_LSB
;
Attribute
.
Layout
def
=
new
Attribute
.
Layout
(
ctype
,
name
.
stringValue
(),
layout
.
stringValue
());
// Check layout string for Java 6 extensions.
String
pvLayout
=
def
.
layoutForPackageMajver
(
getPackageMajver
());
if
(!
pvLayout
.
equals
(
def
.
layout
()))
{
throw
new
IOException
(
"Bad attribute layout in version 150 archive: "
+
def
.
layout
());
try
(
PrintStream
dump
=
!
optDumpBands
?
null
:
new
PrintStream
(
getDumpStream
(
attr_definition_headers
,
".def"
)))
{
for
(
int
i
=
0
;
i
<
numAttrDefs
;
i
++)
{
int
header
=
attr_definition_headers
.
getByte
();
Utf8Entry
name
=
(
Utf8Entry
)
attr_definition_name
.
getRef
();
Utf8Entry
layout
=
(
Utf8Entry
)
attr_definition_layout
.
getRef
();
int
ctype
=
(
header
&
ADH_CONTEXT_MASK
);
int
index
=
(
header
>>
ADH_BIT_SHIFT
)
-
ADH_BIT_IS_LSB
;
Attribute
.
Layout
def
=
new
Attribute
.
Layout
(
ctype
,
name
.
stringValue
(),
layout
.
stringValue
());
// Check layout string for Java 6 extensions.
String
pvLayout
=
def
.
layoutForPackageMajver
(
getPackageMajver
());
if
(!
pvLayout
.
equals
(
def
.
layout
()))
{
throw
new
IOException
(
"Bad attribute layout in version 150 archive: "
+
def
.
layout
());
}
this
.
setAttributeLayoutIndex
(
def
,
index
);
if
(
dump
!=
null
)
dump
.
println
(
index
+
" "
+
def
);
}
this
.
setAttributeLayoutIndex
(
def
,
index
);
if
(
dump
!=
null
)
dump
.
println
(
index
+
" "
+
def
);
}
if
(
dump
!=
null
)
dump
.
close
();
attr_definition_headers
.
doneDisbursing
();
attr_definition_name
.
doneDisbursing
();
attr_definition_layout
.
doneDisbursing
();
...
...
src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java
浏览文件 @
671533fd
...
...
@@ -458,9 +458,9 @@ class PackageWriter extends BandStructure {
Utils
.
log
.
info
(
"Writing "
+
cpMap
.
length
+
" "
+
ConstantPool
.
tagName
(
tag
)+
" entries..."
);
if
(
optDumpBands
)
{
PrintStream
ps
=
new
PrintStream
(
getDumpStream
(
index
,
".idx"
));
printArrayTo
(
ps
,
cpMap
,
0
,
cpMap
.
length
);
ps
.
close
();
try
(
PrintStream
ps
=
new
PrintStream
(
getDumpStream
(
index
,
".idx"
)))
{
printArrayTo
(
ps
,
cpMap
,
0
,
cpMap
.
length
);
}
}
switch
(
tag
)
{
...
...
@@ -923,33 +923,34 @@ class PackageWriter extends BandStructure {
}
});
attrDefsWritten
=
new
Attribute
.
Layout
[
numAttrDefs
];
PrintStream
dump
=
!
optDumpBands
?
null
:
new
PrintStream
(
getDumpStream
(
attr_definition_headers
,
".def"
));
int
[]
indexForDebug
=
Arrays
.
copyOf
(
attrIndexLimit
,
ATTR_CONTEXT_LIMIT
);
for
(
int
i
=
0
;
i
<
defs
.
length
;
i
++)
{
int
header
=
((
Integer
)
defs
[
i
][
0
]).
intValue
();
Attribute
.
Layout
def
=
(
Attribute
.
Layout
)
defs
[
i
][
1
];
attrDefsWritten
[
i
]
=
def
;
assert
((
header
&
ADH_CONTEXT_MASK
)
==
def
.
ctype
());
attr_definition_headers
.
putByte
(
header
);
attr_definition_name
.
putRef
(
ConstantPool
.
getUtf8Entry
(
def
.
name
()));
String
layout
=
def
.
layoutForPackageMajver
(
getPackageMajver
());
attr_definition_layout
.
putRef
(
ConstantPool
.
getUtf8Entry
(
layout
));
// Check that we are transmitting that correct attribute index:
boolean
debug
=
false
;
assert
(
debug
=
true
);
if
(
debug
)
{
int
hdrIndex
=
(
header
>>
ADH_BIT_SHIFT
)
-
ADH_BIT_IS_LSB
;
if
(
hdrIndex
<
0
)
hdrIndex
=
indexForDebug
[
def
.
ctype
()]++;
int
realIndex
=
(
attrIndexTable
.
get
(
def
)).
intValue
();
assert
(
hdrIndex
==
realIndex
);
}
if
(
dump
!=
null
)
{
int
index
=
(
header
>>
ADH_BIT_SHIFT
)
-
ADH_BIT_IS_LSB
;
dump
.
println
(
index
+
" "
+
def
);
try
(
PrintStream
dump
=
!
optDumpBands
?
null
:
new
PrintStream
(
getDumpStream
(
attr_definition_headers
,
".def"
)))
{
int
[]
indexForDebug
=
Arrays
.
copyOf
(
attrIndexLimit
,
ATTR_CONTEXT_LIMIT
);
for
(
int
i
=
0
;
i
<
defs
.
length
;
i
++)
{
int
header
=
((
Integer
)
defs
[
i
][
0
]).
intValue
();
Attribute
.
Layout
def
=
(
Attribute
.
Layout
)
defs
[
i
][
1
];
attrDefsWritten
[
i
]
=
def
;
assert
((
header
&
ADH_CONTEXT_MASK
)
==
def
.
ctype
());
attr_definition_headers
.
putByte
(
header
);
attr_definition_name
.
putRef
(
ConstantPool
.
getUtf8Entry
(
def
.
name
()));
String
layout
=
def
.
layoutForPackageMajver
(
getPackageMajver
());
attr_definition_layout
.
putRef
(
ConstantPool
.
getUtf8Entry
(
layout
));
// Check that we are transmitting that correct attribute index:
boolean
debug
=
false
;
assert
(
debug
=
true
);
if
(
debug
)
{
int
hdrIndex
=
(
header
>>
ADH_BIT_SHIFT
)
-
ADH_BIT_IS_LSB
;
if
(
hdrIndex
<
0
)
hdrIndex
=
indexForDebug
[
def
.
ctype
()]++;
int
realIndex
=
(
attrIndexTable
.
get
(
def
)).
intValue
();
assert
(
hdrIndex
==
realIndex
);
}
if
(
dump
!=
null
)
{
int
index
=
(
header
>>
ADH_BIT_SHIFT
)
-
ADH_BIT_IS_LSB
;
dump
.
println
(
index
+
" "
+
def
);
}
}
}
if
(
dump
!=
null
)
dump
.
close
();
}
void
writeAttrCounts
()
throws
IOException
{
...
...
src/share/classes/com/sun/java/util/jar/pack/PropMap.java
浏览文件 @
671533fd
...
...
@@ -122,26 +122,23 @@ final class PropMap implements SortedMap<Object, Object> {
// Define certain attribute layouts by default.
// Do this after the previous props are put in place,
// to allow override if necessary.
InputStream
propStr
=
null
;
try
{
String
propFile
=
"intrinsic.properties"
;
propStr
=
PackerImpl
.
class
.
getResourceAsStream
(
propFile
);
props
.
load
(
new
BufferedInputStream
(
propStr
));
for
(
Map
.
Entry
<
Object
,
Object
>
e
:
props
.
entrySet
())
{
String
key
=
(
String
)
e
.
getKey
();
String
val
=
(
String
)
e
.
getValue
();
if
(
key
.
startsWith
(
"attribute."
))
{
e
.
setValue
(
Attribute
.
normalizeLayoutString
(
val
));
}
String
propFile
=
"intrinsic.properties"
;
try
(
InputStream
propStr
=
PackerImpl
.
class
.
getResourceAsStream
(
propFile
))
{
if
(
propStr
==
null
)
{
throw
new
RuntimeException
(
propFile
+
" cannot be loaded"
);
}
props
.
load
(
propStr
);
}
catch
(
IOException
ee
)
{
throw
new
RuntimeException
(
ee
);
}
finally
{
try
{
if
(
propStr
!=
null
)
{
propStr
.
close
();
}
}
catch
(
IOException
ignore
)
{}
}
for
(
Map
.
Entry
<
Object
,
Object
>
e
:
props
.
entrySet
())
{
String
key
=
(
String
)
e
.
getKey
();
String
val
=
(
String
)
e
.
getValue
();
if
(
key
.
startsWith
(
"attribute."
))
{
e
.
setValue
(
Attribute
.
normalizeLayoutString
(
val
));
}
}
defaultProps
=
(
new
HashMap
<>(
props
));
// shrink to fit
...
...
src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java
浏览文件 @
671533fd
...
...
@@ -161,8 +161,9 @@ public class UnpackerImpl extends TLGlobals implements Pack200.Unpacker {
}
// Use the stream-based implementation.
// %%% Reconsider if native unpacker learns to memory-map the file.
FileInputStream
instr
=
new
FileInputStream
(
in
);
unpack
(
instr
,
out
);
try
(
FileInputStream
instr
=
new
FileInputStream
(
in
))
{
unpack
(
instr
,
out
);
}
if
(
props
.
getBoolean
(
Utils
.
UNPACK_REMOVE_PACKFILE
))
{
in
.
delete
();
}
...
...
src/share/classes/com/sun/java/util/jar/pack/Utils.java
浏览文件 @
671533fd
...
...
@@ -268,18 +268,18 @@ class Utils {
// 4947205 : Peformance is slow when using pack-effort=0
out
=
new
BufferedOutputStream
(
out
);
out
=
new
NonCloser
(
out
);
// protect from JarOutputStream.close()
JarOutputStream
jout
=
new
JarOutputStream
(
out
);
copyJarFile
(
in
,
jout
);
jout
.
close
();
try
(
JarOutputStream
jout
=
new
JarOutputStream
(
out
))
{
copyJarFile
(
in
,
jout
);
}
}
static
void
copyJarFile
(
JarFile
in
,
OutputStream
out
)
throws
IOException
{
// 4947205 : Peformance is slow when using pack-effort=0
out
=
new
BufferedOutputStream
(
out
);
out
=
new
NonCloser
(
out
);
// protect from JarOutputStream.close()
JarOutputStream
jout
=
new
JarOutputStream
(
out
);
copyJarFile
(
in
,
jout
);
jout
.
close
();
try
(
JarOutputStream
jout
=
new
JarOutputStream
(
out
))
{
copyJarFile
(
in
,
jout
);
}
}
// Wrapper to prevent closing of client-supplied stream.
static
private
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录