Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
e02d4f1c
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看板
提交
e02d4f1c
编写于
9月 11, 2013
作者:
C
chegar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8023090: Additional debug info for java/net/NetworkInterface/Equals.java
Reviewed-by: alanb
上级
e77ef9ea
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
51 addition
and
9 deletion
+51
-9
test/java/net/NetworkInterface/Equals.java
test/java/net/NetworkInterface/Equals.java
+51
-9
未找到文件。
test/java/net/NetworkInterface/Equals.java
浏览文件 @
e02d4f1c
...
@@ -25,41 +25,83 @@
...
@@ -25,41 +25,83 @@
* @bug 7003398
* @bug 7003398
* @run main/othervm Equals
* @run main/othervm Equals
*/
*/
import
java.net.NetworkInterface
;
import
java.io.ByteArrayOutputStream
;
import
java.io.PrintStream
;
import
java.net.InetAddress
;
import
java.net.InetAddress
;
import
java.net.NetworkInterface
;
import
java.net.SocketException
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Enumeration
;
import
java.util.Enumeration
;
import
java.util.HashMap
;
import
java.util.HashMap
;
public
class
Equals
{
public
class
Equals
{
public
static
void
main
(
String
args
[])
throws
Exception
{
public
static
void
main
(
String
args
[])
throws
Exception
{
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
PrintStream
bufferedOut
=
new
PrintStream
(
baos
);
Enumeration
nifs1
=
NetworkInterface
.
getNetworkInterfaces
();
Enumeration
<
NetworkInterface
>
nifs1
=
NetworkInterface
.
getNetworkInterfaces
();
HashMap
<
String
,
Integer
>
hashes
=
new
HashMap
<>();
HashMap
<
String
,
Integer
>
hashes
=
new
HashMap
<>();
HashMap
<
String
,
NetworkInterface
>
nicMap
=
new
HashMap
<>();
HashMap
<
String
,
NetworkInterface
>
nicMap
=
new
HashMap
<>();
while
(
nifs1
.
hasMoreElements
())
{
while
(
nifs1
.
hasMoreElements
())
{
NetworkInterface
ni
=
(
NetworkInterface
)
nifs1
.
nextElement
();
NetworkInterface
ni
=
nifs1
.
nextElement
();
hashes
.
put
(
ni
.
getName
(),
ni
.
hashCode
());
hashes
.
put
(
ni
.
getName
(),
ni
.
hashCode
());
nicMap
.
put
(
ni
.
getName
(),
ni
);
nicMap
.
put
(
ni
.
getName
(),
ni
);
displayInterfaceInformation
(
ni
,
bufferedOut
);
bufferedOut
.
flush
();
}
}
System
.
setSecurityManager
(
new
SecurityManager
());
System
.
setSecurityManager
(
new
SecurityManager
());
Enumeration
nifs2
=
NetworkInterface
.
getNetworkInterfaces
();
Enumeration
<
NetworkInterface
>
nifs2
=
NetworkInterface
.
getNetworkInterfaces
();
while
(
nifs2
.
hasMoreElements
())
{
while
(
nifs2
.
hasMoreElements
())
{
NetworkInterface
ni
=
(
NetworkInterface
)
nifs2
.
nextElement
();
NetworkInterface
ni
=
nifs2
.
nextElement
();
NetworkInterface
niOrig
=
nicMap
.
get
(
ni
.
getName
());
NetworkInterface
niOrig
=
nicMap
.
get
(
ni
.
getName
());
int
h
=
hashes
.
get
(
ni
.
getName
());
int
h
=
ni
.
hashCode
();
if
(
h
!=
ni
.
hashCode
())
{
if
(
h
!=
hashes
.
get
(
ni
.
getName
()))
{
throw
new
RuntimeException
(
"Hashcodes different for "
+
System
.
out
.
printf
(
"%nSystem information:%n"
);
System
.
out
.
printf
(
"%s"
,
baos
.
toString
(
"UTF8"
));
System
.
out
.
printf
(
"%nni.hashCode() returned %d, expected %d, for:%n"
,
h
,
hashes
.
get
(
ni
.
getName
()));
displayInterfaceInformation
(
ni
,
System
.
out
);
throw
new
RuntimeException
(
"Hashcodes different for "
+
ni
.
getName
());
ni
.
getName
());
}
}
if
(!
ni
.
equals
(
niOrig
))
{
if
(!
ni
.
equals
(
niOrig
))
{
throw
new
RuntimeException
(
"equality different for "
+
System
.
out
.
printf
(
"%nSystem information:%n"
);
System
.
out
.
printf
(
"%s"
,
baos
.
toString
(
"UTF8"
));
System
.
out
.
printf
(
"%nExpected the following interfaces to be the same:%n"
);
displayInterfaceInformation
(
niOrig
,
System
.
out
);
displayInterfaceInformation
(
ni
,
System
.
out
);
throw
new
RuntimeException
(
"equality different for "
+
ni
.
getName
());
ni
.
getName
());
}
}
}
}
}
}
static
void
displayInterfaceInformation
(
NetworkInterface
netint
,
PrintStream
out
)
throws
SocketException
{
out
.
printf
(
"Display name: %s%n"
,
netint
.
getDisplayName
());
out
.
printf
(
"Name: %s%n"
,
netint
.
getName
());
Enumeration
<
InetAddress
>
inetAddresses
=
netint
.
getInetAddresses
();
for
(
InetAddress
inetAddress
:
Collections
.
list
(
inetAddresses
))
out
.
printf
(
"InetAddress: %s%n"
,
inetAddress
);
out
.
printf
(
"Up? %s%n"
,
netint
.
isUp
());
out
.
printf
(
"Loopback? %s%n"
,
netint
.
isLoopback
());
out
.
printf
(
"PointToPoint? %s%n"
,
netint
.
isPointToPoint
());
out
.
printf
(
"Supports multicast? %s%n"
,
netint
.
supportsMulticast
());
out
.
printf
(
"Virtual? %s%n"
,
netint
.
isVirtual
());
out
.
printf
(
"Hardware address: %s%n"
,
Arrays
.
toString
(
netint
.
getHardwareAddress
()));
out
.
printf
(
"MTU: %s%n"
,
netint
.
getMTU
());
out
.
printf
(
"Index: %s%n"
,
netint
.
getIndex
());
out
.
printf
(
"%n"
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录