Fix bugged logic in ASMAPI.getSystemPropertyFlag() #41
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.
ASMAPI.getSystemPropertyFlag() has a very strange logic issue that I believe is the result of an oversight when trying to parse the boolean from the resulting property.
The way it works right now is it gets the property from the system that it wants (say, inputting
"testmod"
will result in CoreMods getting the system propertycoremods.testmod
). Then, it usesBoolean.getBoolean()
to attempt to parse that String. However, this method already has the logic of trying to parse a system property as true in the first place. The correct method to use would beBoolean.parseBoolean()
or to not parse the system property before feeding it intoBoolean.getBoolean()
.This PR addresses this logic error by correctly utilizing
Boolean.getBoolean()
without parsing the system property early. Additionally, to retain logical compatibility, the old logic is contained in a separate method that is deprecated for removal. This allows developers who heavily utilize coremods to only rely on one system property being implemented, rather than needing a system property string that points to another system property string which equals true.Here is the documentation for Boolean.getBoolean() (jdk 16 docs because that is the CoreMods current build target): https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/Boolean.html#getBoolean(java.lang.String)