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

Fix bugged logic in ASMAPI.getSystemPropertyFlag() #41

Conversation

Jonathing
Copy link
Member

@Jonathing Jonathing commented Sep 20, 2023

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.

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)

@LexManos
Copy link
Member

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.

@Jonathing
Copy link
Member Author

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.

@Jonathing
Copy link
Member Author

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.

@Jonathing
Copy link
Member Author

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.

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

Successfully merging this pull request may close these issues.

3 participants