jide-oss
jide-oss copied to clipboard
SystemInfo.JavaVersion can't correctly parse single Java versions like "12", "13", ..
Using the latest version of JavaSE-13 whose version is "13" with no dots, I encountered a high CPU usage in my code which did not exist in JavaSE-12.0.2 or earlier.
After tracing it I found out that com.jidesoft.utils.SystemInfo.JavaVersion
is not detecting Java version correctly and is reporting it as Java v1.4 !
Looking at the code was obvious why; I see that the RegEx used to parse Java version:
private static Pattern SUN_JAVA_VERSION = Pattern.compile("(\\d+\\.\\d+)(\\.(\\d+))?(_([^-]+))?(.*)");
is expecting at least a version with two digits separated by a dot which is not the case any more thanks to the new Java 10 versioning scheme, now we are going to encounter versions like "13" which is what I have.
The fix is straight forward, something like this which I've applied and things are now working fine for me on JavaSE-13:
private static Pattern SUN_JAVA_VERSION = Pattern.compile("(\\d+(?:\\.\\d+)?)(\\.(\\d+))?(_([^-]+))?(.*)");
I think it would be wise to change the other safe net RegEx, too:
private static Pattern SUN_JAVA_VERSION_SIMPLE = Pattern.compile("(\\d+(?:\\.\\d+)?)(\\.(\\d+))?(.*)");
👍 I can also confirm this problem.
Thank you both. I just committed and pushed the change.