Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
2deb6469
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看板
提交
2deb6469
编写于
11月 30, 2015
作者:
R
robm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8140344: add support for 3 digit update release numbers
Reviewed-by: coffeys
上级
e287868b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
90 addition
and
78 deletion
+90
-78
src/share/classes/sun/misc/Version.java.template
src/share/classes/sun/misc/Version.java.template
+16
-7
src/share/native/common/jdk_util.c
src/share/native/common/jdk_util.c
+11
-9
test/sun/misc/Version/Version.java
test/sun/misc/Version/Version.java
+63
-62
未找到文件。
src/share/classes/sun/misc/Version.java.template
浏览文件 @
2deb6469
...
@@ -291,15 +291,24 @@ public class Version {
...
@@ -291,15 +291,24 @@ public class Version {
jvm_minor_version = Character.digit(cs.charAt(2), 10);
jvm_minor_version = Character.digit(cs.charAt(2), 10);
jvm_micro_version = Character.digit(cs.charAt(4), 10);
jvm_micro_version = Character.digit(cs.charAt(4), 10);
cs = cs.subSequence(5, cs.length());
cs = cs.subSequence(5, cs.length());
if (cs.charAt(0) == '
_
' && cs.length() >= 3 &&
if (cs.charAt(0) == '
_
' && cs.length() >= 3) {
Character.isDigit(cs.charAt(1)) &&
int nextChar = 0;
Character.isDigit(cs.charAt(2))) {
if (Character.isDigit(cs.charAt(1)) &&
int nextChar = 3;
Character.isDigit(cs.charAt(2)) &&
Character.isDigit(cs.charAt(3)))
{
nextChar = 4;
} else if (Character.isDigit(cs.charAt(1)) &&
Character.isDigit(cs.charAt(2)))
{
nextChar = 3;
}
try {
try {
String uu = cs.subSequence(1,
3
).toString();
String uu = cs.subSequence(1,
nextChar
).toString();
jvm_update_version = Integer.valueOf(uu).intValue();
jvm_update_version = Integer.valueOf(uu).intValue();
if (cs.length() >=
4
) {
if (cs.length() >=
nextChar + 1
) {
char c = cs.charAt(
3
);
char c = cs.charAt(
nextChar
);
if (c >= '
a
' && c <= '
z
') {
if (c >= '
a
' && c <= '
z
') {
jvm_special_version = Character.toString(c);
jvm_special_version = Character.toString(c);
nextChar++;
nextChar++;
...
...
src/share/native/common/jdk_util.c
浏览文件 @
2deb6469
...
@@ -52,6 +52,7 @@ JDK_GetVersionInfo0(jdk_version_info* info, size_t info_size) {
...
@@ -52,6 +52,7 @@ JDK_GetVersionInfo0(jdk_version_info* info, size_t info_size) {
const
char
*
jdk_update_string
=
JDK_UPDATE_VERSION
;
const
char
*
jdk_update_string
=
JDK_UPDATE_VERSION
;
unsigned
int
jdk_update_version
=
0
;
unsigned
int
jdk_update_version
=
0
;
int
len_update_ver
=
0
;
char
update_ver
[
3
];
char
update_ver
[
3
];
char
jdk_special_version
=
'\0'
;
char
jdk_special_version
=
'\0'
;
...
@@ -78,16 +79,17 @@ JDK_GetVersionInfo0(jdk_version_info* info, size_t info_size) {
...
@@ -78,16 +79,17 @@ JDK_GetVersionInfo0(jdk_version_info* info, size_t info_size) {
assert
(
jdk_build_number
>=
0
&&
jdk_build_number
<=
255
);
assert
(
jdk_build_number
>=
0
&&
jdk_build_number
<=
255
);
if
(
strlen
(
jdk_update_string
)
==
2
||
strlen
(
jdk_update_string
)
==
3
)
{
len_update_ver
=
strlen
(
jdk_update_string
);
if
(
isdigit
(
jdk_update_string
[
0
])
&&
isdigit
(
jdk_update_string
[
1
]))
{
if
(
len_update_ver
>=
2
&&
len_update_ver
<=
4
)
{
update_ver
[
0
]
=
jdk_update_string
[
0
];
int
update_digits
=
len_update_ver
;
update_ver
[
1
]
=
jdk_update_string
[
1
];
update_ver
[
2
]
=
'\0'
;
if
(
!
isdigit
(
jdk_update_string
[
len_update_ver
-
1
]))
{
jdk_update_version
=
(
unsigned
int
)
atoi
(
update_ver
);
jdk_special_version
=
jdk_update_string
[
len_update_ver
-
1
];
if
(
strlen
(
jdk_update_string
)
==
3
)
{
update_digits
=
len_update_ver
-
1
;
jdk_special_version
=
jdk_update_string
[
2
];
}
}
}
strncpy
(
update_ver
,
jdk_update_string
,
update_digits
);
update_ver
[
update_digits
]
=
'\0'
;
jdk_update_version
=
(
unsigned
int
)
atoi
(
update_ver
);
}
}
memset
(
info
,
0
,
info_size
);
memset
(
info
,
0
,
info_size
);
...
...
test/sun/misc/Version/Version.java
浏览文件 @
2deb6469
...
@@ -29,11 +29,13 @@
...
@@ -29,11 +29,13 @@
* @run main Version
* @run main Version
*/
*/
import
java.util.regex.*
;
import
static
sun
.
misc
.
Version
.*;
import
static
sun
.
misc
.
Version
.*;
public
class
Version
{
public
class
Version
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
VersionInfo
jdk
=
new
VersionInfo
(
System
.
getProperty
(
"java.runtime.version"
));
VersionInfo
jdk
=
jdk
VersionInfo
(
System
.
getProperty
(
"java.runtime.version"
));
VersionInfo
v1
=
new
VersionInfo
(
jdkMajorVersion
(),
VersionInfo
v1
=
new
VersionInfo
(
jdkMajorVersion
(),
jdkMinorVersion
(),
jdkMinorVersion
(),
jdkMicroVersion
(),
jdkMicroVersion
(),
...
@@ -44,7 +46,7 @@ public class Version {
...
@@ -44,7 +46,7 @@ public class Version {
if
(!
jdk
.
equals
(
v1
))
{
if
(!
jdk
.
equals
(
v1
))
{
throw
new
RuntimeException
(
"Unmatched version: "
+
jdk
+
" vs "
+
v1
);
throw
new
RuntimeException
(
"Unmatched version: "
+
jdk
+
" vs "
+
v1
);
}
}
VersionInfo
jvm
=
new
VersionInfo
(
System
.
getProperty
(
"java.vm.version"
));
VersionInfo
jvm
=
jvm
VersionInfo
(
System
.
getProperty
(
"java.vm.version"
));
VersionInfo
v2
=
new
VersionInfo
(
jvmMajorVersion
(),
VersionInfo
v2
=
new
VersionInfo
(
jvmMajorVersion
(),
jvmMinorVersion
(),
jvmMinorVersion
(),
jvmMicroVersion
(),
jvmMicroVersion
(),
...
@@ -95,74 +97,73 @@ public class Version {
...
@@ -95,74 +97,73 @@ public class Version {
}
}
}
}
private
static
VersionInfo
new
VersionInfo
(
String
version
)
throws
Exception
{
private
static
VersionInfo
jdk
VersionInfo
(
String
version
)
throws
Exception
{
// valid format of the version string is:
// valid format of the version string is:
//
n.n.n[_uu[c]][-<identif
er>]-bxx
//
<major>.<minor>[.<micro>][_uu[c]][-<identifi
er>]-bxx
int
major
=
0
;
int
major
=
0
;
int
minor
=
0
;
int
minor
=
0
;
int
micro
=
0
;
int
micro
=
0
;
int
update
=
0
;
int
update
=
0
;
String
special
=
""
;
String
special
=
""
;
int
build
=
0
;
int
build
=
0
;
CharSequence
cs
=
version
;
if
(
cs
.
length
()
>=
5
)
{
String
regex
=
"^([0-9]{1,2})"
;
// major
if
(
Character
.
isDigit
(
cs
.
charAt
(
0
))
&&
cs
.
charAt
(
1
)
==
'.'
&&
regex
+=
"\\."
;
// separator
Character
.
isDigit
(
cs
.
charAt
(
2
))
&&
cs
.
charAt
(
3
)
==
'.'
&&
regex
+=
"([0-9]{1,2})"
;
// minor
Character
.
isDigit
(
cs
.
charAt
(
4
)))
{
regex
+=
"(\\."
;
// separator
major
=
Character
.
digit
(
cs
.
charAt
(
0
),
10
);
regex
+=
"([0-9]{1,2})"
;
// micro
minor
=
Character
.
digit
(
cs
.
charAt
(
2
),
10
);
regex
+=
")?"
;
// micro is optional
micro
=
Character
.
digit
(
cs
.
charAt
(
4
),
10
);
regex
+=
"(_"
;
cs
=
cs
.
subSequence
(
5
,
cs
.
length
());
regex
+=
"([0-9]{2,3})"
;
// update
}
else
if
(
Character
.
isDigit
(
cs
.
charAt
(
0
))
&&
regex
+=
"([a-z])?"
;
// special char (optional)
Character
.
isDigit
(
cs
.
charAt
(
1
))
&&
cs
.
charAt
(
2
)
==
'.'
&&
regex
+=
")?"
;
// _uu[c] is optional
Character
.
isDigit
(
cs
.
charAt
(
3
)))
{
regex
+=
".*"
;
// -<identifier>
// HSX has nn.n[n] (major.minor) version
regex
+=
"(\\-b([0-9]{1,3}$))"
;
// JDK -bxx
major
=
Integer
.
valueOf
(
version
.
substring
(
0
,
2
)).
intValue
();
if
(
Character
.
isDigit
(
cs
.
charAt
(
4
)))
{
Pattern
p
=
Pattern
.
compile
(
regex
);
minor
=
Integer
.
valueOf
(
version
.
substring
(
3
,
5
)).
intValue
();
Matcher
m
=
p
.
matcher
(
version
);
cs
=
cs
.
subSequence
(
5
,
cs
.
length
());
m
.
matches
();
}
else
{
major
=
Integer
.
parseInt
(
m
.
group
(
1
));
minor
=
Character
.
digit
(
cs
.
charAt
(
3
),
10
);
minor
=
Integer
.
parseInt
(
m
.
group
(
2
));
cs
=
cs
.
subSequence
(
4
,
cs
.
length
());
micro
=
(
m
.
group
(
4
)
==
null
)
?
0
:
Integer
.
parseInt
(
m
.
group
(
4
));
}
update
=
(
m
.
group
(
6
)
==
null
)
?
0
:
Integer
.
parseInt
(
m
.
group
(
6
));
}
special
=
(
m
.
group
(
7
)
==
null
)
?
""
:
m
.
group
(
7
);
if
(
cs
.
charAt
(
0
)
==
'_'
&&
cs
.
length
()
>=
3
&&
build
=
Integer
.
parseInt
(
m
.
group
(
9
));
Character
.
isDigit
(
cs
.
charAt
(
1
))
&&
Character
.
isDigit
(
cs
.
charAt
(
2
)))
{
int
nextChar
=
3
;
String
uu
=
cs
.
subSequence
(
1
,
3
).
toString
();
update
=
Integer
.
valueOf
(
uu
).
intValue
();
if
(
cs
.
length
()
>=
4
)
{
char
c
=
cs
.
charAt
(
3
);
if
(
c
>=
'a'
&&
c
<=
'z'
)
{
special
=
Character
.
toString
(
c
);
nextChar
++;
}
}
cs
=
cs
.
subSequence
(
nextChar
,
cs
.
length
());
}
if
(
cs
.
charAt
(
0
)
==
'-'
)
{
// skip the first character
// valid format: <identifier>-bxx or bxx
// non-product VM will have -debug|-release appended
cs
=
cs
.
subSequence
(
1
,
cs
.
length
());
String
[]
res
=
cs
.
toString
().
split
(
"-"
);
for
(
int
i
=
res
.
length
-
1
;
i
>=
0
;
i
--)
{
String
s
=
res
[
i
];
if
(
s
.
charAt
(
0
)
==
'b'
)
{
try
{
build
=
Integer
.
parseInt
(
s
.
substring
(
1
,
s
.
length
()));
break
;
}
catch
(
NumberFormatException
nfe
)
{
// ignore
}
}
}
}
}
VersionInfo
vi
=
new
VersionInfo
(
major
,
minor
,
micro
,
update
,
special
,
build
);
VersionInfo
vi
=
new
VersionInfo
(
major
,
minor
,
micro
,
update
,
special
,
build
);
System
.
out
.
printf
(
"
new
VersionInfo: input=%s output=%s\n"
,
version
,
vi
);
System
.
out
.
printf
(
"
jdk
VersionInfo: input=%s output=%s\n"
,
version
,
vi
);
return
vi
;
return
vi
;
}
}
private
static
VersionInfo
jvmVersionInfo
(
String
version
)
throws
Exception
{
try
{
// valid format of the version string is:
// <major>.<minor>-bxx[-<identifier>][-<debug_flavor>]
int
major
=
0
;
int
minor
=
0
;
int
build
=
0
;
String
regex
=
"^([0-9]{1,2})"
;
// major
regex
+=
"\\."
;
// separator
regex
+=
"([0-9]{1,2})"
;
// minor
regex
+=
"(\\-b([0-9]{1,3}))"
;
// JVM -bxx
regex
+=
".*"
;
Pattern
p
=
Pattern
.
compile
(
regex
);
Matcher
m
=
p
.
matcher
(
version
);
m
.
matches
();
major
=
Integer
.
parseInt
(
m
.
group
(
1
));
minor
=
Integer
.
parseInt
(
m
.
group
(
2
));
build
=
Integer
.
parseInt
(
m
.
group
(
4
));
VersionInfo
vi
=
new
VersionInfo
(
major
,
minor
,
0
,
0
,
""
,
build
);
System
.
out
.
printf
(
"jvmVersionInfo: input=%s output=%s\n"
,
version
,
vi
);
return
vi
;
}
catch
(
IllegalStateException
e
)
{
// local builds may also follow the jdkVersionInfo format
return
jdkVersionInfo
(
version
);
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录