Skip to content
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

SystemInfo.JavaVersion can't correctly parse single Java versions like "12", "13", .. #42

Open
hamid-nazari opened this issue Sep 29, 2019 · 4 comments

Comments

@hamid-nazari
Copy link

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+))?(.*)");

@raducoravu
Copy link

👍 I can also confirm this problem.

@jidesoft
Copy link
Owner

Thank you both. I just committed and pushed the change.

@mokun
Copy link

mokun commented Aug 24, 2024

Should close this issue since we're going to support jdk 17 in 3.7.16, right ?

@hamid-nazari
Copy link
Author

hamid-nazari commented Aug 24, 2024

I guess so, please have it tested though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants