[
https://issues.apache.org/jira/browse/HADOOP-15033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16296805#comment-16296805
]
ASF GitHub Bot commented on HADOOP-15033:
-----------------------------------------
Github user steveloughran commented on a diff in the pull request:
https://github.com/apache/hadoop/pull/291#discussion_r157757732
--- Diff:
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Shell.java
---
@@ -89,6 +89,22 @@ public static boolean isJava7OrAbove() {
return true;
}
+ private static final boolean IS_JAVA9_OR_ABOVE;
+ static {
+ int major = 0;
+ try {
+ // 1.8.0 -> 1, 10-ea+30 -> 10, 18.03 -> 18, 11 -> 11 etc.
+ String version = System.getProperty("java.version");
+ major = Integer.parseInt(version.split("\\.")[0].split("-")[0]);
+ } catch (NumberFormatException ignored) {
+ }
+ IS_JAVA9_OR_ABOVE = major >= 9;
+ }
+
+ public static boolean isJava9OrAbove() {
+ return IS_JAVA9_OR_ABOVE;
+ }
--- End diff --
Given we've already got isJava7OrAbove() tagged as deprecated, we should
stop repeating the same mistake.
How about some: `boolean IsJavaVersionAtLeast(int)` which can do checks for
versions, store this parsed major in a private static (set the default value to
8, obviously) field, then have the new predicate return true if the param is >=
the cached value
> Use java.util.zip.CRC32C for Java 9 and above
> ---------------------------------------------
>
> Key: HADOOP-15033
> URL: https://issues.apache.org/jira/browse/HADOOP-15033
> Project: Hadoop Common
> Issue Type: Improvement
> Components: performance, util
> Affects Versions: 3.0.0
> Reporter: Dmitry Chuyko
> Labels: Java9, common, jdk9
> Attachments: HADOOP-15033.001.patch, HADOOP-15033.001.patch,
> HADOOP-15033.002.patch, HADOOP-15033.003.patch, HADOOP-15033.003.patch,
> HADOOP-15033.004.patch
>
>
> java.util.zip.CRC32C implementation is available since Java 9.
> https://docs.oracle.com/javase/9/docs/api/java/util/zip/CRC32C.html
> Platform specific assembler intrinsics make it more effective than any pure
> Java implementation.
> Hadoop is compiled against Java 8 but class constructor may be accessible
> with method handle on 9 to instances implementing Checksum in runtime.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]