Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
9871ad68
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看板
提交
9871ad68
编写于
12月 02, 2014
作者:
P
psandoz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8066397: Remove network-related seed initialization code in ThreadLocal/SplittableRandom
Reviewed-by: alanb, dl, chegar, rriggs, shade
上级
203d62fa
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
6 addition
and
64 deletion
+6
-64
src/share/classes/java/util/SplittableRandom.java
src/share/classes/java/util/SplittableRandom.java
+5
-34
src/share/classes/java/util/concurrent/ThreadLocalRandom.java
...share/classes/java/util/concurrent/ThreadLocalRandom.java
+1
-30
未找到文件。
src/share/classes/java/util/SplittableRandom.java
浏览文件 @
9871ad68
...
...
@@ -25,7 +25,6 @@
package
java.util
;
import
java.net.NetworkInterface
;
import
java.util.concurrent.atomic.AtomicLong
;
import
java.util.function.IntConsumer
;
import
java.util.function.LongConsumer
;
...
...
@@ -140,11 +139,10 @@ public final class SplittableRandom {
* other cases, this split must be performed in a thread-safe
* manner, so we use an AtomicLong to represent the seed rather
* than use an explicit SplittableRandom. To bootstrap the
* defaultGen, we start off using a seed based on current time and
* network interface address unless the java.util.secureRandomSeed
* property is set. This serves as a slimmed-down (and insecure)
* variant of SecureRandom that also avoids stalls that may occur
* when using /dev/random.
* defaultGen, we start off using a seed based on current time
* unless the java.util.secureRandomSeed property is set. This
* serves as a slimmed-down (and insecure) variant of SecureRandom
* that also avoids stalls that may occur when using /dev/random.
*
* It is a relatively simple matter to apply the basic design here
* to use 128 bit seeds. However, emulating 128bit arithmetic and
...
...
@@ -237,34 +235,7 @@ public final class SplittableRandom {
s
=
(
s
<<
8
)
|
((
long
)(
seedBytes
[
i
])
&
0xff
L
);
return
s
;
}
long
h
=
0L
;
try
{
Enumeration
<
NetworkInterface
>
ifcs
=
NetworkInterface
.
getNetworkInterfaces
();
boolean
retry
=
false
;
// retry once if getHardwareAddress is null
while
(
ifcs
.
hasMoreElements
())
{
NetworkInterface
ifc
=
ifcs
.
nextElement
();
if
(!
ifc
.
isVirtual
())
{
// skip fake addresses
byte
[]
bs
=
ifc
.
getHardwareAddress
();
if
(
bs
!=
null
)
{
int
n
=
bs
.
length
;
int
m
=
Math
.
min
(
n
>>>
1
,
4
);
for
(
int
i
=
0
;
i
<
m
;
++
i
)
h
=
(
h
<<
16
)
^
(
bs
[
i
]
<<
8
)
^
bs
[
n
-
1
-
i
];
if
(
m
<
4
)
h
=
(
h
<<
8
)
^
bs
[
n
-
1
-
m
];
h
=
mix64
(
h
);
break
;
}
else
if
(!
retry
)
retry
=
true
;
else
break
;
}
}
}
catch
(
Exception
ignore
)
{
}
return
(
h
^
mix64
(
System
.
currentTimeMillis
())
^
return
(
mix64
(
System
.
currentTimeMillis
())
^
mix64
(
System
.
nanoTime
()));
}
...
...
src/share/classes/java/util/concurrent/ThreadLocalRandom.java
浏览文件 @
9871ad68
...
...
@@ -36,8 +36,6 @@
package
java.util.concurrent
;
import
java.io.ObjectStreamField
;
import
java.net.NetworkInterface
;
import
java.util.Enumeration
;
import
java.util.Random
;
import
java.util.Spliterator
;
import
java.util.concurrent.atomic.AtomicInteger
;
...
...
@@ -147,34 +145,7 @@ public class ThreadLocalRandom extends Random {
s
=
(
s
<<
8
)
|
((
long
)(
seedBytes
[
i
])
&
0xff
L
);
return
s
;
}
long
h
=
0L
;
try
{
Enumeration
<
NetworkInterface
>
ifcs
=
NetworkInterface
.
getNetworkInterfaces
();
boolean
retry
=
false
;
// retry once if getHardwareAddress is null
while
(
ifcs
.
hasMoreElements
())
{
NetworkInterface
ifc
=
ifcs
.
nextElement
();
if
(!
ifc
.
isVirtual
())
{
// skip fake addresses
byte
[]
bs
=
ifc
.
getHardwareAddress
();
if
(
bs
!=
null
)
{
int
n
=
bs
.
length
;
int
m
=
Math
.
min
(
n
>>>
1
,
4
);
for
(
int
i
=
0
;
i
<
m
;
++
i
)
h
=
(
h
<<
16
)
^
(
bs
[
i
]
<<
8
)
^
bs
[
n
-
1
-
i
];
if
(
m
<
4
)
h
=
(
h
<<
8
)
^
bs
[
n
-
1
-
m
];
h
=
mix64
(
h
);
break
;
}
else
if
(!
retry
)
retry
=
true
;
else
break
;
}
}
}
catch
(
Exception
ignore
)
{
}
return
(
h
^
mix64
(
System
.
currentTimeMillis
())
^
return
(
mix64
(
System
.
currentTimeMillis
())
^
mix64
(
System
.
nanoTime
()));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录