You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 property coremods.testmod). Then, it uses Boolean.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 be Boolean.parseBoolean() or to not parse the system property before feeding it into Boolean.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.
Well that's a interesting mistake. Has anyone actually ever used this function? Is the bouncer property ever actually used?
Also, would probably be worth moving the 'compatibility' logic to a separate private method and deprecating it. So we can just delete the logic next time a breaking window happens.
In my opinion, the bouncer property is a terrible fucking idea, especially with coremod. artificially prepended to it. And yeah, I can move the old logic to a deprecated, private method.
Something else I noticed when looking back on the original logic: the default value (second argument) is "TRUE", which implies that if the property wasn't found, the method was supposed to return true anyways??? What a mess.
In my opinion, the bouncer property is a terrible fucking idea, especially with coremod. artificially prepended to it.
Should I make another PR after this one if I want to do this? I'd personally like to have that coremod. thing removed sooner rather than later, since it's just a nuisance especially since ASMAPI only lets them try to get booleans from properties and not full-on Strings.
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
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)