Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
4b1ed28b
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看板
提交
4b1ed28b
编写于
12月 23, 2010
作者:
K
ksrini
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7002386: (launcher) fix XshowSettings
Reviewed-by: darcy, mchung, naoto
上级
8f31caf3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
118 addition
and
62 deletion
+118
-62
src/share/bin/java.c
src/share/bin/java.c
+15
-6
src/share/classes/sun/launcher/LauncherHelper.java
src/share/classes/sun/launcher/LauncherHelper.java
+94
-54
test/tools/launcher/Settings.java
test/tools/launcher/Settings.java
+9
-2
未找到文件。
src/share/bin/java.c
浏览文件 @
4b1ed28b
...
@@ -158,8 +158,9 @@ static jboolean IsWildCardEnabled();
...
@@ -158,8 +158,9 @@ static jboolean IsWildCardEnabled();
* Running Java code in primordial thread caused many problems. We will
* Running Java code in primordial thread caused many problems. We will
* create a new thread to invoke JVM. See 6316197 for more information.
* create a new thread to invoke JVM. See 6316197 for more information.
*/
*/
static
jlong
threadStackSize
=
0
;
/* stack size of the new thread */
static
jlong
threadStackSize
=
0
;
/* stack size of the new thread */
static
jlong
heapSize
=
0
;
/* heap size */
static
jlong
maxHeapSize
=
0
;
/* max heap size */
static
jlong
initialHeapSize
=
0
;
/* inital heap size */
int
JNICALL
JavaMain
(
void
*
args
);
/* entry point */
int
JNICALL
JavaMain
(
void
*
args
);
/* entry point */
...
@@ -381,7 +382,7 @@ JavaMain(void * _args)
...
@@ -381,7 +382,7 @@ JavaMain(void * _args)
if
(
showSettings
!=
NULL
)
{
if
(
showSettings
!=
NULL
)
{
ShowSettings
(
env
,
showSettings
);
ShowSettings
(
env
,
showSettings
);
CHECK_EXCEPTION_LEAVE
(
0
);
CHECK_EXCEPTION_LEAVE
(
1
);
}
}
/* If the user specified neither a class name nor a JAR file */
/* If the user specified neither a class name nor a JAR file */
if
(
printXUsage
||
printUsage
||
(
jarfile
==
0
&&
classname
==
0
))
{
if
(
printXUsage
||
printUsage
||
(
jarfile
==
0
&&
classname
==
0
))
{
...
@@ -689,7 +690,14 @@ AddOption(char *str, void *info)
...
@@ -689,7 +690,14 @@ AddOption(char *str, void *info)
if
(
JLI_StrCCmp
(
str
,
"-Xmx"
)
==
0
)
{
if
(
JLI_StrCCmp
(
str
,
"-Xmx"
)
==
0
)
{
jlong
tmp
;
jlong
tmp
;
if
(
parse_size
(
str
+
4
,
&
tmp
))
{
if
(
parse_size
(
str
+
4
,
&
tmp
))
{
heapSize
=
tmp
;
maxHeapSize
=
tmp
;
}
}
if
(
JLI_StrCCmp
(
str
,
"-Xms"
)
==
0
)
{
jlong
tmp
;
if
(
parse_size
(
str
+
4
,
&
tmp
))
{
initialHeapSize
=
tmp
;
}
}
}
}
}
}
...
@@ -1506,12 +1514,13 @@ ShowSettings(JNIEnv *env, char *optString)
...
@@ -1506,12 +1514,13 @@ ShowSettings(JNIEnv *env, char *optString)
jstring
joptString
;
jstring
joptString
;
NULL_CHECK
(
cls
=
FindBootStrapClass
(
env
,
"sun/launcher/LauncherHelper"
));
NULL_CHECK
(
cls
=
FindBootStrapClass
(
env
,
"sun/launcher/LauncherHelper"
));
NULL_CHECK
(
showSettingsID
=
(
*
env
)
->
GetStaticMethodID
(
env
,
cls
,
NULL_CHECK
(
showSettingsID
=
(
*
env
)
->
GetStaticMethodID
(
env
,
cls
,
"showSettings"
,
"(ZLjava/lang/String;JJZ)V"
));
"showSettings"
,
"(ZLjava/lang/String;JJ
J
Z)V"
));
joptString
=
(
*
env
)
->
NewStringUTF
(
env
,
optString
);
joptString
=
(
*
env
)
->
NewStringUTF
(
env
,
optString
);
(
*
env
)
->
CallStaticVoidMethod
(
env
,
cls
,
showSettingsID
,
(
*
env
)
->
CallStaticVoidMethod
(
env
,
cls
,
showSettingsID
,
JNI_TRUE
,
JNI_TRUE
,
joptString
,
joptString
,
(
jlong
)
heapSize
,
(
jlong
)
initialHeapSize
,
(
jlong
)
maxHeapSize
,
(
jlong
)
threadStackSize
,
(
jlong
)
threadStackSize
,
ServerClassMachine
());
ServerClassMachine
());
}
}
...
...
src/share/classes/sun/launcher/LauncherHelper.java
浏览文件 @
4b1ed28b
...
@@ -45,15 +45,18 @@ import java.io.PrintStream;
...
@@ -45,15 +45,18 @@ import java.io.PrintStream;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Modifier
;
import
java.lang.reflect.Modifier
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.math.MathContext
;
import
java.math.RoundingMode
;
import
java.math.RoundingMode
;
import
java.util.ResourceBundle
;
import
java.util.ResourceBundle
;
import
java.text.MessageFormat
;
import
java.text.MessageFormat
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Locale
;
import
java.util.Locale.Category
;
import
java.util.Properties
;
import
java.util.Properties
;
import
java.util.Set
;
import
java.util.TreeSet
;
import
java.util.jar.Attributes
;
import
java.util.jar.Attributes
;
import
java.util.jar.JarFile
;
import
java.util.jar.JarFile
;
import
java.util.jar.Manifest
;
import
java.util.jar.Manifest
;
...
@@ -73,11 +76,6 @@ public enum LauncherHelper {
...
@@ -73,11 +76,6 @@ public enum LauncherHelper {
private
static
final
String
PROP_SETTINGS
=
"Property settings:"
;
private
static
final
String
PROP_SETTINGS
=
"Property settings:"
;
private
static
final
String
LOCALE_SETTINGS
=
"Locale settings:"
;
private
static
final
String
LOCALE_SETTINGS
=
"Locale settings:"
;
private
static
final
long
K
=
1024
;
private
static
final
long
M
=
K
*
K
;
private
static
final
long
G
=
M
*
K
;
private
static
final
long
T
=
G
*
K
;
private
static
synchronized
ResourceBundle
getLauncherResourceBundle
()
{
private
static
synchronized
ResourceBundle
getLauncherResourceBundle
()
{
if
(
javarb
==
null
)
{
if
(
javarb
==
null
)
{
javarb
=
ResourceBundle
.
getBundle
(
defaultBundleName
);
javarb
=
ResourceBundle
.
getBundle
(
defaultBundleName
);
...
@@ -96,14 +94,20 @@ public enum LauncherHelper {
...
@@ -96,14 +94,20 @@ public enum LauncherHelper {
* optionFlag: specifies which options to print default is all other
* optionFlag: specifies which options to print default is all other
* possible values are vm, properties, locale.
* possible values are vm, properties, locale.
*
*
* initialHeapSize: in bytes, as set by the launcher, a zero-value indicates
* this code should determine this value, using a suitable method or
* the line could be omitted.
*
* maxHeapSize: in bytes, as set by the launcher, a zero-value indicates
* maxHeapSize: in bytes, as set by the launcher, a zero-value indicates
* this code should determine this value, using a suitable method.
* this code should determine this value, using a suitable method.
*
*
* stackSize: in bytes, as set by the launcher, a zero-value indicates
* stackSize: in bytes, as set by the launcher, a zero-value indicates
* this code determine this value, using a suitable method.
* this code determine this value, using a suitable method or omit the
* line entirely.
*/
*/
static
void
showSettings
(
boolean
printToStderr
,
String
optionFlag
,
static
void
showSettings
(
boolean
printToStderr
,
String
optionFlag
,
long
maxHeapSize
,
long
stackSize
,
boolean
isServer
)
{
long
initialHeapSize
,
long
maxHeapSize
,
long
stackSize
,
boolean
isServer
)
{
PrintStream
ostream
=
(
printToStderr
)
?
System
.
err
:
System
.
out
;
PrintStream
ostream
=
(
printToStderr
)
?
System
.
err
:
System
.
out
;
String
opts
[]
=
optionFlag
.
split
(
":"
);
String
opts
[]
=
optionFlag
.
split
(
":"
);
...
@@ -112,7 +116,8 @@ public enum LauncherHelper {
...
@@ -112,7 +116,8 @@ public enum LauncherHelper {
:
"all"
;
:
"all"
;
switch
(
optStr
)
{
switch
(
optStr
)
{
case
"vm"
:
case
"vm"
:
printVmSettings
(
ostream
,
maxHeapSize
,
stackSize
,
isServer
);
printVmSettings
(
ostream
,
initialHeapSize
,
maxHeapSize
,
stackSize
,
isServer
);
break
;
break
;
case
"properties"
:
case
"properties"
:
printProperties
(
ostream
);
printProperties
(
ostream
);
...
@@ -121,7 +126,8 @@ public enum LauncherHelper {
...
@@ -121,7 +126,8 @@ public enum LauncherHelper {
printLocale
(
ostream
);
printLocale
(
ostream
);
break
;
break
;
default
:
default
:
printVmSettings
(
ostream
,
maxHeapSize
,
stackSize
,
isServer
);
printVmSettings
(
ostream
,
initialHeapSize
,
maxHeapSize
,
stackSize
,
isServer
);
printProperties
(
ostream
);
printProperties
(
ostream
);
printLocale
(
ostream
);
printLocale
(
ostream
);
break
;
break
;
...
@@ -131,18 +137,25 @@ public enum LauncherHelper {
...
@@ -131,18 +137,25 @@ public enum LauncherHelper {
/*
/*
* prints the main vm settings subopt/section
* prints the main vm settings subopt/section
*/
*/
private
static
void
printVmSettings
(
PrintStream
ostream
,
long
maxHeapSize
,
private
static
void
printVmSettings
(
PrintStream
ostream
,
long
initialHeapSize
,
long
maxHeapSize
,
long
stackSize
,
boolean
isServer
)
{
long
stackSize
,
boolean
isServer
)
{
ostream
.
println
(
VM_SETTINGS
);
ostream
.
println
(
VM_SETTINGS
);
if
(
stackSize
!=
0L
)
{
if
(
stackSize
!=
0L
)
{
ostream
.
println
(
INDENT
+
"Stack Size: "
+
scaleValue
(
stackSize
));
ostream
.
println
(
INDENT
+
"Stack Size: "
+
SizePrefix
.
scaleValue
(
stackSize
));
}
if
(
initialHeapSize
!=
0L
)
{
ostream
.
println
(
INDENT
+
"Min. Heap Size: "
+
SizePrefix
.
scaleValue
(
initialHeapSize
));
}
}
if
(
maxHeapSize
!=
0L
)
{
if
(
maxHeapSize
!=
0L
)
{
ostream
.
println
(
INDENT
+
"Max. Heap Size: "
+
scaleValue
(
maxHeapSize
));
ostream
.
println
(
INDENT
+
"Max. Heap Size: "
+
SizePrefix
.
scaleValue
(
maxHeapSize
));
}
else
{
}
else
{
ostream
.
println
(
INDENT
+
"Max. Heap Size (Estimated): "
ostream
.
println
(
INDENT
+
"Max. Heap Size (Estimated): "
+
scaleValue
(
Runtime
.
getRuntime
().
maxMemory
()));
+
SizePrefix
.
scaleValue
(
Runtime
.
getRuntime
().
maxMemory
()));
}
}
ostream
.
println
(
INDENT
+
"Ergonomics Machine Class: "
ostream
.
println
(
INDENT
+
"Ergonomics Machine Class: "
+
((
isServer
)
?
"server"
:
"client"
));
+
((
isServer
)
?
"server"
:
"client"
));
...
@@ -151,28 +164,6 @@ public enum LauncherHelper {
...
@@ -151,28 +164,6 @@ public enum LauncherHelper {
ostream
.
println
();
ostream
.
println
();
}
}
/*
* scale the incoming values to a human readable form, represented as
* K, M, G and T, see java.c parse_size for the scaled values and
* suffixes.
*/
private
static
String
scaleValue
(
double
v
)
{
MathContext
mc2
=
new
MathContext
(
3
,
RoundingMode
.
HALF_EVEN
);
if
(
v
>=
K
&&
v
<
M
)
{
return
(
new
BigDecimal
(
v
/
K
,
mc2
)).
toPlainString
()
+
"K"
;
}
else
if
(
v
>=
M
&&
v
<
G
)
{
return
(
new
BigDecimal
(
v
/
M
,
mc2
)).
toPlainString
()
+
"M"
;
}
else
if
(
v
>=
G
&&
v
<
T
)
{
return
(
new
BigDecimal
(
v
/
G
,
mc2
)).
toPlainString
()
+
"G"
;
}
else
if
(
v
>=
T
)
{
return
(
new
BigDecimal
(
v
/
T
,
mc2
)).
toPlainString
()
+
"T"
;
}
else
{
return
String
.
format
(
"%.0f"
,
v
);
}
}
/*
/*
* prints the properties subopt/section
* prints the properties subopt/section
*/
*/
...
@@ -196,16 +187,17 @@ public enum LauncherHelper {
...
@@ -196,16 +187,17 @@ public enum LauncherHelper {
String
key
,
String
value
)
{
String
key
,
String
value
)
{
ostream
.
print
(
INDENT
+
key
+
" = "
);
ostream
.
print
(
INDENT
+
key
+
" = "
);
if
(
key
.
equals
(
"line.separator"
))
{
if
(
key
.
equals
(
"line.separator"
))
{
byte
[]
bytes
=
value
.
getBytes
();
for
(
byte
b
:
value
.
getBytes
())
{
for
(
byte
b
:
bytes
)
{
switch
(
b
)
{
switch
(
b
)
{
case
0xd
:
case
0xd
:
ostream
.
print
(
"
CR
"
);
ostream
.
print
(
"
\\r
"
);
break
;
break
;
case
0xa
:
case
0xa
:
ostream
.
print
(
"
LF
"
);
ostream
.
print
(
"
\\n
"
);
break
;
break
;
default
:
default
:
// print any bizzare line separators in hex, but really
// shouldn't happen.
ostream
.
printf
(
"0x%02X"
,
b
&
0xff
);
ostream
.
printf
(
"0x%02X"
,
b
&
0xff
);
break
;
break
;
}
}
...
@@ -217,15 +209,14 @@ public enum LauncherHelper {
...
@@ -217,15 +209,14 @@ public enum LauncherHelper {
ostream
.
println
(
value
);
ostream
.
println
(
value
);
return
;
return
;
}
}
// pretty print the path values as a list
String
[]
values
=
value
.
split
(
System
.
getProperty
(
"path.separator"
));
String
[]
values
=
value
.
split
(
System
.
getProperty
(
"path.separator"
));
int
len
=
values
.
length
;
boolean
first
=
true
;
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
String
s
:
values
)
{
if
(
i
==
0
)
{
// first line treated specially
if
(
first
)
{
// first line treated specially
ostream
.
println
(
values
[
i
]);
ostream
.
println
(
s
);
first
=
false
;
}
else
{
// following lines prefix with indents
}
else
{
// following lines prefix with indents
ostream
.
print
(
INDENT
+
INDENT
);
ostream
.
println
(
INDENT
+
INDENT
+
s
);
ostream
.
println
(
values
[
i
]);
}
}
}
}
}
}
...
@@ -236,21 +227,35 @@ public enum LauncherHelper {
...
@@ -236,21 +227,35 @@ public enum LauncherHelper {
private
static
void
printLocale
(
PrintStream
ostream
)
{
private
static
void
printLocale
(
PrintStream
ostream
)
{
Locale
locale
=
Locale
.
getDefault
();
Locale
locale
=
Locale
.
getDefault
();
ostream
.
println
(
LOCALE_SETTINGS
);
ostream
.
println
(
LOCALE_SETTINGS
);
ostream
.
println
(
INDENT
+
"default locale = "
+
locale
.
getDisplayLanguage
());
ostream
.
println
(
INDENT
+
"default locale = "
+
locale
.
getDisplayLanguage
());
ostream
.
println
(
INDENT
+
"default display locale = "
+
Locale
.
getDefault
(
Category
.
DISPLAY
).
getDisplayName
());
ostream
.
println
(
INDENT
+
"default format locale = "
+
Locale
.
getDefault
(
Category
.
FORMAT
).
getDisplayName
());
printLocales
(
ostream
);
printLocales
(
ostream
);
ostream
.
println
();
ostream
.
println
();
}
}
private
static
void
printLocales
(
PrintStream
ostream
)
{
private
static
void
printLocales
(
PrintStream
ostream
)
{
Locale
[]
locales
=
Locale
.
getAvailableLocales
();
Locale
[]
t
locales
=
Locale
.
getAvailableLocales
();
final
int
len
=
locales
==
null
?
0
:
locales
.
length
;
final
int
len
=
tlocales
==
null
?
0
:
t
locales
.
length
;
if
(
len
<
1
)
{
if
(
len
<
1
)
{
return
;
return
;
}
}
// Locale does not implement Comparable so we convert it to String
// and sort it for pretty printing.
Set
<
String
>
sortedSet
=
new
TreeSet
<>();
for
(
Locale
l
:
tlocales
)
{
sortedSet
.
add
(
l
.
toString
());
}
ostream
.
print
(
INDENT
+
"available locales = "
);
ostream
.
print
(
INDENT
+
"available locales = "
);
final
int
last
=
len
-
1
;
Iterator
<
String
>
iter
=
sortedSet
.
iterator
();
for
(
int
i
=
0
;
i
<
last
;
i
++)
{
final
int
last
=
len
-
1
;
ostream
.
print
(
locales
[
i
]);
for
(
int
i
=
0
;
iter
.
hasNext
()
;
i
++)
{
String
s
=
iter
.
next
();
ostream
.
print
(
s
);
if
(
i
!=
last
)
{
if
(
i
!=
last
)
{
ostream
.
print
(
", "
);
ostream
.
print
(
", "
);
}
}
...
@@ -260,7 +265,42 @@ public enum LauncherHelper {
...
@@ -260,7 +265,42 @@ public enum LauncherHelper {
ostream
.
print
(
INDENT
+
INDENT
);
ostream
.
print
(
INDENT
+
INDENT
);
}
}
}
}
ostream
.
println
(
locales
[
last
]);
}
private
enum
SizePrefix
{
KILO
(
1024
,
"K"
),
MEGA
(
1024
*
1024
,
"M"
),
GIGA
(
1024
*
1024
*
1024
,
"G"
),
TERA
(
1024L
*
1024L
*
1024L
*
1024L
,
"T"
);
long
size
;
String
abbrev
;
SizePrefix
(
long
size
,
String
abbrev
)
{
this
.
size
=
size
;
this
.
abbrev
=
abbrev
;
}
private
static
String
scale
(
long
v
,
SizePrefix
prefix
)
{
return
BigDecimal
.
valueOf
(
v
).
divide
(
BigDecimal
.
valueOf
(
prefix
.
size
),
2
,
RoundingMode
.
HALF_EVEN
).
toPlainString
()
+
prefix
.
abbrev
;
}
/*
* scale the incoming values to a human readable form, represented as
* K, M, G and T, see java.c parse_size for the scaled values and
* suffixes. The lowest possible scaled value is Kilo.
*/
static
String
scaleValue
(
long
v
)
{
if
(
v
<
MEGA
.
size
)
{
return
scale
(
v
,
KILO
);
}
else
if
(
v
<
GIGA
.
size
)
{
return
scale
(
v
,
MEGA
);
}
else
if
(
v
<
TERA
.
size
)
{
return
scale
(
v
,
GIGA
);
}
else
{
return
scale
(
v
,
TERA
);
}
}
}
}
/**
/**
...
...
test/tools/launcher/Settings.java
浏览文件 @
4b1ed28b
...
@@ -74,8 +74,15 @@ public class Settings {
...
@@ -74,8 +74,15 @@ public class Settings {
static
void
runTestOptionDefault
()
throws
IOException
{
static
void
runTestOptionDefault
()
throws
IOException
{
TestHelper
.
TestResult
tr
=
null
;
TestHelper
.
TestResult
tr
=
null
;
tr
=
TestHelper
.
doExec
(
TestHelper
.
javaCmd
,
"-Xmx512m"
,
"-Xss128k"
,
tr
=
TestHelper
.
doExec
(
TestHelper
.
javaCmd
,
"-Xms64m"
,
"-Xmx512m"
,
"-XshowSettings"
,
"-jar"
,
testJar
.
getAbsolutePath
());
"-Xss128k"
,
"-XshowSettings"
,
"-jar"
,
testJar
.
getAbsolutePath
());
containsAllOptions
(
tr
);
if
(!
tr
.
isOK
())
{
System
.
out
.
println
(
tr
.
status
);
throw
new
RuntimeException
(
"test fails"
);
}
tr
=
TestHelper
.
doExec
(
TestHelper
.
javaCmd
,
"-Xms65536k"
,
"-Xmx712m"
,
"-Xss122880"
,
"-XshowSettings"
,
"-jar"
,
testJar
.
getAbsolutePath
());
containsAllOptions
(
tr
);
containsAllOptions
(
tr
);
if
(!
tr
.
isOK
())
{
if
(!
tr
.
isOK
())
{
System
.
out
.
println
(
tr
.
status
);
System
.
out
.
println
(
tr
.
status
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录