Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Access Transform all methods of class


Recommended Posts

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) 

Link to post
Share on other sites

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.

8 minutes ago, DasBabyPixel said:

And do I really need to get rid of 300 lines access transformers for protected getters? (Took quite a while) 

Yes, you do. You are breaking any mod that overrides these methods as outlined above.

Link to post
Share on other sites
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. :/

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.