Fixed detecting Windows 11 and wrong class casting#10
Open
skmedix wants to merge 2 commits into
Open
Conversation
Owner
|
Hi @skmedix thank you very much for this pull request! One thing though, before I check the rest... It is my intention not to throw exceptions if there is an error in this library that doesn't cause an app to crash. Thanks |
|
Regarding output, maybe please consider #14 |
|
My proposal to avoid the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.versionproperty, 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_11is also a result of anos.namematch.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.