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

allow different mapping for reflection #3470

Merged
merged 8 commits into from
Aug 23, 2021

Conversation

LogicFan
Copy link
Contributor

@LogicFan LogicFan commented Jul 13, 2021

It's configured using json file. I've included one for sponge vanilla.

@LogicFan
Copy link
Contributor Author

Should be fixed now.

@Zidane
Copy link
Member

Zidane commented Jul 13, 2021

@gabizou @zml2008

Any changes? Looks straightforward to me.

@LogicFan
Copy link
Contributor Author

fixed.

@zml2008
Copy link
Member

zml2008 commented Jul 13, 2021

This looks like a fairly straightforward implementation -- but it doesn't capture the situation of using a SpongeForge/SpongeFabric jar in a dev environment with different mappings. Forge has an (iirc) INameMappingService, fabric loader has some mapping API as well to convert from SRG/intermediary strings into the appropriate dev-time mappings. Could you look into exposing that, probably through Launch as well?

@LogicFan
Copy link
Contributor Author

Could you look into exposing that, probably through Launch as well?

I looked at the fabric part. So, to remap a method, it also needs to also pass a descriptor. I also don't want this API to be restricted to method only. It might be necessary to use reflection on class name or field one day. I think it will be a little bit tricky to design an API that could facilitate potential future use & quite clean right now.

I think I will need to look at the forge part too to have a better understanding of what will be the best way.

@LogicFan
Copy link
Contributor Author

Hi, @zml2008 , do you think this new approach works better? or is it overkill?

@zml2008
Copy link
Member

zml2008 commented Jul 24, 2021

This is a step in the right direction -- however, taking a look at Fabric's Mapping resolver API, this API would fail when used in development environments, particularly if a user depended on your fabric implementation from a Yarn-based workspace (since Sponge will at most know about official names and intermediary). You'd have a mismatch between the class literals (remapped by TR), and the method names (string constants), unless you were in a prod environment using intermediary class names.

@LogicFan
Copy link
Contributor Author

You'd have a mismatch between the class literals (remapped by TR), and the method names (string constants)

As you can see in the fabric mapping resolver, there is a unmap method, which can be used for this situation. If a user runs things on yarn environment and the jar is in an intermediary, then the process will be

owner (class literal) -> getName (yarn name) -> unmap (intermediary name)
desc (class literals) -> similar to above
method (mojname) -> some how make it intermediary name -> map (with the intermediary owner and desc described above) -> yarn name

@zml2008
Copy link
Member

zml2008 commented Jul 24, 2021

Ah I see that, thanks for clairfying -- it's a touch non-traditional, but the class literal-based API is less error prone. I'm fine with that, but would be even better to see a class literal-based API exposed directly upstream in loader.

@LogicFan
Copy link
Contributor Author

styles fixed.

@LogicFan
Copy link
Contributor Author

Since SpongeForge is developed using forge-loom (which also uses tiny-remapper IIRC), FabricMC/tiny-remapper#70 might be a better solution than this PR.

@zml2008 zml2008 self-assigned this Aug 23, 2021
@zml2008 zml2008 closed this in 5de812e Aug 23, 2021
@zml2008 zml2008 merged commit 5de812e into SpongePowered:api-8 Aug 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants