RFR [9] 8151140: Replace use of lambda/method ref in jdk.Version constructor
Chris Hegarty
chris.hegarty at oracle.com
Thu Mar 3 10:31:58 UTC 2016
Since 8150163 [1], jdk.Version can now be used earlier in startup, but not
always. It was noticed that the use of lambda / method ref in the constructor,
in some cases, was the first usage of such, and incurred the initialization
costs of the java.lang.invoke infrastructure ( which can take a significant
amount of time on first access).
The solution is to simple avoid the usage, as has been done in other “core"
areas, that may be used early in startup.
diff --git a/src/java.base/share/classes/jdk/Version.java b/src/java.base/share/classes/jdk/Version.java
--- a/src/java.base/share/classes/jdk/Version.java
+++ b/src/java.base/share/classes/jdk/Version.java
@@ -28,10 +28,10 @@
import java.math.BigInteger;
import java.security.AccessController;
import java.security.PrivilegedAction;
+import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
-import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
@@ -208,11 +208,10 @@
+ s + "'");
// $VNUM is a dot-separated list of integers of arbitrary length
- version
- = Collections.unmodifiableList(
- Arrays.stream(m.group(VNUM_GROUP).split("\\."))
- .map(Integer::parseInt)
- .collect(Collectors.toList()));
+ List<Integer> list = new ArrayList<>();
+ for (String i : m.group(VNUM_GROUP).split("\\."))
+ list.add(Integer.parseInt(i));
+ version = Collections.unmodifiableList(list);
pre = Optional.ofNullable(m.group(PRE_GROUP));
-Chris.
[1] https://bugs.openjdk.java.net/browse/JDK-8150976
More information about the core-libs-dev
mailing list