Posted April 20, 20214 yr Is there a syntax to make all methods of a class public? With fields it was just *, but what is it with methods? Thanks for your help!
April 20, 20214 yr Author Because it is more convenient than looking up mappings for potentially duzens of methods.
April 20, 20214 yr The correct answer is don't and spend the time to properly utilize methods in the system. If you need to call a private or protected method outside of its context, you're most likely doing something wrong.
April 21, 20214 yr Author What is the difference? Reflection is in run time, access transforming is done before the classes are loaded, or what? Why is it not recommended to transform methods, but fields are fine? It should not hurt other mods, right? Youre not taking away functionality, or am I missunderstanding sth? And do I really need to get rid of 300 lines access transformers for protected getters? (Took quite a while)
April 21, 20214 yr Author 54 minutes ago, diesieben07 said: If you make a method public that was previously protected you must access transform all classes that inherit from it as well because they potentially override the method (also protected). If you just make the base method public, the extending class now crashes with a IncompatibleClassChangeError, because you cannot override a public method with a protected one. Since you cannot possibly know all extending classes (you'd have to know all the mods out there), this cannot be done safely. It is okay to do in the case of private or package private, since in those cases the possible overriding methods are either none (if the method was private) or well known (only classes in the same package apply). But even then it is only mostly safe because Minecraft uses SRG names at runtime, so the risk of someone inadvertently using the same method name in a subclass (which would then error or rather change behavior) is minute. Yes, you do. You are breaking any mod that overrides these methods as outlined above. Aww thanks i guess... Makes sense now.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.