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

Add a reflective name fixer, used for various calls in Class and MethodHandles.Lookup #458

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

AlexIIL
Copy link
Contributor

@AlexIIL AlexIIL commented Dec 7, 2024

This currently handles class names with mixed mappings, so doing:

Class.forName(ServerPlayerEntity.class.getName() + "$2");

now works correctly even if the inner class has been mapped differently.

This also supports field and method lookups using Class.get[Declared](Field/Method), as well as the MethodHandle.Lookup methods find[Static](Getter/Setter/VarHandle), and find(Static/Virtual/Special)`

This only works if the mappings are present for it - using proper names will never work outside of a development environment. In addition, we still encourage developers to use the MappingResolver to be sure the names will always be mapped correctly.

This commit also adds a somewhat unrelated change:

  • Fixed InternalsHiderTransform always adding one to the maximum stack size of every single method.

(I hadn't checked the order that visitMaxs is called in - and since it must be called last, just before visitEnd, we can wait and see if we've needed to emit code that requires an additional stack element, whereas I previously thought it was called first)

…odHandles.Lookup

This currently handles class names with mixed mappings, so doing:

Class.forName(ServerPlayerEntity.class.getName() + "$2");

now works correctly even if the inner class has been mapped differently.

This also supports field and method lookups using Class.get[Declared](Field/Method), as well as the MethodHandle.Lookup methods find[Static](Getter/Setter/VarHandle), and find(Static/Virtual/Special)

This only works if the mappings are present for it - using proper names will never work outside of a development environment.
In addition, we still encourage developers to use the MappingResolver to be sure the names will always be mapped correctly.

This commit also adds a somewhat unrelated change:

- Fixed InternalsHiderTransform always adding one to the maximum stack size of every single method.

(I hadn't checked the order that visitMaxs is called in - and since it must be called last, just before visitEnd, we can wait and see if we've needed to emit code that requires an additional stack element, whereas I previously thought it was called first)
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.

1 participant