Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
934917b1
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看板
提交
934917b1
编写于
2月 01, 2013
作者:
W
weijun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8006564: Test sun/security/util/Oid/S11N.sh fails with timeout on Linux 32-bit
Reviewed-by: alanb
上级
2e1828c0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
246 addition
and
254 deletion
+246
-254
test/sun/security/util/Oid/S11N.java
test/sun/security/util/Oid/S11N.java
+246
-0
test/sun/security/util/Oid/S11N.sh
test/sun/security/util/Oid/S11N.sh
+0
-188
test/sun/security/util/Oid/SerialTest.java
test/sun/security/util/Oid/SerialTest.java
+0
-66
未找到文件。
test/sun/security/util/Oid/S11N.java
0 → 100644
浏览文件 @
934917b1
/*
* Copyright (c) 2013, 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 4811968 6908628 8006564
* @run main S11N check
* @summary Serialization compatibility with old versions (and fixes)
*/
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.ObjectInputStream
;
import
java.io.ObjectOutputStream
;
import
java.util.HashMap
;
import
java.util.Map
;
import
sun.misc.BASE64Encoder
;
import
sun.security.util.ObjectIdentifier
;
public
class
S11N
{
static
String
[]
SMALL
=
{
"0.0"
,
"1.1"
,
"2.2"
,
"1.2.3456"
,
"1.2.2147483647.4"
,
"1.2.268435456.4"
,
};
static
String
[]
HUGE
=
{
"2.16.764.1.3101555394.1.0.100.2.1"
,
"1.2.2147483648.4"
,
"2.3.4444444444444444444444"
,
"1.2.8888888888888888.33333333333333333.44444444444444"
,
};
// Do not use j.u.Base64, the test needs to run in jdk6
static
BASE64Encoder
encoder
=
new
BASE64Encoder
()
{
@Override
protected
int
bytesPerLine
()
{
return
48
;
}
};
public
static
void
main
(
String
[]
args
)
throws
Exception
{
if
(
args
[
0
].
equals
(
"check"
))
{
int
version
=
Integer
.
valueOf
(
System
.
getProperty
(
"java.version"
)
.
split
(
"\\."
)[
1
]);
System
.
out
.
println
(
"version is "
+
version
);
if
(
version
>=
7
)
{
for
(
String
oid:
SMALL
)
{
// 7 -> 7
check
(
out
(
oid
),
oid
);
// 6 -> 7
check
(
out6
(
oid
),
oid
);
}
for
(
String
oid:
HUGE
)
{
// 7 -> 7
check
(
out
(
oid
),
oid
);
}
}
else
{
for
(
String
oid:
SMALL
)
{
// 6 -> 6
check
(
out
(
oid
),
oid
);
// 7 -> 6
check
(
out7
(
oid
),
oid
);
}
for
(
String
oid:
HUGE
)
{
// 7 -> 6 fails for HUGE oids
boolean
ok
=
false
;
try
{
check
(
out7
(
oid
),
oid
);
ok
=
true
;
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
);
}
if
(
ok
)
{
throw
new
Exception
();
}
}
}
}
else
{
// Generates the JDK6 serialized string inside this test, call
// $JDK7/bin/java S11N dump7
// $JDK6/bin/java S11N dump6
// and paste the output at the end of this test.
dump
(
args
[
0
],
SMALL
);
// For jdk6, the following line will throw an exception, ignore it
dump
(
args
[
0
],
HUGE
);
}
}
// Gets the serialized form for jdk6
private
static
byte
[]
out6
(
String
oid
)
throws
Exception
{
return
new
sun
.
misc
.
BASE64Decoder
().
decodeBuffer
(
dump6
.
get
(
oid
));
}
// Gets the serialized form for jdk7
private
static
byte
[]
out7
(
String
oid
)
throws
Exception
{
return
new
sun
.
misc
.
BASE64Decoder
().
decodeBuffer
(
dump7
.
get
(
oid
));
}
// Gets the serialized form for this java
private
static
byte
[]
out
(
String
oid
)
throws
Exception
{
ByteArrayOutputStream
bout
=
new
ByteArrayOutputStream
();
new
ObjectOutputStream
(
bout
).
writeObject
(
new
ObjectIdentifier
(
oid
));
return
bout
.
toByteArray
();
}
// Makes sure serialized form can be deserialized
private
static
void
check
(
byte
[]
in
,
String
oid
)
throws
Exception
{
ObjectIdentifier
o
=
(
ObjectIdentifier
)
(
new
ObjectInputStream
(
new
ByteArrayInputStream
(
in
)).
readObject
());
if
(!
o
.
toString
().
equals
(
oid
))
{
throw
new
Exception
(
"Read Fail "
+
o
+
", not "
+
oid
);
}
}
// dump serialized form to java code style text
private
static
void
dump
(
String
title
,
String
[]
oids
)
throws
Exception
{
for
(
String
oid:
oids
)
{
String
[]
base64
=
encoder
.
encodeBuffer
(
out
(
oid
)).
split
(
"\n"
);
System
.
out
.
println
(
" "
+
title
+
".put(\""
+
oid
+
"\","
);
for
(
int
i
=
0
;
i
<
base64
.
length
;
i
++)
{
System
.
out
.
print
(
" \""
+
base64
[
i
]
+
"\""
);
if
(
i
==
base64
.
length
-
1
)
{
System
.
out
.
println
(
");"
);
}
else
{
System
.
out
.
println
(
" +"
);
}
}
}
}
// Do not use diamond operator, this test is also meant to run in jdk6
private
static
Map
<
String
,
String
>
dump7
=
new
HashMap
<
String
,
String
>();
private
static
Map
<
String
,
String
>
dump6
=
new
HashMap
<
String
,
String
>();
static
{
////////////// PASTE BEGIN //////////////
dump7
.
put
(
"0.0"
,
"rO0ABXNyACJzdW4uc2VjdXJpdHkudXRpbC5PYmplY3RJZGVudGlmaWVyeLIO7GQX"
+
"fy4DAANJAAxjb21wb25lbnRMZW5MAApjb21wb25lbnRzdAASTGphdmEvbGFuZy9P"
+
"YmplY3Q7WwAIZW5jb2Rpbmd0AAJbQnhwAAAAAnVyAAJbSU26YCZ26rKlAgAAeHAA"
+
"AAACAAAAAAAAAAB1cgACW0Ks8xf4BghU4AIAAHhwAAAAAQB4"
);
dump7
.
put
(
"1.1"
,
"rO0ABXNyACJzdW4uc2VjdXJpdHkudXRpbC5PYmplY3RJZGVudGlmaWVyeLIO7GQX"
+
"fy4DAANJAAxjb21wb25lbnRMZW5MAApjb21wb25lbnRzdAASTGphdmEvbGFuZy9P"
+
"YmplY3Q7WwAIZW5jb2Rpbmd0AAJbQnhwAAAAAnVyAAJbSU26YCZ26rKlAgAAeHAA"
+
"AAACAAAAAQAAAAF1cgACW0Ks8xf4BghU4AIAAHhwAAAAASl4"
);
dump7
.
put
(
"2.2"
,
"rO0ABXNyACJzdW4uc2VjdXJpdHkudXRpbC5PYmplY3RJZGVudGlmaWVyeLIO7GQX"
+
"fy4DAANJAAxjb21wb25lbnRMZW5MAApjb21wb25lbnRzdAASTGphdmEvbGFuZy9P"
+
"YmplY3Q7WwAIZW5jb2Rpbmd0AAJbQnhwAAAAAnVyAAJbSU26YCZ26rKlAgAAeHAA"
+
"AAACAAAAAgAAAAJ1cgACW0Ks8xf4BghU4AIAAHhwAAAAAVJ4"
);
dump7
.
put
(
"1.2.3456"
,
"rO0ABXNyACJzdW4uc2VjdXJpdHkudXRpbC5PYmplY3RJZGVudGl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mplY3RJZGVudGlmaWVyJEh1Z2VPaWROb3RTdXBwb3J0ZWRCeU9sZEpESwAA"
+
"AAAAAAABAgAAeHB1cgACW0Ks8xf4BghU4AIAAHhwAAAADmCFfAGLxvf1QgEAZAIB"
+
"eA=="
);
dump7
.
put
(
"1.2.2147483648.4"
,
"rO0ABXNyACJzdW4uc2VjdXJpdHkudXRpbC5PYmplY3RJZGVudGlmaWVyeLIO7GQX"
+
"fy4DAANJAAxjb21wb25lbnRMZW5MAApjb21wb25lbnRzdAASTGphdmEvbGFuZy9P"
+
"YmplY3Q7WwAIZW5jb2Rpbmd0AAJbQnhw/////3NyAD5zdW4uc2VjdXJpdHkudXRp"
+
"bC5PYmplY3RJZGVudGlmaWVyJEh1Z2VPaWROb3RTdXBwb3J0ZWRCeU9sZEpESwAA"
+
"AAAAAAABAgAAeHB1cgACW0Ks8xf4BghU4AIAAHhwAAAAByqIgICAAAR4"
);
dump7
.
put
(
"2.3.4444444444444444444444"
,
"rO0ABXNyACJzdW4uc2VjdXJpdHkudXRpbC5PYmplY3RJZGVudGlmaWVyeLIO7GQX"
+
"fy4DAANJAAxjb21wb25lbnRMZW5MAApjb21wb25lbnRzdAASTGphdmEvbGFuZy9P"
+
"YmplY3Q7WwAIZW5jb2Rpbmd0AAJbQnhw/////3NyAD5zdW4uc2VjdXJpdHkudXRp"
+
"bC5PYmplY3RJZGVudGlmaWVyJEh1Z2VPaWROb3RTdXBwb3J0ZWRCeU9sZEpESwAA"
+
"AAAAAAABAgAAeHB1cgACW0Ks8xf4BghU4AIAAHhwAAAADFOD4e+HpNG968eOHHg="
);
dump7
.
put
(
"1.2.8888888888888888.33333333333333333.44444444444444"
,
"rO0ABXNyACJzdW4uc2VjdXJpdHkudXRpbC5PYmplY3RJZGVudGlmaWVyeLIO7GQX"
+
"fy4DAANJAAxjb21wb25lbnRMZW5MAApjb21wb25lbnRzdAASTGphdmEvbGFuZy9P"
+
"YmplY3Q7WwAIZW5jb2Rpbmd0AAJbQnhw/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AJJAAxjb21wb25lbnRMZW5bAApjb21wb25lbnRzdAACW0l4cAAAAAR1cgAC"
+
"W0lNumAmduqypQIAAHhwAAAABAAAAAEAAAACf////wAAAAQ="
);
dump6
.
put
(
"1.2.268435456.4"
,
"rO0ABXNyACJzdW4uc2VjdXJpdHkudXRpbC5PYmplY3RJZGVudGlmaWVyeLIO7GQX"
+
"fy4CAAJJAAxjb21wb25lbnRMZW5bAApjb21wb25lbnRzdAACW0l4cAAAAAR1cgAC"
+
"W0lNumAmduqypQIAAHhwAAAABAAAAAEAAAACEAAAAAAAAAQ="
);
////////////// PASTE END //////////////
}
}
test/sun/security/util/Oid/S11N.sh
已删除
100644 → 0
浏览文件 @
2e1828c0
#
# Copyright (c) 2004, 2012, 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 4811968 6908628
# @summary Serialization compatibility with old versions (and fix)
# @author Weijun Wang
#
# set a few environment variables so that the shell-script can run stand-alone
# in the source directory
if
[
"
${
TESTSRC
}
"
=
""
]
;
then
TESTSRC
=
"."
fi
if
[
"
${
TESTCLASSES
}
"
=
""
]
;
then
TESTCLASSES
=
"."
fi
if
[
"
${
TESTJAVA
}
"
=
""
]
;
then
echo
"TESTJAVA not set. Test cannot execute."
echo
"FAILED!!!"
exit
1
fi
if
[
"
${
COMPILEJAVA
}
"
=
""
]
;
then
COMPILEJAVA
=
"
${
TESTJAVA
}
"
fi
# set platform-dependent variables
PF
=
""
OS
=
`
uname
-s
`
case
"
$OS
"
in
SunOS
)
FS
=
"/"
ARCH
=
`
isainfo
`
case
"
$ARCH
"
in
sparc
*
)
PF
=
"solaris-sparc"
;;
i[3-6]86
)
PF
=
"solaris-i586"
;;
amd64
*
)
PF
=
"solaris-amd64"
;;
*
)
echo
"Unsupported System: Solaris
${
ARCH
}
"
exit
0
;
;;
esac
;;
Linux
)
ARCH
=
`
uname
-m
`
FS
=
"/"
case
"
$ARCH
"
in
i[3-6]86
)
PF
=
"linux-i586"
;;
amd64
*
|
x86_64
)
PF
=
"linux-amd64"
;;
*
)
echo
"Unsupported System: Linux
${
ARCH
}
"
exit
0
;
;;
esac
;;
Windows
*
)
FS
=
"
\\
"
PF
=
"windows-i586"
# 'uname -m' does not give us enough information -
# should rely on $PROCESSOR_IDENTIFIER (as is done in Defs-windows.gmk),
# but JTREG does not pass this env variable when executing a shell script.
#
# execute test program - rely on it to exit if platform unsupported
;;
*
)
echo
"Unsupported System:
${
OS
}
"
exit
0
;
;;
esac
echo
"==================================================="
echo
"Try to set ALT_JAVA_RE_JDK if you see timeout error"
echo
"==================================================="
# the test code
${
COMPILEJAVA
}${
FS
}
bin
${
FS
}
javac
-target
1.4
-source
1.4
\
-d
.
${
TESTSRC
}${
FS
}
SerialTest.java
||
exit
10
# You can set ALT_JAVA_RE_JDK to another location that contains the
# binaries for older JDK releases. You can set it to a non-existent
# directory to skip the interop tests between different versions.
if
[
"
$ALT_JAVA_RE_JDK
"
=
""
]
;
then
JAVA_RE_JDK
=
/java/re/j2se
else
JAVA_RE_JDK
=
$ALT_JAVA_RE_JDK
fi
OLDJAVA
=
"
$JAVA_RE_JDK
/1.6.0/latest/binaries/
${
PF
}
$JAVA_RE_JDK
/1.5.0/latest/binaries/
${
PF
}
$JAVA_RE_JDK
/1.4.2/latest/binaries/
${
PF
}
"
SMALL
=
"
0.0
1.1
2.2
1.2.3456
1.2.2147483647.4
1.2.268435456.4
"
HUGE
=
"
2.16.764.1.3101555394.1.0.100.2.1
1.2.2147483648.4
2.3.4444444444444444444444
1.2.888888888888888888.111111111111111.2222222222222.33333333333333333.44444444444444
"
for
oid
in
${
SMALL
}
;
do
echo
${
oid
}
# new ->
${
TESTJAVA
}${
FS
}
bin
${
FS
}
java SerialTest out
${
oid
}
>
tmp.oid.serial
||
exit
1
# -> new
${
TESTJAVA
}${
FS
}
bin
${
FS
}
java SerialTest
in
${
oid
}
< tmp.oid.serial
||
exit
2
for
oldj
in
${
OLDJAVA
}
;
do
if
[
-d
${
oldj
}
]
;
then
echo
${
oldj
}
# -> old
${
oldj
}${
FS
}
bin
${
FS
}
java SerialTest
in
${
oid
}
< tmp.oid.serial
||
exit
3
# old ->
${
oldj
}${
FS
}
bin
${
FS
}
java SerialTest out
${
oid
}
>
tmp.oid.serial.old
||
exit
4
# -> new
${
TESTJAVA
}${
FS
}
bin
${
FS
}
java SerialTest
in
${
oid
}
< tmp.oid.serial.old
||
exit
5
fi
done
done
for
oid
in
${
HUGE
}
;
do
echo
${
oid
}
# new ->
${
TESTJAVA
}${
FS
}
bin
${
FS
}
java SerialTest out
${
oid
}
>
tmp.oid.serial
||
exit
1
# -> new
${
TESTJAVA
}${
FS
}
bin
${
FS
}
java SerialTest
in
${
oid
}
< tmp.oid.serial
||
exit
2
for
oldj
in
${
OLDJAVA
}
;
do
if
[
-d
${
oldj
}
]
;
then
echo
${
oldj
}
# -> old
${
oldj
}${
FS
}
bin
${
FS
}
java SerialTest badin < tmp.oid.serial
||
exit
3
fi
done
done
rm
-f
tmp.oid.serial
rm
-f
tmp.oid.serial.old
rm
-f
SerialTest.class
for
oldj
in
${
OLDJAVA
}
;
do
if
[
!
-d
${
oldj
}
]
;
then
echo
WARNING:
${
oldj
}
is missing. Test incomplete!
>
/dev/stderr
fi
done
exit
0
test/sun/security/util/Oid/SerialTest.java
已删除
100644 → 0
浏览文件 @
2e1828c0
/*
* Copyright (c) 2004, 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.
*/
/*
* read S11.sh
*/
import
java.io.*
;
import
sun.security.util.*
;
/**
* Test OID serialization between versions
*
* java SerialTest out oid // write a OID into System.out
* java SerialTest in oid // read from System.in and compare it with oid
* java SerialTest badin // make sure *cannot* read from System.in
*/
class
SerialTest
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
if
(
args
[
0
].
equals
(
"out"
))
out
(
args
[
1
]);
else
if
(
args
[
0
].
equals
(
"in"
))
in
(
args
[
1
]);
else
badin
();
}
static
void
in
(
String
oid
)
throws
Exception
{
ObjectIdentifier
o
=
(
ObjectIdentifier
)
(
new
ObjectInputStream
(
System
.
in
).
readObject
());
if
(!
o
.
toString
().
equals
(
oid
))
throw
new
Exception
(
"Read Fail "
+
o
+
", not "
+
oid
);
}
static
void
badin
()
throws
Exception
{
boolean
pass
=
true
;
try
{
new
ObjectInputStream
(
System
.
in
).
readObject
();
}
catch
(
Exception
e
)
{
pass
=
false
;
}
if
(
pass
)
throw
new
Exception
(
"Should fail but not"
);
}
static
void
out
(
String
oid
)
throws
Exception
{
new
ObjectOutputStream
(
System
.
out
).
writeObject
(
new
ObjectIdentifier
(
oid
));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录