-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-26392 Update ClassSize.BYTE_BUFFER for JDK17 #3784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
💔 -1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
hbase-common/src/main/java/org/apache/hadoop/hbase/util/ClassSize.java
Outdated
Show resolved
Hide resolved
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
| private static final String JVMVersion = System.getProperty("java.version"); | ||
|
|
||
| private static final Float JREVersion = | ||
| Float.parseFloat(System.getProperty("java.specification.version")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can not use the above 'java.version' to test whether it is JDK17?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above JVMVersion is a String like "1.8.0_302", which is not easy to be changed to a numeric variable. System.getProperty("java.specification.version") will only return String like "1", "8", "9", "10", "11", which can be easily parsed to a Float.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, got it. So why use Float here? I think it is just a integer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the java is 7 or 8, the String will be "1.7" or "1.8". In this case, if we parse it to Integer, it will raise an exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only version > 9, will return an Integer friendly String.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. But maybe we'd better unify them to the same pattern? For example, we check whether the returned property contains a dot, if so, we just parse the last character as a int, otherwise parse the whole String. And for the field name, better name it as JVM_RELEASE_VERSION or JVM_SPEC_VERSION? And also add some comments to explain the meaning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, have added comments and rename the variable. I think it is easier to read and use. (Version 8 is represented by 1)
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
| * NOTE: Java 8 will be represented by 1. | ||
| */ | ||
| private static final int JVM_SPEC_VERSION = JVM_SPEC_VERSION_STRING.contains(".") ? | ||
| (int) Float.parseFloat(System.getProperty("java.specification.version")) : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just use the above JVM_SPEC_VERSION_STRING? And let's use substring and then parse 1.8 to 8? Or use float and multiply 10 and then minus 10 to get 8? It is a bit strange that we return 1 for 1.8...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refined the version number logic, it now return a int like 8, 9, 10,....
| return ibmvendor && JVMVersion.contains("1.6.0"); | ||
| } | ||
|
|
||
| public static float getJVMSpecVersion() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should return int here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Float legacy, have fixed in the latest commit.
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
Signed-off-by: Duo Zhang <[email protected]>
Signed-off-by: Duo Zhang <[email protected]>
Signed-off-by: Duo Zhang <[email protected]>
https://issues.apache.org/jira/browse/HBASE-26392