1 Star 0 Fork 81

wujiahua/openjdk-1.8.0

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
fix-LongCache-s-range-when-BoxTypeCachedMax-number-is-bigger-than-Integer.MAX_VALUE.patch 1.77 KB
一键复制 编辑 原始数据 按行查看 历史
jdkboy 提交于 2020-08-31 10:08 . Add several enhancement patches
diff --git a/jdk/src/share/classes/java/lang/Long.java b/jdk/src/share/classes/java/lang/Long.java
index 58c2cc3ba..7b6e14a97 100644
--- a/jdk/src/share/classes/java/lang/Long.java
+++ b/jdk/src/share/classes/java/lang/Long.java
@@ -812,12 +812,11 @@ public final class Long extends Number implements Comparable<Long> {
static final Long cache[];
static {
-
+ int h = 127;
String longCacheHighPropValue =
sun.misc.VM.getSavedProperty("java.lang.Long.LongCache.high");
if (longCacheHighPropValue != null) {
// high value may be configured by property
- int h = 0;
try {
int i = Integer.parseInt(longCacheHighPropValue);
i = Math.max(i, 127);
@@ -826,21 +825,13 @@ public final class Long extends Number implements Comparable<Long> {
} catch( NumberFormatException nfe) {
// If the property cannot be parsed into an int, ignore it.
}
- high = h;
- low = -h - 1;
- cache = new Long[(high - low) + 1];
- int j = low;
- for(int k = 0; k < cache.length; k++)
- cache[k] = new Long(j++);
-
- } else {
- low = -128;
- high = 127;
- cache = new Long[(high - low) + 1];
- int j = low;
- for(int k = 0; k < cache.length; k++)
- cache[k] = new Long(j++);
}
+ high = h;
+ low = -h - 1;
+ cache = new Long[(high - low) + 1];
+ int j = low;
+ for(int k = 0; k < cache.length; k++)
+ cache[k] = new Long(j++);
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/varlardohaeris/openjdk-1.8.0.git
git@gitee.com:varlardohaeris/openjdk-1.8.0.git
varlardohaeris
openjdk-1.8.0
openjdk-1.8.0
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385