Fixed detecting Windows 11 and wrong class casting #10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The changes merged from PR #6 are incorrect and are breaking the library. It introduced two bugs.
First, Windows 11 is no longer detected. The switch statement is getting a value from the
os.version
property, but we must remember that Windows 11 was essentially a Windows 10 refresh. This property returns 10 instead of 11 because of that. If we look into commons-lang3 to class SystemUtils, we can see that fieldIS_OS_WINDOWS_11
is also a result of anos.name
match.Secondly, returning an anonymous method may seem useful, but it is not possible with the current library design. If we encounter a situation where none of the system is supported and we try to cast the return into a specific ThemeWindowManager, it will throw a ClassCastException. It can be casted to ThemeWindowManager, but not to the created anonymous ThemeWindowManagerFactory$1. Therefore, I suggest making the method Nullable or considering using Optionals.