Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
c51d2cc3
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c51d2cc3
编写于
10月 09, 2012
作者:
N
naoto
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7200341: DateFormatSymbols.hashCode() throws ArrayIndexOutOfBoundsException in some circumstances
Reviewed-by: okutsu
上级
2f66a543
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
51 addition
and
6 deletion
+51
-6
src/share/classes/java/text/DateFormatSymbols.java
src/share/classes/java/text/DateFormatSymbols.java
+31
-5
test/java/util/PluggableLocale/DateFormatSymbolsProviderTest.java
...a/util/PluggableLocale/DateFormatSymbolsProviderTest.java
+14
-0
test/java/util/PluggableLocale/DateFormatSymbolsProviderTest.sh
...ava/util/PluggableLocale/DateFormatSymbolsProviderTest.sh
+1
-1
test/java/util/PluggableLocale/fooprovider.jar
test/java/util/PluggableLocale/fooprovider.jar
+0
-0
test/java/util/PluggableLocale/providersrc/DateFormatSymbolsProviderImpl.java
...ableLocale/providersrc/DateFormatSymbolsProviderImpl.java
+5
-0
未找到文件。
src/share/classes/java/text/DateFormatSymbols.java
浏览文件 @
c51d2cc3
...
...
@@ -45,6 +45,7 @@ import java.lang.ref.SoftReference;
import
java.text.spi.DateFormatSymbolsProvider
;
import
java.util.Arrays
;
import
java.util.Locale
;
import
java.util.Objects
;
import
java.util.ResourceBundle
;
import
java.util.TimeZone
;
import
java.util.concurrent.ConcurrentHashMap
;
...
...
@@ -366,6 +367,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
*/
public
void
setEras
(
String
[]
newEras
)
{
eras
=
Arrays
.
copyOf
(
newEras
,
newEras
.
length
);
cachedHashCode
=
0
;
}
/**
...
...
@@ -393,6 +395,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
*/
public
void
setMonths
(
String
[]
newMonths
)
{
months
=
Arrays
.
copyOf
(
newMonths
,
newMonths
.
length
);
cachedHashCode
=
0
;
}
/**
...
...
@@ -420,6 +423,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
*/
public
void
setShortMonths
(
String
[]
newShortMonths
)
{
shortMonths
=
Arrays
.
copyOf
(
newShortMonths
,
newShortMonths
.
length
);
cachedHashCode
=
0
;
}
/**
...
...
@@ -439,6 +443,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
*/
public
void
setWeekdays
(
String
[]
newWeekdays
)
{
weekdays
=
Arrays
.
copyOf
(
newWeekdays
,
newWeekdays
.
length
);
cachedHashCode
=
0
;
}
/**
...
...
@@ -458,6 +463,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
*/
public
void
setShortWeekdays
(
String
[]
newShortWeekdays
)
{
shortWeekdays
=
Arrays
.
copyOf
(
newShortWeekdays
,
newShortWeekdays
.
length
);
cachedHashCode
=
0
;
}
/**
...
...
@@ -474,6 +480,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
*/
public
void
setAmPmStrings
(
String
[]
newAmpms
)
{
ampms
=
Arrays
.
copyOf
(
newAmpms
,
newAmpms
.
length
);
cachedHashCode
=
0
;
}
/**
...
...
@@ -558,6 +565,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
zoneStrings
=
aCopy
;
isZoneStringsSet
=
true
;
cachedHashCode
=
0
;
}
/**
...
...
@@ -576,6 +584,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
public
void
setLocalPatternChars
(
String
newLocalPatternChars
)
{
// Call toString() to throw an NPE in case the argument is null
localPatternChars
=
newLocalPatternChars
.
toString
();
cachedHashCode
=
0
;
}
/**
...
...
@@ -597,12 +606,23 @@ public class DateFormatSymbols implements Serializable, Cloneable {
* Override hashCode.
* Generates a hash code for the DateFormatSymbols object.
*/
@Override
public
int
hashCode
()
{
int
hashcode
=
0
;
String
[][]
zoneStrings
=
getZoneStringsWrapper
();
for
(
int
index
=
0
;
index
<
zoneStrings
[
0
].
length
;
++
index
)
hashcode
^=
zoneStrings
[
0
][
index
].
hashCode
();
return
hashcode
;
int
hashCode
=
cachedHashCode
;
if
(
hashCode
==
0
)
{
hashCode
=
5
;
hashCode
=
11
*
hashCode
+
Arrays
.
hashCode
(
eras
);
hashCode
=
11
*
hashCode
+
Arrays
.
hashCode
(
months
);
hashCode
=
11
*
hashCode
+
Arrays
.
hashCode
(
shortMonths
);
hashCode
=
11
*
hashCode
+
Arrays
.
hashCode
(
weekdays
);
hashCode
=
11
*
hashCode
+
Arrays
.
hashCode
(
shortWeekdays
);
hashCode
=
11
*
hashCode
+
Arrays
.
hashCode
(
ampms
);
hashCode
=
11
*
hashCode
+
Arrays
.
deepHashCode
(
getZoneStringsWrapper
());
hashCode
=
11
*
hashCode
+
Objects
.
hashCode
(
localPatternChars
);
cachedHashCode
=
hashCode
;
}
return
hashCode
;
}
/**
...
...
@@ -641,6 +661,11 @@ public class DateFormatSymbols implements Serializable, Cloneable {
private
transient
int
lastZoneIndex
=
0
;
/**
* Cached hash code
*/
transient
volatile
int
cachedHashCode
=
0
;
private
void
initializeData
(
Locale
desiredLocale
)
{
locale
=
desiredLocale
;
...
...
@@ -782,6 +807,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
dst
.
zoneStrings
=
null
;
}
dst
.
localPatternChars
=
src
.
localPatternChars
;
dst
.
cachedHashCode
=
0
;
}
/**
...
...
test/java/util/PluggableLocale/DateFormatSymbolsProviderTest.java
浏览文件 @
c51d2cc3
...
...
@@ -44,6 +44,7 @@ public class DateFormatSymbolsProviderTest extends ProviderTest {
DateFormatSymbolsProviderTest
()
{
availableLocalesTest
();
objectValidityTest
();
hashCodeTest
();
}
void
availableLocalesTest
()
{
...
...
@@ -124,4 +125,17 @@ public class DateFormatSymbolsProviderTest extends ProviderTest {
}
}
}
// Bug 7200341.
void
hashCodeTest
()
{
for
(
Locale
target:
availloc
)
{
// look for provider's object
DateFormatSymbols
dfs
=
DateFormatSymbols
.
getInstance
(
target
);
if
(
dfs
.
getClass
().
getSimpleName
().
equals
(
"FooDateFormatSymbols"
))
{
// call its hashCode(). success if no ArrayIndexOutOfBoundsException is thrown.
dfs
.
hashCode
();
break
;
}
}
}
}
test/java/util/PluggableLocale/DateFormatSymbolsProviderTest.sh
浏览文件 @
c51d2cc3
...
...
@@ -23,6 +23,6 @@
#!/bin/sh
#
# @test
# @bug 4052440
# @bug 4052440
7200341
# @summary DateFormatSymbolsProvider tests
# @run shell ExecTest.sh foo DateFormatSymbolsProviderTest true
test/java/util/PluggableLocale/fooprovider.jar
浏览文件 @
c51d2cc3
无法预览此类型文件
test/java/util/PluggableLocale/providersrc/DateFormatSymbolsProviderImpl.java
浏览文件 @
c51d2cc3
...
...
@@ -221,5 +221,10 @@ public class DateFormatSymbolsProviderImpl extends DateFormatSymbolsProvider {
public
void
setAmPmStrings
(
String
[]
newAmpms
)
{
ampms
=
newAmpms
;
}
@Override
public
String
[][]
getZoneStrings
()
{
return
new
String
[
0
][
0
];
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录