Merge files from jdk11u/jdk-11.0.13-ga into the expected_upstream branch
List of files:
ojluni/src/main/java/java/lang/Integer.java
ojluni/src/main/java/java/lang/Long.java
ojluni/src/main/java/java/lang/String.java
Generated by tools/expected_upstream/ojluni_refresh_files.py
Test: N/A
Change-Id: I761c991751e456085f1a675b91c9e536823ff138
diff --git a/ojluni/src/main/java/java/lang/Integer.java b/ojluni/src/main/java/java/lang/Integer.java
index fa059a5..43cd0f3 100644
--- a/ojluni/src/main/java/java/lang/Integer.java
+++ b/ojluni/src/main/java/java/lang/Integer.java
@@ -997,7 +997,8 @@
private static class IntegerCache {
static final int low = -128;
static final int high;
- static final Integer cache[];
+ static final Integer[] cache;
+ static Integer[] archivedCache;
static {
// high value may be configured by property
@@ -1016,11 +1017,19 @@
}
high = h;
- cache = new Integer[(high - low) + 1];
- int j = low;
- for(int k = 0; k < cache.length; k++)
- cache[k] = new Integer(j++);
+ // Load IntegerCache.archivedCache from archive, if possible
+ VM.initializeFromArchive(IntegerCache.class);
+ int size = (high - low) + 1;
+ // Use the archived cache if it exists and is large enough
+ if (archivedCache == null || size > archivedCache.length) {
+ Integer[] c = new Integer[size];
+ int j = low;
+ for(int k = 0; k < c.length; k++)
+ c[k] = new Integer(j++);
+ archivedCache = c;
+ }
+ cache = archivedCache;
// range [-128, 127] must be interned (JLS7 5.1.7)
assert IntegerCache.high >= 127;
}
@@ -1388,7 +1397,7 @@
boolean negative = false;
Integer result;
- if (nm.length() == 0)
+ if (nm.isEmpty())
throw new NumberFormatException("Zero length string");
char firstChar = nm.charAt(0);
// Handle sign, if present
diff --git a/ojluni/src/main/java/java/lang/Long.java b/ojluni/src/main/java/java/lang/Long.java
index d9066ff..489417a 100644
--- a/ojluni/src/main/java/java/lang/Long.java
+++ b/ojluni/src/main/java/java/lang/Long.java
@@ -1229,7 +1229,7 @@
boolean negative = false;
Long result;
- if (nm.length() == 0)
+ if (nm.isEmpty())
throw new NumberFormatException("Zero length string");
char firstChar = nm.charAt(0);
// Handle sign, if present
diff --git a/ojluni/src/main/java/java/lang/String.java b/ojluni/src/main/java/java/lang/String.java
index 3f497c7..7ff9ed4 100644
--- a/ojluni/src/main/java/java/lang/String.java
+++ b/ojluni/src/main/java/java/lang/String.java
@@ -1934,8 +1934,7 @@
* characters followed by the string argument's characters.
*/
public String concat(String str) {
- int olen = str.length();
- if (olen == 0) {
+ if (str.isEmpty()) {
return this;
}
if (coder() == str.coder()) {
@@ -1947,6 +1946,7 @@
return new String(buf, coder);
}
int len = length();
+ int olen = str.length();
byte[] buf = StringUTF16.newBytesFor(len + olen);
getBytes(buf, 0, UTF16);
str.getBytes(buf, len, UTF16);
@@ -2307,7 +2307,7 @@
// Construct result
int resultSize = list.size();
if (limit == 0) {
- while (resultSize > 0 && list.get(resultSize - 1).length() == 0) {
+ while (resultSize > 0 && list.get(resultSize - 1).isEmpty()) {
resultSize--;
}
}