Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
73f7c6a8
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看板
提交
73f7c6a8
编写于
11月 01, 2010
作者:
M
mchung
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6994413: JDK_GetVersionInfo0 only expects a two digit build number
Reviewed-by: dholmes
上级
41690c44
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
178 addition
and
8 deletion
+178
-8
src/share/native/common/jdk_util.c
src/share/native/common/jdk_util.c
+22
-8
test/sun/misc/Version/Version.java
test/sun/misc/Version/Version.java
+156
-0
未找到文件。
src/share/native/common/jdk_util.c
浏览文件 @
73f7c6a8
...
...
@@ -25,6 +25,8 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
#include "jvm.h"
#include "jdk_util.h"
...
...
@@ -45,6 +47,7 @@ JDK_GetVersionInfo0(jdk_version_info* info, size_t info_size) {
(
unsigned
int
)
atoi
(
JDK_MICRO_VERSION
);
const
char
*
jdk_build_string
=
JDK_BUILD_NUMBER
;
char
build_number
[
4
];
unsigned
int
jdk_build_number
=
0
;
const
char
*
jdk_update_string
=
JDK_UPDATE_VERSION
;
...
...
@@ -55,16 +58,28 @@ JDK_GetVersionInfo0(jdk_version_info* info, size_t info_size) {
/* If the JDK_BUILD_NUMBER is of format bXX and XX is an integer
* XX is the jdk_build_number.
*/
if
(
strlen
(
jdk_build_string
)
==
3
)
{
if
(
jdk_build_string
[
0
]
==
'b'
&&
jdk_build_string
[
1
]
>=
'0'
&&
jdk_build_string
[
1
]
<=
'9'
&&
jdk_build_string
[
2
]
>=
'0'
&&
jdk_build_string
[
2
]
<=
'9'
)
{
jdk_build_number
=
(
unsigned
int
)
atoi
(
&
jdk_build_string
[
1
]);
int
len
=
strlen
(
jdk_build_string
);
if
(
jdk_build_string
[
0
]
==
'b'
&&
len
>=
2
)
{
int
i
=
0
;
for
(
i
=
1
;
i
<
len
;
i
++
)
{
if
(
isdigit
(
jdk_build_string
[
i
]))
{
build_number
[
i
-
1
]
=
jdk_build_string
[
i
];
}
else
{
// invalid build number
i
=
-
1
;
break
;
}
}
if
(
i
==
len
)
{
build_number
[
len
-
1
]
=
'\0'
;
jdk_build_number
=
(
unsigned
int
)
atoi
(
build_number
)
;
}
}
assert
(
jdk_build_number
>=
0
&&
jdk_build_number
<=
255
);
if
(
strlen
(
jdk_update_string
)
==
2
||
strlen
(
jdk_update_string
)
==
3
)
{
if
(
jdk_update_string
[
0
]
>=
'0'
&&
jdk_update_string
[
0
]
<=
'9'
&&
jdk_update_string
[
1
]
>=
'0'
&&
jdk_update_string
[
1
]
<=
'9'
)
{
if
(
isdigit
(
jdk_update_string
[
0
])
&&
isdigit
(
jdk_update_string
[
1
]))
{
update_ver
[
0
]
=
jdk_update_string
[
0
];
update_ver
[
1
]
=
jdk_update_string
[
1
];
update_ver
[
2
]
=
'\0'
;
...
...
@@ -75,7 +90,6 @@ JDK_GetVersionInfo0(jdk_version_info* info, size_t info_size) {
}
}
memset
(
info
,
0
,
info_size
);
info
->
jdk_version
=
((
jdk_major_version
&
0xFF
)
<<
24
)
|
((
jdk_minor_version
&
0xFF
)
<<
16
)
|
...
...
test/sun/misc/Version/Version.java
0 → 100644
浏览文件 @
73f7c6a8
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 6994413
* @summary Check the JDK and JVM version returned by sun.misc.Version
* matches the versions defined in the system properties
* @compile -XDignore.symbol.file Version.java
* @run main Version
*/
import
static
sun
.
misc
.
Version
.*;
public
class
Version
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
VersionInfo
jdk
=
newVersionInfo
(
System
.
getProperty
(
"java.runtime.version"
));
VersionInfo
v1
=
new
VersionInfo
(
jdkMajorVersion
(),
jdkMinorVersion
(),
jdkMicroVersion
(),
jdkUpdateVersion
(),
jdkSpecialVersion
(),
jdkBuildNumber
());
System
.
out
.
println
(
"JDK version = "
+
jdk
+
" "
+
v1
);
if
(!
jdk
.
equals
(
v1
))
{
throw
new
RuntimeException
(
"Unmatched version: "
+
jdk
+
" vs "
+
v1
);
}
VersionInfo
jvm
=
newVersionInfo
(
System
.
getProperty
(
"java.vm.version"
));
VersionInfo
v2
=
new
VersionInfo
(
jvmMajorVersion
(),
jvmMinorVersion
(),
jvmMicroVersion
(),
jvmUpdateVersion
(),
jvmSpecialVersion
(),
jvmBuildNumber
());
System
.
out
.
println
(
"JVM version = "
+
jvm
+
" "
+
v2
);
if
(!
jvm
.
equals
(
v2
))
{
throw
new
RuntimeException
(
"Unmatched version: "
+
jvm
+
" vs "
+
v2
);
}
}
static
class
VersionInfo
{
final
int
major
;
final
int
minor
;
final
int
micro
;
final
int
update
;
final
String
special
;
final
int
build
;
VersionInfo
(
int
major
,
int
minor
,
int
micro
,
int
update
,
String
special
,
int
build
)
{
this
.
major
=
major
;
this
.
minor
=
minor
;
this
.
micro
=
micro
;
this
.
update
=
update
;
this
.
special
=
special
;
this
.
build
=
build
;
}
public
boolean
equals
(
VersionInfo
v
)
{
return
(
this
.
major
==
v
.
major
&&
this
.
minor
==
v
.
minor
&&
this
.
micro
==
v
.
micro
&&
this
.
update
==
v
.
update
&&
this
.
special
.
equals
(
v
.
special
)
&&
this
.
build
==
v
.
build
);
}
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
major
+
"."
+
minor
+
"."
+
micro
);
if
(
update
>
0
)
{
sb
.
append
(
"_"
+
update
);
}
if
(!
special
.
isEmpty
())
{
sb
.
append
(
special
);
}
sb
.
append
(
"-b"
+
build
);
return
sb
.
toString
();
}
}
private
static
VersionInfo
newVersionInfo
(
String
version
)
throws
Exception
{
// valid format of the version string is:
// n.n.n[_uu[c]][-<identifer>]-bxx
int
major
=
0
;
int
minor
=
0
;
int
micro
=
0
;
int
update
=
0
;
String
special
=
""
;
int
build
=
0
;
CharSequence
cs
=
version
;
if
(
cs
.
length
()
>=
5
)
{
if
(
Character
.
isDigit
(
cs
.
charAt
(
0
))
&&
cs
.
charAt
(
1
)
==
'.'
&&
Character
.
isDigit
(
cs
.
charAt
(
2
))
&&
cs
.
charAt
(
3
)
==
'.'
&&
Character
.
isDigit
(
cs
.
charAt
(
4
)))
{
major
=
Character
.
digit
(
cs
.
charAt
(
0
),
10
);
minor
=
Character
.
digit
(
cs
.
charAt
(
2
),
10
);
micro
=
Character
.
digit
(
cs
.
charAt
(
4
),
10
);
cs
=
cs
.
subSequence
(
5
,
cs
.
length
());
}
else
if
(
Character
.
isDigit
(
cs
.
charAt
(
0
))
&&
Character
.
isDigit
(
cs
.
charAt
(
1
))
&&
cs
.
charAt
(
2
)
==
'.'
&&
Character
.
isDigit
(
cs
.
charAt
(
3
)))
{
// HSX has nn.n (major.minor) version
major
=
Integer
.
valueOf
(
version
.
substring
(
0
,
2
)).
intValue
();
minor
=
Character
.
digit
(
cs
.
charAt
(
3
),
10
);
cs
=
cs
.
subSequence
(
4
,
cs
.
length
());
}
if
(
cs
.
charAt
(
0
)
==
'_'
&&
cs
.
length
()
>=
3
&&
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
(
String
s
:
res
)
{
if
(
s
.
charAt
(
0
)
==
'b'
)
{
build
=
Integer
.
valueOf
(
s
.
substring
(
1
,
s
.
length
())).
intValue
();
break
;
}
}
}
}
return
new
VersionInfo
(
major
,
minor
,
micro
,
update
,
special
,
build
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录