Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
a7d24368
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看板
提交
a7d24368
编写于
7月 11, 2020
作者:
S
smarks
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8231800: Better listing of arrays
Reviewed-by: alanb, rhalade, ahgross, igerasim
上级
1b39e8ee
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
25 addition
and
19 deletion
+25
-19
src/share/classes/java/util/ArrayList.java
src/share/classes/java/util/ArrayList.java
+8
-6
src/share/classes/java/util/PriorityQueue.java
src/share/classes/java/util/PriorityQueue.java
+1
-2
src/share/classes/java/util/Vector.java
src/share/classes/java/util/Vector.java
+7
-5
src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java
...re/classes/java/util/concurrent/CopyOnWriteArrayList.java
+8
-4
src/share/classes/java/util/concurrent/PriorityBlockingQueue.java
...e/classes/java/util/concurrent/PriorityBlockingQueue.java
+1
-2
未找到文件。
src/share/classes/java/util/ArrayList.java
浏览文件 @
a7d24368
...
...
@@ -175,14 +175,16 @@ public class ArrayList<E> extends AbstractList<E>
* @throws NullPointerException if the specified collection is null
*/
public
ArrayList
(
Collection
<?
extends
E
>
c
)
{
elementData
=
c
.
toArray
();
if
((
size
=
elementData
.
length
)
!=
0
)
{
// c.toArray might (incorrectly) not return Object[] (see 6260652)
if
(
elementData
.
getClass
()
!=
Object
[].
class
)
elementData
=
Arrays
.
copyOf
(
elementData
,
size
,
Object
[].
class
);
Object
[]
a
=
c
.
toArray
();
if
((
size
=
a
.
length
)
!=
0
)
{
if
(
c
.
getClass
()
==
ArrayList
.
class
)
{
elementData
=
a
;
}
else
{
elementData
=
Arrays
.
copyOf
(
a
,
size
,
Object
[].
class
);
}
}
else
{
// replace with empty array.
this
.
elementData
=
EMPTY_ELEMENTDATA
;
elementData
=
EMPTY_ELEMENTDATA
;
}
}
...
...
src/share/classes/java/util/PriorityQueue.java
浏览文件 @
a7d24368
...
...
@@ -254,8 +254,7 @@ public class PriorityQueue<E> extends AbstractQueue<E>
private
void
initElementsFromCollection
(
Collection
<?
extends
E
>
c
)
{
Object
[]
a
=
c
.
toArray
();
// If c.toArray incorrectly doesn't return Object[], copy it.
if
(
a
.
getClass
()
!=
Object
[].
class
)
if
(
c
.
getClass
()
!=
ArrayList
.
class
)
a
=
Arrays
.
copyOf
(
a
,
a
.
length
,
Object
[].
class
);
int
len
=
a
.
length
;
if
(
len
==
1
||
this
.
comparator
!=
null
)
...
...
src/share/classes/java/util/Vector.java
浏览文件 @
a7d24368
...
...
@@ -171,11 +171,13 @@ public class Vector<E>
* @since 1.2
*/
public
Vector
(
Collection
<?
extends
E
>
c
)
{
elementData
=
c
.
toArray
();
elementCount
=
elementData
.
length
;
// c.toArray might (incorrectly) not return Object[] (see 6260652)
if
(
elementData
.
getClass
()
!=
Object
[].
class
)
elementData
=
Arrays
.
copyOf
(
elementData
,
elementCount
,
Object
[].
class
);
Object
[]
a
=
c
.
toArray
();
elementCount
=
a
.
length
;
if
(
c
.
getClass
()
==
ArrayList
.
class
)
{
elementData
=
a
;
}
else
{
elementData
=
Arrays
.
copyOf
(
a
,
elementCount
,
Object
[].
class
);
}
}
/**
...
...
src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java
浏览文件 @
a7d24368
...
...
@@ -34,6 +34,7 @@
package
java.util.concurrent
;
import
java.util.AbstractList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.Comparator
;
...
...
@@ -135,8 +136,7 @@ public class CopyOnWriteArrayList<E>
elements
=
((
CopyOnWriteArrayList
<?>)
c
).
getArray
();
else
{
elements
=
c
.
toArray
();
// c.toArray might (incorrectly) not return Object[] (see 6260652)
if
(
elements
.
getClass
()
!=
Object
[].
class
)
if
(
c
.
getClass
()
!=
java
.
util
.
ArrayList
.
class
)
elements
=
Arrays
.
copyOf
(
elements
,
elements
.
length
,
Object
[].
class
);
}
setArray
(
elements
);
...
...
@@ -762,6 +762,9 @@ public class CopyOnWriteArrayList<E>
*/
public
int
addAllAbsent
(
Collection
<?
extends
E
>
c
)
{
Object
[]
cs
=
c
.
toArray
();
if
(
c
.
getClass
()
!=
ArrayList
.
class
)
{
cs
=
cs
.
clone
();
}
if
(
cs
.
length
==
0
)
return
0
;
final
ReentrantLock
lock
=
this
.
lock
;
...
...
@@ -822,9 +825,10 @@ public class CopyOnWriteArrayList<E>
try
{
Object
[]
elements
=
getArray
();
int
len
=
elements
.
length
;
if
(
len
==
0
&&
cs
.
getClass
()
==
Object
[].
class
)
if
(
len
==
0
&&
(
c
.
getClass
()
==
CopyOnWriteArrayList
.
class
||
c
.
getClass
()
==
ArrayList
.
class
))
{
setArray
(
cs
);
else
{
}
else
{
Object
[]
newElements
=
Arrays
.
copyOf
(
elements
,
len
+
cs
.
length
);
System
.
arraycopy
(
cs
,
0
,
newElements
,
len
,
cs
.
length
);
setArray
(
newElements
);
...
...
src/share/classes/java/util/concurrent/PriorityBlockingQueue.java
浏览文件 @
a7d24368
...
...
@@ -263,8 +263,7 @@ public class PriorityBlockingQueue<E> extends AbstractQueue<E>
}
Object
[]
a
=
c
.
toArray
();
int
n
=
a
.
length
;
// If c.toArray incorrectly doesn't return Object[], copy it.
if
(
a
.
getClass
()
!=
Object
[].
class
)
if
(
c
.
getClass
()
!=
java
.
util
.
ArrayList
.
class
)
a
=
Arrays
.
copyOf
(
a
,
n
,
Object
[].
class
);
if
(
screen
&&
(
n
==
1
||
this
.
comparator
!=
null
))
{
for
(
int
i
=
0
;
i
<
n
;
++
i
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录